Determine if running in iOS Simulator

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Determine if running in iOS Simulator

Erik J. Thomas
XCode's iOS Simulator does NOT support running an AIR Mobile app that uses flash.data.EncryptedLocalStore. But since I already abstracted two different local storage implementations to support running my app on AIR Desktop (Mac and Windows) which don't support EncryptedLocalStore, I just need to know if the app is running in iOS Simulator in order to use the non-encrypted local storage implementation:

public class LocalStoreFactory {
   public static function getLocalStoreInstance(keyPrefix:String = null):ILocalStore {
      if (Platform.isDesktop || isIosSimulator()) {
            return LocalDataStore.instance(keyPrefix);
        } else {
            return LocalEncryptedDataStore.instance(keyPrefix);
        }
    }

    private static function isIosSimulator():Boolean {
        // what to put here?
    }
}

What I need is to figure out if the runtime environment is an iOS Simulator.

I've checked the values of Platform and Capabilities and see nothing of any help. The values are the same as on an actual device.

Thanks.

Erik
Reply | Threaded
Open this post in threaded view
|

Re: Determine if running in iOS Simulator

Erik J. Thomas
Hmmm, actually, I answered my own question. If Capabilities.cpuArchitecture is 'x86', then it's not on an iOS device which have always been arm. This should be a durable solution in my case (using macOS).

private static function isIosSimulator():Boolean {
   return Capabilities.cpuArchitecture == "x86";
}

Solved. Thanks.

Erik

On Mar 15, 2019, at 10:41 AM, Erik J. Thomas <[hidden email]> wrote:

XCode's iOS Simulator does NOT support running an AIR Mobile app that uses flash.data.EncryptedLocalStore. But since I already abstracted two different local storage implementations to support running my app on AIR Desktop (Mac and Windows) which don't support EncryptedLocalStore, I just need to know if the app is running in iOS Simulator in order to use the non-encrypted local storage implementation:

public class LocalStoreFactory {
  public static function getLocalStoreInstance(keyPrefix:String = null):ILocalStore {
     if (Platform.isDesktop || isIosSimulator()) {
           return LocalDataStore.instance(keyPrefix);
       } else {
           return LocalEncryptedDataStore.instance(keyPrefix);
       }
   }

   private static function isIosSimulator():Boolean {
       // what to put here?
   }
}

What I need is to figure out if the runtime environment is an iOS Simulator.

I've checked the values of Platform and Capabilities and see nothing of any help. The values are the same as on an actual device.

Thanks.

Erik