You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by "Erik J. Thomas" <er...@linqto.com> on 2019/03/15 17:41:39 UTC

Determine if running in iOS Simulator

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

Re: Determine if running in iOS Simulator

Posted by "Erik J. Thomas" <er...@linqto.com>.
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 <er...@linqto.com> 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