Connect to a cloud deployment
Before reading this document, make sure you are familiar with:
- Setting up iOS Support for the GDK
- Ways to test your iOS client
- Development Authentication Flow
- Creating workers with WorkerConnector
To connect your mobile application to a cloud deployment, you need to authenticate against our services. This guide describes how to authenticate using the development authentication flow which we provide for early stages in development. Alternatively, if you want to create your own authentication server, follow this guide.
Connecting your iOS device or simulator to a cloud deployment
- Build your server-worker types.
- Upload your server-worker types. To do this, open a terminal window and from the root directory of your SpatialOS project, enter
spatial cloud upload <assembly name>.
- In the same directory, start your cloud deployment using
spatial cloud launch --snapshot=snapshots/default.snapshot my_assembly <launch configuration>.json <deployment name>.
- In the SpatialOS Console, tag your cloud deployment with the tag
To do this:
- From the SpatialOS Console, select your deployment name to display the project OVERVIEW screen.
- In the OVERVIEW screen, there’s a Tag field, add
dev_loginto the field.
- Create a Development Authentication Token (SpatialOS documentation).
- Create a MonoBehaviour script which inherits from the
MobileWorkerConnectorand includes the functionality you want. In your Unity Editor, add this script it to your Android client-worker GameObject.
DevelopmentAuthTokenfield. Still in your Unity Editor, make sure your Android client-worker GameObject is selected and in the Inspector, locate the script you just added to it.
- In the Inspector, in the script’s drop-down window, there is a field to add the authentication token that you created.
- In the same drop-down window, ensure that the checkbox
ShouldConnectLocallyis not checked.
- In the Unity Editor, navigate to SpatialOS > Build for cloud. Select your Android client-worker, and wait for the build to complete.
You know it’s complete when it says
Completed build for Cloud targetin your Unity Editor’s Console window.
- Select SpatialOS > Launch mobile client > Android Device.
- Go to your file manager and open the generated XCode project in the
- Code sign the project and build it - see the Building an XCode project using Unity section in the Unity documentation.
- Play the game on your iOS device or simulator.