Made With Marmalade: A seven step guide to using Marmalade Juice

Made With Marmalade: A seven step guide to using Marmalade Juice

By Marmalade

May 29th 2014 at 1:48PM

How to bring your Objective-C games to Android

Marmalade Juice is the latest service added to the Marmalade SDK, enabling devs to publish iOS apps on Android by adding the ‘clang’ compiler and support for core app APIs on top of the C++SDK. This enables native iOS Objective-C titles to deploy as native code on Android with no virtual machine, so the code runs fast.

So how does it actually work and what steps get you from Objective-C to Android?

1. Conversion Process
The initial conversion process takes your original iOS Xcode project, and generates a corresponding Marmalade MKB project configured to use the Juice libraries and toolchain. This is done through the SDK Hub, so open this, choose Juice and click Starter Tutorial. Click the ‘Convert XCode’ button, which gives you an Xcode Report. Then go to the Project details page.

2. Build your converted project
Next, open the project in your IDE via the Hub. This step uses the MKB project to create a Juice Xcode project ready for building, and then launches Xcode to open it. This project exists in parallel with your original iOS project, but shares the same source files. That means you can apply updates to both your iOS and Juice versions of your app at the same time.

The projects can share resource files too, but it’s common to have different versions for Juice builds, optimised to suit new platforms. Run the debug x86 build scheme for the Marmalade Simulator. Your game will now start to build and run in the Marmalade Simulator.

3. Fixing Errors
As this is the first pass attempt to get the core game up and running, comment out or provide stub functions for the time being to work around any errors. Return to them later to complete the conversion.

4. Simulator and Device Testing
When your app builds, try running it initially in the Marmalade simulator.

At this stage we’re focusing on getting the core app up and running, so skip any asserts and make necessary configuration changes. When you’re happy the core of your app is working, select the debug or release GCC ARM build schemes and build those. This will create an Android ARM build ready for deployment.

Return to your project’s page in the Hub. In the ‘Deployment panel’, set the desired deployment options, connect an Android device via USB then click on the green ‘Package/Install/Run’ button. This will package your app and install it.

5. Maintaining iOS compatibility
As the source is shared between the iOS and Juice versions, code changes should be conditionally compiled for the Juice build so it’s easier to switch between the two without duplicating the source.

To add platform-specific functionality, create this in separate modules that you can add to just the Juice project.

6. Completing conversion
Return to any code workarounds from the initial pass and address these. Add any platform-specific features, or configure platform-specific versions of features from your iOS project, such as in-app purchases. Test and tune your build on the device to achieve the performance you intend.

7. Submitting to store
Once you’re happy with the Juice version, you can proceed to store submission. Follow the guides to the Google and Amazon store submissions available in the Marmalade documentation.

Marmalade Juice is free in the Marmalade SDK. Check the website for licence details and special offers.

www.madewithmarmlade.com