-
Notifications
You must be signed in to change notification settings - Fork 3
Gradle platform variants
When you are targeting multiple platforms, you may need to customize each platform with different properties, you can do this using platform container from your build.gradle
file:
flair {
appId "com.hello.world"
appFullScreen true
appAspectRatio "any"
appAutoOrients true
ios {
appIdSuffix ".ios" // "com.hello.world.ios"
appFullScreen false
}
android {
appIdSuffix ".android" // "com.hello.world.android"
packageX86 true
}
desktop {
appIdSuffix ".desktop" // "com.hello.world.desktop"
}
}
You 'll have access to these platform containers only if you have applied the corresponding platform plugin. If you set the same property on both a platform container and default Flair properties container, properties from platform containers overwrite ones from default Flair properties expect with compilerOption
/compilerOptions
, adlParameter
/adlParameters
and packageExcludeDrawable
/packageExcludeDrawables
. Indeed these properties will be merged insteadof being overwritten, for example:
flair {
compilerOption "-swf-version=30"
ios {
compilerOption "-omit-trace-statements=true"
}
android {
}
}
In this example compiling iOS will use both -swf-version=30
and -omit-trace-statements=true
, compiling Android will use only -swf-version=30
.
You may used any Flair properties in platform container but moduleName
, packageName
and autoGenerateVariantDirectories
which are Flair global properties.
In your code you may access which platform is executing using compilation constants:
- PLATFORM::IOS
- PLATFORM::ANDROID
- PLATFORM::DESKTOP
Theses constants will be set to true or false depending which version you are running.
...
if( PLATFORM::IOS )
{
// do stuff only if ios
}
PLATFORM::IOS
{
public function myFunction(){}
}
PLATFORM::ANDROID
{
public function myFunction(){}
}
Learn more about compilation constants from Adobe documentation.