Skip to Content

This is the first in a series of tutorials on Sybase Unwired Platform programming for iOS. The second tutorial can be found here:

http://scn.sap.com/community/developer-center/mobility-platform/blog/2013/01/03/sup101-ios6-client-part-2

Setting Up iOS Client in Xcode

As a pre-requisite of doing this tutorial is to have access to a Sybase Unwired Server. An easy way to set this up is to deploy it on AWS as an EC2 instance. The procedure to follow for this is found here: Get your own Sybase Unwired Platform server on … | SCN

More stuff on running SUP on AWS can be found here SAP for Mobile: Run the SUP 101 example in your… | SCN

To generate the mobile business objects iOS code for this tutorial, follow this procedure found here:

Sybase Unwired Platform 2.2 > Tutorial: iOS Object API Application Development 2.2 SP01 > Developing an iOS Application.

(Generating Object API Code)

Using the mobile business objects (MBOs) that was automatically generated by the Unwired WorkSpace tool, we will build a modern native iPhone app that contains all the new features in iOS 5 and 6.

To be able to build the App with Automatic Reference Counting (ARC), so we can utilize the automatic garbage collection in Objective-C 2.0, we need to first build the generated code as a static library. When we link the static library with the iOS project, we can call the methods in the generated code from our project and use ARC in our project.

Build the generated code as a static library

Create a new Xcode project, and select “Single View Application” template. Call the project SUP101, and be sure to check both “Use Storyboards” and “Use Automatic Reference Counting”.

/wp-content/uploads/2013/01/suptut1_171062.png

When the project have been opened in Xcode, click “Add Target” button under the “TARGETS” area in Xcode.

/wp-content/uploads/2013/01/suptut2_171063.png

Select “Cocoa Touch Static Library” from the “Framework & Library” template. Click Next.

Call the library “generatedcode_lib”, and make sure that the “Use Automatic Reference Counting” box is NOT checked. The generated code from the Unwired WorkSpace tool generates code without ARC, and to be able to compile the static library, we have to build it without ARC.

Click Finish.

Delete the generated code_lib.h and generated code_lib.m files from the generated code_lib group folder in the “Group & File” view in Xcode.

Find the “Generated Code” folder that was generated  by Unwired WorkSpace, and drop it in the SUP101 folder in Finder that Xcode generated.

Also copy in the same way the “includes” and “Libraries” folders from the iOS/RBS folder (from the MobileSDK/ObjectAPI/DOE).

Drag the Settings.bundle into Xcode (download here) with the “Copy items into destination group’s folder…” ticked, and SUP101 target ticked.

/wp-content/uploads/2013/01/suptut3_171064.png

From Finder, drag the “Generated Code” folder into Xcode “Group & File” window, and drop it inside the “generatedcode_lib”.

/wp-content/uploads/2013/01/suptut4_171071.png

Make sure that “generated code_lib” is the target you add the files to.

We need to modify the build setting for the static library, so the compiler can find the header files that the generated code references.

Select the generatedcode_lib target, and click on “Build Settings”. Scroll down to “Search Paths”, and add the includes folder to the “Header Search Paths”.

An easy way to do this is to drag from the Finder into Xcode “Header Search Paths” field.

Make sure to have recursive selected.

/wp-content/uploads/2013/01/suptut5_171072.png

Make sure that ARC is off in Build Settings for the static library target.

/wp-content/uploads/2013/01/suptut6_171073.png

Set the active scheme to generatedcode_lib and iOS Device, and build the static library.

XcodeScreenSnapz016.png

We now need to link the new static library with the main application target.

Click on SUP101 target, click “Build Phases”, and expand the “Link Binary With Libraries” button.

Drag libgeneratedcode_lib.a from “Products” group in Xcode into the expanded list field.

Add files to Main Target

Add the CallbackHandler.h and CallbackHandler.m files to the Xcode project by dragging them into the SUP101 group in Xcode. The files can be downloaded here.

As this class is a non-ARC class, the compiler has to be told to compile it without ARC enabled. Click on the main Target, Build Phases, and expand “Compile Sources” button.

Double-click the “Compiler Flags” column for the “Callbackhandler.m” row, and write “-fno-objc-arc” into the cell.

/wp-content/uploads/2013/01/suptut7_171074.png

Click on “Build Settings” for SUP101 target, and scroll down to “Search Paths” and double-click on “Header Search Paths”. Drag the “includes” folder from Finder (in the SUP101 folder) into the Xcode field.

Make sure to have the “recursive option” selected.

Double-click the “Library Search Paths” and drag the “Debug-iphoneos” folder from Finder (in the SUP101/Libraries folder) into the Xcode field.

Click on “Build Phases” and expand the “Link Binary With Libraries” switch and drag the 7 static files from “Debug-iphoneos” folder into the Xcode field.

/wp-content/uploads/2013/01/suptut8_171075.png

We have now made the groundwork for the project, and can now continue with making the GUI and connection to Sybase Unwired Platform server,

That will come in Part 2 of this tutorial.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply