If you come here, it means that you have started to use the new language of Swift.
Just like Java has maven. OBJECTIVE-C also has its own dependency management tool, Cocoapods.
But because Swift came out soon, a lot of Cocoapods managed third-party libraries are still written by Objective-c.
In order to be able to use these class libraries in Swift. You need to do some configuration in Xcode.
If your project is based on Cocoapods, and is open by Xx.xcworkspace. (Xcode6 or more)
For demonstration purposes, if the imported third-party library is Mbprogresshud.
The following explains how to use this class library in Swift.
Step One: Create the header file (the header file is the bridge connecting OC to Swift)
In Project Navigator, right-click the project and select New File ... , IOS, Source, header file, after naming the file (headers are named arbitrarily, if bridging-header.h) is saved.
Step Two: Open the file, empty the contents, then import the class library you want and save it.
#import "MBProgressHUD.h"
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdg91bmfvynvu/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
Step Three:
Go to build Settings and enter BRIDG in the search box. Find the objective-c bridging Header. Options. Assign the path to the head file to this option. What you see:
Step Three:
Use the referenced code, for example, to add a display run progress box to the Viewdidload method:
Override Func Viewdidload () { super.viewdidload () //Do any additional setup after loading the view, typically fro M a nib. Just like a PCH. You do not need to import the header file mbprogresshud. showhudaddedto (Self.view, Animated:true)} on the top of the class library using this class library
Performance effects such as the following:
--------------------
-----
-----
It is important to note that. If not the class library introduced through Cocoapods. Instead of copying directly into the project (Build settings objective-c bridging header is not assigned, Xcode pops up such as the following dialog box:
After you select Yes. Under the root folder of the project, you will create a header file with the name Xxx-bridging-header.h (XXX is your module name), which is usually your product name.
In addition, the value of the OBJECTIVE-C header file in Build settings is also set as the path to the header files themselves.
What you see:
Just import the third-party class library you want in the header file that you are actively generating. You can use it anywhere in your project source files.
[Reference Using Swift with Cocoa and Objective-c]
Note: The above originates from the Xcode6 beta version number. The content is subject to change until the official release is finally released.
How to use Cocoapods imported third-party OC libraries in Swift