Before you can integrate the Skillz SDK into your game, you must first properly add it to your Xcode project. For this and all future articles, we require the use of Unity 2017, and Xcode 9.
Step 1: Add the Skillz SDK to your Unity project
With your Unity project already open, double-click the file skillz_ios.unitypackage inside the Unity folder in the downloaded SDK. In the window that pops up, click All to make sure all files are selected, then click Import to import the files into your project. A folder named Skillz should now exist in the project.
Make sure the Unity project still compiles with the SDK added.
Step 2: Set the Target iOS Version
Ensure that the Unity project is set to the correct target iOS version. This can be set by going to File -> Build Settings -> iOS -> Player Settings and changing the Target iOS Version under the mobile section. Skillz requires iOS 9.0 or higher.
Step 3: Build Unity
Now, just build your game like any other project, and Skillz will do some work behind the scenes to set up the XCode project to use our SDK.
If doing a build from scratch, you should see two popups at the end of the build process:
- A prompt for the orientation your game uses.
- A folder selection dialog for locating the Skillz.Framework file that came with the SDK download.
Step 4: Add Required Linker Flags
Skillz requires five linker flags which must be set in your Xcode project. The required linker flags are:
-ObjC -lc++ -lz -lsqlite3 -lxml2 -weak_framework PassKit
To set these flags, go to your project target in Xcode. In the Linking section in Build Settings, specify any missing flags in theOther Linker Flags setting.
If any of these flags are missing, you may encounter linking errors when trying to compile your game with the Skillz framework or a runtime crash.
Step 5: Check Code Sign on Copy in Embed Frameworks
Go to your project's target > Build Phases > Embed Frameworks, make sure that Code Sign on On Copy is checked for Skillz.framework.
Step 6: Modify supportedInterfaceOrientationsForWindow in UnityAppController.mm
In UnityAppController.mm, find the function supportedInterfaceOrientationsForWindow. Currently this method is returning the following:
return (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
Since Skillz doesn’t support switching orientations between portrait and landscape, you’ll need to modify this function to either portrait only or landscape only.
return (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown);
return (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
After completing these steps, the Skillz SDK should be properly included in your project and you should be able to compile your game without errors.
The next step is to perform the actual integration!