Monday, November 14, 2016

IBM MobileFirst Platform 8.0 - Developing Applications (Adding the MobileFirst SDK to iOS Applications)


The MobileFirst Foundation SDK consists of a collection of pods that are available through CocoaPods and which you can add to your Xcode project:
  • IBMMobileFirstPlatformFoundation - Implements client-to-server connectivity, handles authentication and security aspects, resource requests, and other required core functions
  • IBMMobileFirstPlatformFoundationJSONStore - Contains the JSONStore framework
  • IBMMobileFirstPlatformFoundationPush - Contains the push notification framework
  • IBMMobileFirstPlatformFoundationWatchOS - Contains support for Apple WatchOS
Prerequisites:
  • Xcode and MobileFirst CLI installed on the developer workstation
  • A local or remote instance of MobileFirst Server is running
  • Support level
    • Xcode 7.1 and later
    • iOS 8 and later
Procedure:
1. Create an Xcode project or use an existing one (Swift or Objective-C). For example I have chosen Swift.
Note: Swift is a new programming language for iOS, macOS, watchOS, and tvOS apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works. 




2. If CocoaPods is already installed in your development environment, skip to step 3.
Open a Command-line window and navigate to the root of the Xcode project and run:
Note: "pod setup" command might take several minutes to complete. Use a git process.

$ sudo gem install cocoapod
$ pod setup
Setting up CocoaPods master repo
Setup completed

3. This creates a Podfile
$ pod init

4. Edit the Podfile.
Comment out or delete the contents of the file.
Add the following lines and save the changes:

use_frameworks!

platform :ios, 8.0
target "MyHelloiOS" do
    pod 'IBMMobileFirstPlatformFoundation'
end

5. Back in the command-line window, run the commands. These command add the MobileFirst Native SDK files, add the mfpclient.plist file, and generate a Pod project.
Note: The commands might take several minutes to complete.

$ pod install
Analyzing dependencies
Downloading dependencies
Installing IBMMobileFirstPlatformFoundation (8.0.2016070718)

[!] Please close any current Xcode sessions and use `MyHelloiOS.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

$ pod update
Update all pods
Updating local specs repositories

CocoaPods 1.2.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.0.beta.1

Analyzing dependencies
Downloading dependencies
Using IBMMobileFirstPlatformFoundation (8.0.2016070718)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

6. Close Xcode and open Xcode MyHelloiOS.xcworkspace file


7. Registering the application to MobileFirst Server, go to project folder and run:
$ mfpdev app register 
Verifying server configuration...
Registering to server:'http://####.####.####.####:9080' runtime:'mfp'
? Enter your bundleId: jif.examples.helloios
To prevent future prompting for the bundle ID in iOS projects, update the '<string>' element that corresponds to the '<key>CFBundleIdentifier</key>' in your Info.plist file.
Registered app for platform: ios

8. In Xcode, right-click the project entry, click on Add Files To [ProjectName] and select the mfpclient.plist file, located at the root of the Xcode project.




 Cheers!!!

No comments:

Post a Comment