API Development

Add AMPLIFY Appcelerator Services to your Swift App

The following are the step-by-step instructions for how to install the AMPLIFY Appcelerator Services SDK for this native Swift (4) Xcode project. Once installed, use the appropriate key below to enable for Development or Production modes. Development is the mode during which you are doing development or during pre-production testing. You should only use the Production key when doing a release build to either the iTunes store or when you are releasing through Enterprise distribution. PS: if you are not using Xcode 7 or up. Really? Why not? Get the latest stuff!

Step 1 — Download and unzip the SDK (this will happen after you register your app for services)

Step 2 — Add the SDK to your Xcode project

Xcode 6 and later, drag the Appcelerator.framework folder into the root of your project, making sure Copy items into destination is checked, and click Finish.

Step 3 — Add Dependencies

On your project’s Build Phases tab, expand Link Binary With Libraries section and add the libsqlite3.tbd and libz.tbd frameworks.

Step 4 — Add Linker Flag

On your project’s Build Settings tab, click the All button in the top-left corner of the tab. Then expand the Linking section and add -ObjC to Other Linker Flags.

Step 5 — Disable Bitcode

For Xcode 7 and later, you need to disable bitcode since not all dependent third-party libraries have it enabled. In the Build Settings tab, expand the Build Options section and set Enable Bitcode to No.

Step 6 — Import Appcelerator.h using a bridging header
File > New > File > (iOS, watchOS, tvOS, or macOS) > Source > Header File. Name it [YOUR PROJECT NAME]-Bridging-Header.h and put it in your root directory [YOUR PROJECT NAME].

In Build Settings, in Swift Compiler – Code Generation, make sure the Objective-C Bridging Header build setting has a path to the bridging header file.

Now in the Bridge-Header file add
#import <Appcelerator/Appcelerator.h>

Step 7 – Initialize services

Select your deployment environment
Add the code below to your application delegate’s
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool method.

APSServiceManager.sharedInstance().enable(withAppKey:"[YOU APPLICATION KEY WILL BE HERE]")

Now you’re ready to start making service requests. See the Quick Start Guide for iOS APS SDK for making requests to the Cloud, Performance, and Analytics services.