如何在Swift项目中导入LinkedIn SDK?

我需要将LinkedIn SDK添加到我的Swift项目中。 我已经下载了他们的最新版本(1.0.4),将SDK文件拖放到XCode中(“复制项目如果需要”和“添加到目标”选中)。 我可以在我的目标的“链接框架和库”部分看到框架。

我卡住,但是当我需要在一个swift文件中导入标题。 LinkedIn文档中有一个Objective C示例:

#import <linkedin-sdk/LISDK.h> 

但是你如何在Swift中做到这一点? 我尝试了不同的名字,但他们都提出了一个错误。

 import LinkedIn import LISDK 

“import linkedin-sdk”由于破折号( – )而失败。

我已经在我的项目中导入了外部框架(例如Parse),它完美的工作。

谢谢您的帮助!

编辑我不再使用LinkedIn API,因为他们已经停止分享有用的信息。 无论如何,这是一个旧的代码示例:

 var accessToken: LISDKAccessToken? func loadAccount(then: (() -> Void)?, or: ((String) -> Void)?) { // then & or are handling closures if let token = accessToken { LISDKSessionManager.createSessionWithAccessToken(token) if LISDKSessionManager.hasValidSession() { LISDKAPIHelper.sharedInstance().getRequest("https://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,headline,location,industry,current-share,num-connections,num-connections-capped,summary,specialties,positions,picture-url,picture-urls::(original))?format=json", success: { response in print(response.data) then?() }, error: { error in print(error) or?("error") } ) } } else { LISDKSessionManager.createSessionWithAuth([LISDK_BASIC_PROFILE_PERMISSION], state: nil, showGoToAppStoreDialog: true, successBlock: { (state) in self.accessToken = LISDKSessionManager.sharedInstance().session.accessToken if LISDKSessionManager.hasValidSession() { LISDKAPIHelper.sharedInstance().getRequest("https://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,headline,location,industry,current-share,num-connections,num-connections-capped,summary,specialties,positions,picture-url,picture-urls::(original))?format=json", success: { response in print(response.data) then?() }, error: { error in print(error) or?("error") } ) } }, errorBlock: { (error) in switch error.code { default: if let errorUserInfo = error.userInfo["error"] as? NSString { or?(errorUserInfo as String) } else { or?(UIError.Code.Unknown) } } } ) } } 

男人,你应该有一个桥头 。 我看起来很简单:

 // Copyright © 2015 Arthur Gevorkyan. All rights reserved. // #ifndef BridgingHeader_h #define BridgingHeader_h #import <Foundation/Foundation.h> #import <linkedin-sdk/LISDK.h> #endif /* BridgingHeader_h */