In this second entry I am going to review all the neccesary steps to build the default LibGDX base project. The example will be running on two different platforms: Desktop (which is pretty much straightforward if you follow the wiki and iOS. Testing our project in our Apple phone devices… well, it can be a bit tricky, it is not hard, but you have to scrupulously follow some steps.

If you want to try the same project on Android devices there is enough documentation in the LibGDX wiki.

It is true that this entry breaks a little bit the flow on the video games developing series, but this is so important that I think is well worth leaving everything written down before moving on.

Prerequisites:

  1. IDEIntelliJ IDEA

  2. Hardware I am using → Macbook Pro retina mid 2014 and iPhone 5c.

  3. Apple Developer Account (free version) → In order to sign the app being created we need an Apple Developer Account. This account is free and will allow us to sign apps to be used in our devices, although we obviously can’t publish them in the App Store. If we also want do so, we mush adhere to the Apple Developer Program, which costs 100€ per year.

Step 1: Download LibGDX framework and create a new project.

Go to the LibGDX download page and run the jar. We fill up the available options as follows:

libgx-entry2-1

As you can see we are only generating Desktop and iOS projects.

BEWARE: Before finishing, go to “Advanced” and tick “IDEA” as we are going to use this IDE.

It is absolutely critical to pay attention at the “Package name” written because it will be decisive to run the app on iOS.

Step 2: Open the created project and run it in Desktop.

We open IntelliJ IDEA → Open→ Move to the path we created the base project and then select the *.ipr file.

libgx-entry2-2

Click on “Import Gradle” and we select all the possible options.

To run the Desktop project we have to create a “Run configuration”. We go to menu Run → Edit Configurations and the click to the “+” symbol to add an application. We have to fill everything like in the following picture: be careful with the working directory!

libgx-entry2-3

To run the demo now, simply click on the “Play” button or push ctrl-r and voalá:

libgx-entry2-4

Step 3: Let’s run the demo on iOS!

First things first, let’s download the 2.3.0 MoviDevelop Plugin for IDEA (the former RoboVM). You can find it in the official Movidevelop Web. To install the plugin follow the steps written there:

  1. Install Xcode on Mac OS X, open it once and agree to the license
  2. Download the RoboVM IntelliJ IDEA plugin Jar
  3. Open IntelliJ IDEA/Android Studio, go to Preferences -> Plugins
  4. Click Install plugin from disk…
  5. Select the Jar you downloaded and re-start IntelliJ IDEA/Android Studio

Now we create a XCode project with the exactly same package we used for our project. This is the only way we can sign our app:

  1. Open XCode.
  2. New XCode Project →Single View Application …

libgx-entry2-5

CAUTION –> The “Organization identifier” value has to be the same that “Package” we used in LibGDX. CAUTION –> The product name has to be: IOSLauncher.

We finish the creation; it doesn’t matter where we store the project. And then we change the Identity again to match out LibGDX Package:

libgx-entry2-6

CAUTION –> Xcode should automatically sign this app. Take into account that with the base developer account you can only sign 10 apps each 7 days (yes, thanks Apple).

To be really sure everything is as expected I will show you my robovm.properties file which is located inside the “ios” project:

 libgx-entry2-7

Finally we create a new “Run configuration”, but this time we select a RovoVM iOS configuration:

 libgx-entry2-8

And now when we click “Run” or “Ctrl-R” the Base project will be install in our device as a regular App. Lastly you have to accept your developer sign in your device in order to run the code.

To sum up

Creating a base project and make it run natively on iOS isn’t particularly difficult but we have to be careful. There aren’t many updated tutorials in this particular topic in the libGDX wiki or community, hence this entry.

Please post here if you need help. Don’t forget to follow me on twitter for more entries like this → @Musicaligera_