Setup

To be able to start development using the Mobage Native SDK, you need to add the SDK libraries and header files into Xcode. 
In this chapter, we explain how to create a new project in Xcode, and how to import the Mobage Native SDK libraries.

Create a new project in Xcode

When you launch Xcode IDE, a welcome window is displayed (the upper image). Please select “Create a new Xcode project” to create a project. 

A project template selection window (the below image) is displayed. Please select a template you want to use.

In this chapter, we choose “Single View Application”. Click the “Next” button.

When you select a project template, a project configuration window (the below image) will be shown. You can specify Project Name, Organization Name, and Company Identifier in this windows. 
Please enter the project name and click on the “Next” button at the bottom right of the window.

A window to save the project files is display. Please select the folder to save the project, and then press the “Create” button at the bottom right of the window.

An Xcode IDE window is displayed. That completes the creation of a new Xcode project.

When you click the file ${PJNAME}/${PJNAME}AppDelegate.m in the left pane, the source code will be shown in the right pane as follows.

Importing Mobage Native SDK libraries

You need to add the Mobage Native SDK libraries into the new project, which you created. 
Please drag and drop the MobageSDK folder (iOS version) into the project tree in the Xcode window.


 

About F.O.X for Mobage

From Mobage Native SDK 1.4.7 we have included libmobage.a library without F.O.X for Mobage.
Follow the steps of "Importing Mobage Native SDK libraries" if you are going to use F.O.X for Mobage.
To implement your own F.O.X SDK and not F.O.X for Mobage, you need to link "SDKWithoutFOX/libmobage-withoutfox.a" and not libmobage.a.

  1. Delete the following lib if your removing F.O.X for Mobage
  2. Drag and drop SDKWithoutFOX/libmobage-withoutfox.a to MobageSDK folder.

Architecture Settings (From 1.4.7)

From Mobage Native SDK 1.4.7 you can set the following architectures ("TARGETS" -> "Build Settings" -> "Architectures" and "Valid Architectures").

  • 64 bit
    • "Standard Architectures (armv7, armv7s, arm64)" or "armv7, armv7s, arm64"
  • 32 bit
    • $(ARCHS_STANDARD_32_BIT)

      • The libmobage.a contains 64-bit architecture from Mobage Native SDK 14.7. Therefor the above settings are needed.
      • When supporting 64-bit, please make sure the Deployment Target is set to iOS 5.1.1 or higher.

Architecture Settings (1.4.6.7 and before)

Set the following architecture ("TARGETS" -> "Build Settings" -> "Architectures" and "Valid Architectures") for Mobage Native SDK 1.4.6.7 or before

  • $(ARCHS_STANDARD_32_BIT)


Link iOS SDK frameworks

Since Mobage Native SDK uses libz.dylib and StoreKit.framework, Security.framework, AdSupport.framework, SystemConfiguration.framework(1.4.4 or later) internally, you are required to import these libraries.


 
Please perform the following processes.
1.Click on the Project icon.
2.Select the target you want to build.
3.Select “BuildPhases” -> “Link Binary With Libraries”
4.Select libz.dylib, StoreKit.framework, Security.framework, AdSupport.framework, SystemConfiguration.framework(1.4.4 or later)
5.After adding AdSupport.framework, you need to change drop down menu "Required" into "Optional". This is for supporting iOS4 and 5 before iOS6.

Configure Linker flag

Since the Mobage Native SDK contains Category implementations in the static library, you need to set “-ObjC” option in the linker flags in order to link the category implementations.
Please perform the following processes:

1.Select the project to build
2.Open the menu “Build Settings”, and select “All” (not Basic)
3.Select “Linking” -> “Other Linker Flags” and add the option “-ObjC”

How to create a new project in Xcode 4.5 or later.

When you create a new project in Xcode 4.5 or a later version, libc++ is selected as the C++ Standard Library by default.
Thus,it results in a build error in Mobage SDKs which use libstdc++ in the C++ Standard Library. To avoid this, perform the following:
libraries when developing an application with support, using Mobage Native SDK 1.3.1 or later in the import procedure. As before, drag and folder (iOS version) on to Xcode.

There's no need to change the C++ Standard Library from Mobage Native SDK 1.4.6.
There's no need to change the AppDelegate.m from Mobage Native SDK 1.4.6.
  • When you create a new project, change the C++ Standard Library from libc++ (LLVM C++ standard library with C++11 support) to libstdc+ (GNU C+ standard library).
  • As described in "Login process", change AppDelegate.m to AppDelegete.mm.

Adding "com.mobage.shared" on Keychain Groups

Go to "TARGETS" -> "Capabilities" -> "Keychain Sharing", then turn the setting "ON" and add "com.mobage.shared" to the "Keychain Groups".

Notice that without adding this to your "Keychain Groups" you wont be able to connect to Mobage platform

  • Incase you want to modify the info.plist manually, add "$(AppIdentifierPrefix).com.mobage.shared" to the "keychain-access-groups".

Important points when you import Mobage SDK in Xcode 4.5 or later

In Xcode 4.5 or later, when you create a new project Xcode automatically creates Default.png, Default@2x.png and Default-568h@2x.png and adds them to the target.

Therefore, when you drag and drop the whole MobageSDK folder to add it to the target, two files with a same name exist in the target,
and it results in the error “While reading ... Default.png pngcrush caught libpng error:".

Be sure to remove the automatically created Default.png, Default@2x.png, and Default-568h@2x.png from the target.


Update History

  • 08/09/2014
    • Updated for Mobage Native SDK 1.4.7
  • 09/05/2013
    • Added mention of SystemConfiguration.framework.
  • 04/18/2013
    • Added guideline for Apple's new regulation
  • 11/01/2012
    • Added procedure for creating a new project in Xcode 4.5 or later.
  • 09/19/2012
    • Add the descriptions about the new library import procedure for iPhone5
  • 08/08/2012
    • Initial Release.

PREVIOUS

Contents

NEXT

How to build in Xcode7