iOS 9 introduces some changes to the way that apps integrate with Facebook. A preview release of the Facebook SDK for Unity has been prepared for testing with iOS 9 and is available on our iOS 9 documentation.
Note: This guide is organized to follow after the shared setup steps for the Facebook SDK for Unity detailed in the Getting Stared guide. If you have not yet completed these steps please do so first.
This document provides an follow up step-by-step guide to get started with the Facebook SDK for Unity on iOS. We will build and deploy the sample Unity app bundled with the Unity SDK to allow you to get working on a Facebook integration quickly and effectively. If you're more comfortable working on Android or Web, you can switch to the Getting Started guides for those platforms.
Step 1: Switch to the iOS Platform
Go to the Unity Editor. From the menu, choose 'File', 'Build Settings…' In the Build Settings dialog, under 'Platform', select 'iOS' as the target and click 'Switch Platform'. Ensure the sample project scenes have been added to the 'Scenes in Build' as previously described here.
Step 2: Set minimum iOS Version
The Facebook SDK for Unity only supports iOS version 7.0 and above. In order to prevent issues any issues on older devices, ensure the 'Target minimum iOS Version' is set to
7.0 or higher.
Step 3: Configure Bundle ID
With the Build Settings dialog still open, click 'Player Settings...' Then, in the Inspector pane go to 'Settings for iOS', then 'Other Settings'. Fill in the 'Bundle Identifier' field with a valid bundle identifier, usually formed using your company name and product name.
Whatever value you put there, you'll need to configure the same value in your app's Facebook settings. Go to the 'iOS' pane in the Basic tab of your app's 'Settings' page, and fill in the 'Bundle ID' field.
Step 4: Build
Now, back in the Unity Editor, click the 'Build' button. When prompted for an output directory name, call it
unity_ios. Once Unity finishes building, open the file
Unity-iPhone.xcodeproj in the directory that was created with Xcode.
You can hit the 'Play' button in Xcode to run the app in your default target (by default, the simulator), or use Xcode's usual functionality to run it on real iOS devices.
Now you're up and running on iOS. Congratulations!
Feel free to explore the sample app to try out the various features of the SDK. Start by clicking the FB.Init button at the top of the sample, which will enable the other features of the sample. As a next step, modify the code included in the sample and add it to your game project; this will get your Facebook integration off to a flying start.
For more details on integrating the Facebook SDK into your Unity game, check out the SDK reference and SDK Examples. And if you'd like to see how easy it is to deploy to Facebook Canvas and Android, check out their respective Getting Started guides.