+

Search Tips   |   Advanced Search

Create a Swift project

Because Apple Swift is compatible with Objective-C, we can use the MobileFirst API from within an iOS Swift project.

  1. Create a Swift project and install the native API into an iOS native application as explained in Development guidelines for using native API.

  2. After you follow the steps for an iOS application, select Build Settings > Swift Compiler - Code Generation.

  3. In Objective-C Bridging Header, add this file: $SRCROOT/WorklightAPI/include/WLSwiftBridgingHeader.h.

    If we already have our own Bridging Header for other purposes, include the MobileFirst Bridging Header inside our own Bridging Header instead.


Results

All the MobileFirst classes are now available from any of the Swift files. The XCode IDE provides code autocompletion, converted to the Swift style.


What to do next

A tutorial is available on the Get Started page.


Parent topic: Develop native applications for iOS