Swift: Bridging OC Files in Swift (class files you create, third-party library files)

Source: Internet
Author: User

First, Introduction

As Swift matures, the use of swift development or hybrid development has become a trend, and Apple is recommending the use of Swift as a new language. Swift has now been updated to 3.0, and it is estimated that no more than 4.0 will come out. Then there are some unavoidable problems when developing with Swift, and the following are some common problems to solve.

ii. Problems and Solutions
    • How do I manually bridge oc in Swift?

1. Create a swift bridging file

2. Set the path of the bridge file, that is, the path of the objective-c bridging header, you can import the custom OC class file after Setup, using the

    • How do I use Cocoapods to integrate third-party libraries?

The swift language is added use_framework! when configuring Podfile files with Cocoapods. The purpose of this code is to package the three-party library into a static library for developers to use.

    • How do I import a third-party library that uses Cocoapods integration? Here I use Mjrefresh example

1, #import "MJREFRESH.H" after you want to set up a user Header Search Paths, otherwise you need to use a three-party library is not adjustable.

Locate the search Paths in the Target->build setting, and double-click the empty space behind the user Header Search Paths to set the directory path to ${srcroot}.

${srcroot} Select all the files under the recursive directory.


2, be careful not to #import<mjrefresh/mjrefresh.h> such import. When referencing a three-party library, you need to declare it as a constant or variable in the method to associate the file within the library.

Use Mjrefresh as follows:

Swift: Bridging OC Files in Swift (class files you create, third-party library files)

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.