Swift integrated third party QQ sharing error Summary

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.