将Xcode项目注册到Bluemix

时间:2015-06-29 14:31:48

标签: ios xcode swift ibm-cloud devops

IMFClient.sharedInstance().initializeWithBackendRoute

每次我在Xcode 6中尝试这一行时,我都会收到此错误:

  

'使用未解析的标识符IMF客户端'

有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

You have to make sure you have imported the correct header files as well as configured the frameworks/Pods correctly. It seems you are using swift so I will add instructions below:

1) Make sure you have configured your pod file correctly. Below is a standard Pod file for using IMF services, but you only need to include the resources you need (IMFCore in your case above):

source 'https://github.com/CocoaPods/Specs.git'
# Copy the following list as is and remove the dependencies you do not need
pod 'IMFCore'
pod 'IMFGoogleAuthentication'
pod 'IMFFacebookAuthentication'
pod 'IMFURLProtocol'
pod 'IMFPush'
pod 'IMFData'

2) From terminal, go to your project folder and install the dependencies with the following command:

pod install

3) Now open the {AppName}.xcworkspace instead of the .xcproject. The .xcworkspace has all of the pods and decencies configured correctly after the pod install has been completed successfully.

4) In swift you need to add the correct import statements for your header files in the Bridging-Header.h. Again I will show you a standard Bridging-Header.h file when using the IMF services, but you only need to include the ones you require (at least IMFCore in your case):

#import <Foundation/Foundation.h>
#import <CDTDatastore/CloudantSync.h>
#import <CloudantToolkit/CloudantToolkit.h>
#import <IMFCore/IMFCore.h>
#import <IMFPush/IMFPush.h>
#import <facebookSDK/FacebookSDK.h>
#import "IMFFacebookAuthenticationHandler.h"
#import "IMFGoogleAuthenticationHandler.h"
#import <IMFData/IMFData.h>

Once you have installed and configured the dependencies correctly you should be able to register the client to the backend using the following:

IMFClient.sharedInstance().initializeWithBackendRoute(applicationRoute, backendGUID: applicationId)

Please Note: You will need to add your applicationRoute and applicationId to the above. These variables will be shown to you on the AMA dashboard when you registered the client.

If you want to see similar instructions when using Objective-C please see the following:

https://www.ng.bluemix.net/docs/starters/mobilefirst/gettingstarted/existingproject.html#createapp