Now the iOS program is developed, basically using Swift to write code. However, many third-party libraries are built by OC, so when you integrate a third-party SDK, you will encounter some problems. The following is my integration QQ share encountered the problem summary.
The environment of IOS_SDK is described here in detail. Because of the upgrade of the Xcode version. Configuration is still a little different.
1. In the "Build Settings" column of the project configuration, locate the "linking" configuration area and add the property value "-fobjc-arc" to the "other Linker Flags" configuration item. This is the previous version of Xcode.
Xcode6 is the case.
2. There is no frameworks folder in the new Swift project. So we create a new folder frameworks.
3. Add the following header file in XXX (your project name)-bridging-header.h. The path must be right, otherwise there is no effect. I made a path error as soon as I opened it. So swift can easily invoke the QQ interface.
//TencentOpenapi#import <TencentOpenAPI/TencentOAuth.h>#import <TencentOpenAPI/QQApiInterface.h>#import <TencentOpenAPI/QQApiInterfaceObject.h>#import <TencentOpenAPI/sdkdef.h>#import <TencentOpenAPI/TencentMessageObject.h>#import <TencentOpenAPI/TencentOAuthObject.h>#import <TencentOpenAPI/WeiBoAPI.h>#import <TencentOpenAPI/WeiyunAPI.h>
4, rewrite the Appdelegate.swift two methods, write with Swift.
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { return TencentOAuth.HandleOpenURL(url) } func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool { return TencentOAuth.HandleOpenURL(url) }
5. Test and share the code.
let title = deal["title"] as! String let previewImageUrl = deal["image"] as! String var newObj = QQApiNewsObject(URL: NSURL(string:"http://www.baidu.com")!, title: title, description: title, previewImageURL: NSURL(string: previewImageUrl)!, targetContentType:QQApiURLTargetTypeNews) var req = SendMessageToQQReq(content: newObj) QQApiInterface.sendReq(req)
Basically third-party invocation methods are similar. For beginners, still a bit of a role.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Swift integrated third party QQ sharing error Summary