How to Build Your Unity Game
If you're here, you've:
- Installed the Skillz SDK.
- Launched the Skillz UI.
- Set up either a Play and Compare or Realtime Sync core loop
- Used the Unity Companion to test your game's workflow with Skillz.
And are ready to test your Skillz integrated game on an actual mobile device. Follow the instructions below on how to build your game for iOS or Android.
Build Your Game For iOS
Set the Target iOS Version
Go to your iOS Player Settings -> Configuration
, and set the target minimum iOS version to 10.0 or higher.
Build to an Xcode Project
Go to File -> Build Settings
, select iOS then Build
. You should be prompted to locate where you saved the Skillz.framework
file.
Build from Unity Cloud
Alternatively, you can build your game from Unity Cloud. To do so, make an Assets/Plugins/iOS/
folder in your Unity project and add the Skillz.framework
file to it.
Set the App's Orientation
Open the Xcode project. In UnityAppController.mm
, find the function called application:supportedInterfaceOrientationsForWindow
. Currently, this method's body looks similar to:
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
if ([window rootViewController] == nil)
return UIInterfaceOrientationMaskAll;
return [[window rootViewController] supportedInterfaceOrientations] | _forceInterfaceOrientationMask;
}
Since Skillz doesn’t support switching orientations between portrait and landscape, you’ll need to modify this function to support only either portrait or landscape:
return (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown);
return (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
Disable Bitcode (If Needed)
If you are building on a device, you may run into an error about your game not supporting bitcode. Here’s an example error:
/Skillz.framework/Skillz
does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
In Unity 2019.2 or earlier, you can disable this by going to your target's Build Settings then setting Enable Bitcode
to 'No'
:
For Unity 2019.3, you will need to disable this for both the "Unity-iPhone" and "UnityFramework" targets:
You should now be able to build on a device via Xcode.
We’re always here to help. Contact us if you run into any issues.
Set Up Android Builds
The following steps are required before you build your game for the first time.
Regenerate Android Files
Make sure that Skillz emitted a few files in Assets/Plugins/Android/
.
In Unity 2019.2 or earlier, these will be:
- mainTemplate.gradle
- multidex-keep.txt
- proguard-user.txt
For Unity 2019.3 or later, these will be:
- baseProjectTemplate.gradle
- mainTemplate.gradle
- launcherTemplate.gradle
- multidex-keep.txt
- proguard-user.txt
If any of these files is missing, please:
- Select the
Skillz > Regenerate Android Files
menu item command. - A prompt may appear asking for permission to overwrite the files listed above. Select "Yes".
- Save your project, close it, and reopen it. This is because the Unity editor does not always refresh correctly.
- Verify that the files listed above are now present in
Assets/Plugins/Android/
before proceeding.
Important
The mainTemplate.gradle
that Skillz emits ensures that an exported Android Studio project will compile and run successfully (with Skillz). Other libraries, such as Firebase, may overwrite it. Make sure that it is the one that Skillz emits. If you're unsure, run the Skillz > Regenerate Android Files
menu item command.
The dependencies section should contain lines similar to:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
}
Configure External Dependency Manager
Skillz for Unity is bundled with the External Dependency Manager plugin. This plugin will resolve transitive dependencies between multiple libraries (that support it) for Android, such as Skillz and Firebase. However, preliminary configuration is needed:
- Select the
Assets > External Dependency Manager > Android Resolver > Settings
menu item. - Click the "Reset to Defaults" button as a precaution.
- Uncheck the "Enable Auto-Resolution" option.
- Make sure the "Patch mainTemplate.gradle" option is checked.
- By selecting this option, the External Dependency Manager will modify
Assets/Plugins/Android/mainTemplate.gradle
with the list of resolved of resolved dependencies. - The final
build.gradle
file in an exported Android Studio project will list these dependencies. - This approach is recommended by Google. Otherwise, the plugin will download the resolved dependencies as JARs/AARs.
- By selecting this option, the External Dependency Manager will modify
- Check the "Use Jetifier" option. Skillz requires the new AndroidX Support Libraries, instead of the original Android Support Libraries. Checking the Jetifier option ensures that all libraries that depend on the original Android Support Libraries are migrated to the equivalent AndroidX ones.
- Click the "OK" button to save your changes.
Help, the "Use Jetifier" Option Is Missing
If the "Use Jetifier" option is missing, it is possible that you installed another library that had an older version of the External Dependency Manager. You'll have to reinstall the copy that is bundled with the Skillz SDK:
- Delete the
Assets/ExternalDependencyManager
folder.- Reimport the Skillz SDK.
- From the import dialog, ensure the "ExternalDependencyManager" folder, and all its subfolders and files, are checked.
- Click the Import button.
Resolve Android Dependencies
With the External Dependency Manager configured, it's time to resolve your Unity project's Android dependencies. Select Assets > External Dependency Manager > Android Resolver > Resolve
. A message box will display after resolution has completed.
Afterwards, verify that mainTemplate.gradle
was modified to ensure that all resolved dependencies are listed.
The dependencies section should look similar to this snippet before modification:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
**DEPS**
}
And it should look similar to this snippet after modification:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
// Android Resolver Dependencies Start
implementation 'android.arch.lifecycle:extensions:1.1.1' // Assets/Skillz/Editor/SkillzDependencies.xml:109
implementation 'com.airbnb.android:lottie-react-native-skillz:2.6.2' // Assets/Skillz/Editor/SkillzDependencies.xml:29
// Etc., etc.
If the file did not appear to be changed, you may have to save your project, reopen it, and select the Assets > External Dependency Manager > Android Resolver > Force Resolve
menu item.
Build Your Game For Android
NOTE
The Skillz SDK does NOT support building an APK directly from Unity. Please export your project to Android Studio, as described in the section below, when you need to build an APK.
Change Android Build Settings to use ARM64
Navigate to your Android Player Settings via Edit > Project Settings > Player > Android Icon. Change "Scripting Backend" to IL2CPP
. Under "Target Architectures" check the box next to ARM64
.
Export to Android Studio
If you choose to export to Android Studio, make sure to click on Export Project
.
Then, in Android Studio, go to File > New > Import Project
and select the exported directory. Your Android studio project will contain a build.gradle
file that was generated from Assets/Plugins/Android/mainTemplate.gradle
of your Unity project.
For projects exported from Unity 2019.2 or earlier, this file will be at the project level. For projects exported from Unity 2019.3 or later, this file will be in the project's unityLibrary
module.
Perform any changes you wish to make in the (Android Studio) project and you should now be able to build and run your game on a device.
Build from Unity Cloud
Alternatively, you can build your game from Unity Cloud. No additional setup is required, but we recommend you first verify that an APK can be built directly from the Unity editor before attempting to build from Unity Cloud.
Contact us if you run into any issues.