Reputation: 810
I am creating a mobile app for iOS and Android, with flashbuilder 4.6, Flex SDK 4.6.
I am using a ANE for Google Cloud Messaging, which I would like to skip when compiling for iOS. Are there any defines within flashbuilder to check if its compiling for iOS or Android, so i can skip the GCM imports. I don't want to change my compiler defines every time i compile my app.
Another way would be to use an IF statement in the compiler arguments:
if (compiling for ios)
-define+=CONFIG::IOS,true
else
-define+=CONFIG::IOS,false
Is it possible to do something like this, or are there any built-in compiler defines I can use in my code?
EDIT: package managers has 3 classes:
Compiling for android is fine, compiling for iOS gives errors on the classes from the ANE.
the NotificationManager.as:
package managers {
public class NotificationManager {
public static function getInstance():NotificationManager {
var ios:Boolean = (Capabilities.manufacturer.indexOf("iOS") != -1);
if (ios) {
return NotificationManagerIOS.getInstance();
} else {
return NotificationManagerAndroid.getInstance();
}
}
}
}
Upvotes: 4
Views: 1777
Reputation: 17217
The Flash Player AVM2 runtime is a virtual machine which uses a JIT compiler so what you want to do is not possible. However, there are 2 common ways to approach this issue:
Compile separately for each deployment target, especially if the embedded, OS-specific support files are large. You can set up your IDE project to contain multiple folders so that compiling for each target is simply opening each folder and compiling the contents. Read Christian Cantrell's Writing multiscreen AIR apps to see how setting up a project for separate deployment targets can be arranged.
If the embedded, OS-specific support files are small, or if you only want to manage one project folder, you can direct the runtime to use the appropriate file by determining its target using flash.system.Capabilities:
var isIOS:Boolean = (Capabilities.manufacturer.indexOf("iOS") != -1);
var isAndroid:Boolean = (Capabilities.manufacturer.indexOf("Android") != -1)
Upvotes: 2