Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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-p...

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".

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

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.

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

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.

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

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

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.

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.

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.

3 Comments
Labels in this area