Swift Foundation--Invoke the third party OC Project

Source: Internet
Author: User
First step: Create and configure Bridging-header.h

Swift is mixed with OC with an. h file, which uses bridging-header.h and then sets the project's build Settings--swift compiler--objective-c bridging The Header content is demoapp/bridging-header.h, which is related to the bridging-header.h position, starting at the root directory of the project Objective-c bridging The Header option writes the Bridging-header.h relative path.


Step two: Third party project Dependencies

To the third party project dependence, at first I intend to use cocoapods, but the process twists and turns, finally has been reported

[OBJC] View plain copy <span style= "FONT-SIZE:14PX;" >ld:218 duplicate symbols for architecture i386 Clang:error:linker command failed with exit code 1 (use-v to) Invocation) </span> I also have no way to copy the third party project source code into their own projects, the image can also see my copy of the Afnetworking project, and then add the source code to build Phases--compile Sources inside

Step Three: Modify Bridging-header.h

Write #import "AFNetworking.h" in Bridging-header.h step Fourth: Invoke OC

After the previous work is done, we can invoke the function of the third party project.

[objc]  View plain  copy  //  //  viewcontroller.swift  //   DemoApp  //  //  created by jiezhang on 14/10/24.   //  copyright  (c)  2014 year  jiezhang. all rights reserved.   //      import uikit      class viewcontroller:  UIViewController {           @IBOutlet  weak var  weatherInfo: UITextView!       override func viewdidload ()  {           super.viewdidload ()             updateweatherinfo ()        }           override func didreceivememorywarning ()  {             super.didreceivememorywarning ()           

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.