GameMaker Studio 2 Mobile comes with two export platforms: iOS and Android. In this article we give the required steps to get the iOS platform up and running. Note that we assume you already have an Apple Developer Account.
NOTE: If you are new to iOS development and/or do not have a Developer Account with Apple, then the following link will take you to a tutorial that explains everything related to getting your developer licence and creating certifcates etc... https://www.raywenderlich.com/127936/submit-an-app-part-1
To target iOS from the IDE, you use the Target Manager, which is located in the top-right of the main GameMaker Studio 2 workspace:
For the iOS target platform you can see that there are two output options:
- VM - This will build your game using interpreted code.
- YYC - This will build you game using compiled native code.
The VM option will build your game and use interpreted code within a special YoYo Runner. The performance of this target is less optimised than YYC, but it is faster to compile and offers the ability to run in debug mode (when using YYC the debugger will not start). The YYC target however, gives a much greater optimisation (and corresponding performance boost) especially with logic-heavy games, but large projects can take some time to compile.
To compile your game using either the VM or YYC however, you will first need to set up your Devices so that GameMaker Studio 2 can communicate with your Mac machine and transfer files to build for iOS.
NOTE: GameMaker Studio 2 requires a physical Mac computer to be able to test or compile your iOS projects, and although you can run macOS in a virtual machine, this is not supported and you should own a mac computer (and preferably) an iOS device before targeting iOS with your games.
This article is targeted at users with the latest OS version for Mac, macOS Sierra. However, if you are using an older version of macOS (GameMaker Studio 2 supports from El Capitan onwards) then you may still be able to test and compile your games, but some steps may be slightly different and you will only be able to test on iOS versions that are compatible with the version of XCode that works with the macOS being used. We recommend that you have the latest macOS and the latest Xcode to build games for iOS.
Before going any further, you will first need to download and install Xcode which is what GameMaker Studio 2 will use to build your projects. You can get the latest copy of Xcode here: https://developer.apple.com/xcode/
Once you have downloaded and installed Xcode, you need to link it with your Apple Developer account so that it can use the required certificates to build your projects. For that you need to follow these steps:
- Go to Xcode > Preferences.
- At the top of the window, click the Accounts button.
- In the lower-left corner, click the Add button (+) .
- Choose Add Apple ID from the pop-up menu.
In the dialog that appears, enter your Apple Developer ID and password, and click Sign In. You difefrent certificates will now be retrieved and you should verify that they are visible to Xcode by going to Xcode > Preferences > Accounts. Here you select the Apple ID to look at and then on the right of the window click the Team Name and then the button Show Details. This should show all the different signing identity certificates that you have:
You can close these windows now, as you are almost ready to start building projects for iOS, however we still need to set up GameMaker Studio 2.
Setup GameMaker Studio 2 Devices
Back to your GameMaker Studio 2 machine, and in the Targets Window you can see that there is a section marked Devices with a small "pencil" icon beside it:
Clicking this will open up the Device Manager where you will need to first add your macOS machine and then your iOS devices, since GameMaker Studio 2 needs to communicate with the Mac first to get the devices available.
Set Up Your macOS Machine
So, in the Device Manager you should select the macOS platform and then click the Add New Device button to create a new Device and fill out the details (below you can see an example of what information is expected):
The top field, Display Name is simply a name that you can give to the device so that it is easy to identify in the devices list. After filling that out you need to give the Host Name - the IP address or Device Name of the Mac machine on the network that is to host the game - and the User Name and Password of the Mac user account that will be used for testing/creating your game. Finally, supply the Install Folder destination on the Mac system where the GameMaker Studio 2 files should be stored (default should be fine but you can change if required).
NOTE: To get the IP address of the Mac system you simply have to go to System Preferences then click on the Network icon and you can see the IP address there. If you wish to use an actual name to address the Mac, then this will require you to enable the option on the Mac as part of the network connection settings.
With that done you can then click the Test Connection button, and if you have installed all the required packages and the maxOS machine is visible over the network then it should say "Connection Successful!":
Setup Your iOS Devices
Still in the Device Manager, you now need to select the iOS platform from the list on the left. Here you can configure the iOS devices that can be targeted when testing your game project. Before continuing, you should ensure that any iOS devices you own are connected via cable to your Mac machine so that they can be correctly discovered.
The Device Manager for iOS shows two initial preferences, with the first permitting you to select from the macOS machines that have been added in the previous step (you can add more than one Mac to the device list and switch targets from here), and the second option is to Detect Devices. Clicking this will automatically populate the Device Manager with all the available devices from the target Mac:
Once your devices have been discovered, they will be listed and you can choose to rename the display name of each device (this will only affect what is shown in the target manager). Note that not only will any physical devices be detected, but the different simulator devices in Xcode will also be listed, and you can target them like you can any physical device. Note though that when targeting a simulated device, you need to launch the simulator first from the Device Manager before testing your project.
GameMaker Studio 2 Preferences for iOS
With the devices now setup, you need to open the GameMaker Studio 2 Preferences (from the File menu at the top of the IDE) and under Platform Settings > iOS you need to specify the general Team Identifier, and the macOS Install Path (default should be fine but you can change if required):
NOTE: You can find your Team ID from the "Membership" section of your Apple Developer Account.
The other option you have here is to Suppress build and run. It's very important that this is enabled the first time you try to test a project on an iOS device. We will explain why in the next section of this article, but for now, make sure that it is checked too.
Test Your Project
You are now ready to test your project. Regardless of whether you are using the VM or YYC output, you can simply click the "Play" button at the top of the IDE and the game will build and then be sent to your macOS machine. If this is the first time you are testing your project then you should have enabled "Suppress build and run" in the iOS Preferences (see above), so this initial test will simply send the game files over to Xcode, but will not run the game on the target iOS device. This is because the project requires a Provisioning Profile, which you need to generate in Xcode.
In Xcode on your development Mac your project should open and the initial page look something like the image above. You can see that there are issues with the signing (flagged in the "Status" section), and we need to fix them by changing the Bundle Identifier. This identifier needs to be unique for the project so you should change that until the status warnings go away and Xcode creates a provisioning profile, as shown here:
If all has gone correctly your project should now run when you click the Xcode "play" button. You can now go back to GameMaker Studio and uncheck the "Suppress build and run" option in the preferences, as the project has a correct bundle ID and should be able to run directly from GameMaker Studio 2 when you click the "Play" button in the GMS2 IDE.
Note that you can also test play your game using the "Debug" option at the top of the IDE. When clicked using the VM output it will run the game and enable the Debug Module to run too (this may require some extra permissions from the OS). This module permits you to see in detail how your game is performing as well as set breakpoints and check for issues or bugs. For more information, see the manual.
When you are ready to publish your iOS app, you will want to compile a final executable package. This is explained in the following article: