How to build for iOS and publish to Apple App Store

I thought I’d post some information I have manged to put together regarding building your Jmonkey project on iOS.

There are a couple of updates required to the standard XCODE project generated by the system in order to build correctly.

  1. After creating a BASIC GAME JME project then Add the iOS library. (jme3-ios)
    image

  2. In Project properties - Enable iOS deployment and make sure the iOS SDK Version is showing a number (Not Default). If there is no number present then you need to install XCODE.
    In this example, my SDK version is 11.3 and I’m using XCODE version 9.3
    When you press OK after enabling iOS deployment then if it’s not already installed then AVIAN will download and install. This is shown in the bottom status bar of the JME editor. Wait until this is finished before doing anything else.
    image

  3. Compile your project.
    If it’s missing stdio.h you need to install the xcode command line tools
    run this command in terminal
    xcode-select --install

  4. When it’s compiled successfully then load the XCODE PROJECT into XCODE which is located in the IOS/PROJECT folder. As mentioned above, my SDK version is 11.3 and I’m using XCODE version 9.3

  5. First change the selected TARGET at the top of the screen from iPhone 7 Plus to Generic iOS Device. This is so we can do a full build. If you want to run it in a simulator then you can change it back later.
    image

  6. From the PROJECT menu click BUILD and the build will fail. If you click the ISSUE NAVIGATOR button to show the compilation errors.
    image

  7. We can see here that the Developer account is missing, the project settings are out of date and there is a missing image for Retina 4-inch support.

  8. Click Validate Project Settings to and click PERFORM CHANGES to accept all the suggested amendments.
    image

  9. Click on the Missing Image warning and XCODE will automatically add a placeholder for you.
    image

  10. Add you iOS developer account details by clicking on the target and then the Account Drop down.
    image

  11. Now click PROJECT menu and BUILD again and it should compile now but fails at the linking stage.
    image

  12. We need to amend the linker search paths.
    12a) Click on PROJECT NAVIGATOR
    12b) Highlight the top row (JME-IOS)
    12c) Click jme-ios under PROJECT (Not TARGETS)
    12d) If you have done it correct then you will only see INFO & BUILD SETTINGS at the top.
    12e) select BUILD SETTINGS
    12f) Scroll down to LINKING section
    image

12g) Double click on OTHER LINKER FLAGS
image

12h) Double click on the line referencing i386 and change it from:
…/…/build/ios-i386/libs.list
to
…/…/build/ios-x86_64/libs.list

12i) Add the additonal flag for ARM64 sub type issue introduced in iOS SDK 11.
With nothing selected click on the + sign and a new entry will be added at the bottom.
In here add
-force_cpusubtype_ALL

Your other linker flags should now look like this…
image

  1. Disable BITCODE
    13a) Click on PROJECT NAVIGATOR
    13b) Highlight the top row (JME-IOS)
    13c) Click jme-ios under TARGETS (Not PROJECT)
    13d) If you have done it correct then you will see General/Capabilities/Resource Tags/Info/Build Settings/Build Phases/Build Rules at the top.
    13e) select BUILD SETTINGS
    13f) Scroll down to BUILD OPTIONS section and change ENABLE BITCODE to NO
    image

  2. From the PROJECT menu click BUILD and the project should build and link fully.

  3. To publish to the APP STORE you select PROJECT MENU and ARCHIVE.
    This will generate the App Store Archive and show in the organizer screen.

  4. Click Upload to APP Store and away you go.

I’ve shared the final (fixed) BASIC GAME project which includes the XCODE project on this link for your reference which just needs an iOS developer account adding and should compile and link fine.

Basic Game 11 Project - Fixed for IOS 11 and XCODE 9

There are couple of things I’ve not included such as setting up a bundle identifier , an iOS developer account, an App in iTunes Connect store, signing certificates, provisioning profiles but Apple have many much better documents about this that I could provide. I will help out if I can though.

If I’ve missed anything else or you need any further help let me know.

Check out my cross platform JME app on App Store, Play Store and Windows/Linux/OSX,

Chatter Games - Google Play Store

Chatter Games - Apple App Store

Chatter Games - Official Site (With Links for Windows/Linux/OSX)

Thanks
Anthony.

17 Likes

Wow, thanks!

I haven’t done anything with JME and iOS so I can’t approve the correctness but this should definitely go into the Wiki.

Yeah, maybe @mitm could work with you to get it into the wiki.
I’m actually also thinking about just updating the default project the SDK generates so that steps 7-13 aren’t required anymore, but I am not sure if I can simply change it that way.
But on the other hand: Why not?

I will add it but not for a few more weeks.

I cant verify the accuracy so it will be written as is until someone finds problems with it.

I agree it would be better to change the standard project because they are standard changes that apply for all instances.

I do have some other observations about iOS that you may want to include such as:

  1. Problems with serializing in networking module which I had to tweak to get working fully cross platform,
  2. Sound problems since SDK 3.2. I never managed to fix that so I had to include some native iOS code for sound effects.
  3. Network initialization has to be called twice for it work.
  4. Several pro-guard exceptions needed to be added too which could be added to the standard ios.properties file.

Also, I managed to get Bullet Physics to work by compiling the bullet sources into the XCODE project. However, I did have to make some tweaks to it, to get it working.

I can help test the standard project if you like when the changes are made. Let me know.

1 Like

Actually you’d just need to PR this: sdk/jme3-ios/ios-data/templates at master · jMonkeyEngine/sdk · GitHub
As you can see (regarding to 4.) I also started adding some exceptions to proguard, but without being able to test it, I can only add what has been requested so far.

  1. and 3. could be solved by altering jme code depending on the issue, so it might be good to talk to @pspeed about what was needed in detail

  2. Might be worth an issue on the engine repo as well (also see https://github.com/jMonkeyEngine/sdk/blob/master/jme3-ios/ios-data/templates/src/com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.c)

In theory for bullet you’d need jBullet, so it’s awesome that you find a way around it regarding that we wanted to drop it! :slight_smile:

1 Like

Yesterday I managed to port my two iOS apps to jME 3.2.4. I also noticed that the sound support was broken, but I was able to fix it. :grinning:

I just copied and adapted the Android files:
https://github.com/revvv/sdk/tree/ios-openal-fix/jme3-ios/ios-data/templates/src

I think this zip contains outdated templates and is not used any longer?

Let me know if should make a PR.

I also have iOS fixes for the touch events which appear at a wrong location and some excludes for ProGuard.

4 Likes

Wow, @revv . Well done.
This is a big achievement.

1 Like

Sorry for the late reply :slight_smile:
Only a few brave monkeys deploy to iOS :stuck_out_tongue:
The zip file could very well be outdated but I need some time to look into it again.

1 Like

Technology - No place for wimps :nerd_face:

If I only knew that before… :wink:

I already submitted my first PR. Three more to come…

1 Like

Curious why iOS stuff is in the SDK repo instead of being in the engine?

If you enable iOS in your netbeans project, these Objective C source files are copied into a freshly created subfolder.
They will get compiled by netbeans (“ant jar”) through Avian or by Xcode.

I think the reason is that there are no binaries shipped with jME.
Probably because you would need to ship all architectures (ARM, ARM64, X86_64 and more to come).

Forgot about this so added it.

https://wiki.jmonkeyengine.org/jme3.html#deployment

I f anything needs changing let me know as I wrote this by guessing.

2 Likes

Turns out there was already a page explaining most of this in the sdk.

https://wiki.jmonkeyengine.org/jme3/ios.html

I am removing the page I wrote because I merged it with the existing one. If people who use this find errors let me know. This is just me guessing its right.

2 Likes

Thanks a lot. I know this was a lot of work. (And I really liked that “alpha” was removed… ok, now it’s back again…)

As soon as my PR is available in the next release, I’ll revise the instructions. Hopefully we can finally drop “alpha” :wink: