You can add MobileFirst functionality
to your existing or new Xcode project with CocoaPods. Once your project
is set up, you can continue developing your code.
Before you begin
Note: MobileFirst development
is supported in Xcode from version 7.1 by
using iOS 8.0 and later.
You
must have
About this task
You can create a
IBM MobileFirst™ Platform Foundation
Xcode project by adding core frameworks and libraries with CocoaPods.
Addtional optional CocoaPods may be added.
Procedure
- Create an Xcode project if one does not exist.
- Open a command line in the Xcode project folder.
- Run the pod init command to create a Podfile file.
- Open the new Podfile file also at
the Xcode project root.
- Comment out or remove the entire existing content.
- Add the following lines including the iOS version and save
the changes:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, 9.0
target :name-of-the-target-in-xcode-project do
pod 'IBMMobileFirstPlatformFoundation'
end
- Optional: If you want to add any optional features,
add additional pods. For a list of available features see Table 1.
Add an additional line for each pod, for example:
pod 'IBMMobileFirstPlatformFoundationJSONStore'
Note: The previous syntax imports the latest version of the
IBMMobileFirstPlatformFoundation pod. If you are not using the latest version
of
MobileFirst, you
need to add the full version number, including the major, minor, and patch numbers. The patch number
is in the format
YYYYMMDDHH. For example, for importing the specific patch version
8.0.2016021411 of the
IBMMobileFirstPlatformFoundation pod the line would look
like
this:
pod 'IBMMobileFirstPlatformFoundation', '8.0.2016021411'
Or to get the last patch for the minor version number the syntax such
is
pod 'IBMMobileFirstPlatformFoundation', '~>8.0.0'
- Optional: If you are
developing for watchOS your Podfile must contain
sections corresponding to the main app and the watchOS extension:
#use the name of the app
xcodeproj 'MyWatchApp'
use_frameworks!
#use the name of the iOS target
target :MyWatchApp do
platform :ios, 9.0
pod 'IBMMobileFirstPlatformFoundation'
end
#use the name of the watch extension target
target :MyWatchApp WatchKit Extension do
platform :watchos, 2.0
pod 'IBMMobileFirstPlatformFoundation'
end
The
previous targets must match your main iOS app and watchOS extension:
The
main app section can contain any of the frameworks documented here: Table 1. However, only
the IBMMobileFirstPlatformFoundation pod is supported for the watchOS
extension. For more information on watchOS, see Developing for watchOS 2.
- Verify that the Xcode project is closed.
- Run the pod install command. This command
installs the IBMMobileFirstPlatformFoundation pod
and any other pods that are specified in the Podfile and
their dependencies. It then generates the pods project, and integrates
the client project with the MobileFirst SDK.
It also adds other required dependencies.
- Open your ProjectName.xcworkspace file
in Xcode by typing open [ProjectName].xcworkspace from
a command line. This file is in the same directory as
the [ProjectName].xcodeproj file.
- The main framework is imported like this:
Swift:
import IBMMobileFirstPlatformFoundation
Objective
C
#import <IBMMobileFirstPlatformFoundation/IBMMobileFirstPlatformFoundation.h>
- Beginning with iOS9 TLS must be enforced, see Enforcing TLS-secure connections in iOS apps.
Results
You can now start developing your native iOS application with
the
IBM
MobileFirst Platform Foundation
integration.
What to do next
Before you can access server resources, you must register
your app. See
Registering iOS applications from the MobileFirst Platform CLI.
For details about the
mfpclient.plist file see
iOS client properties file