Swift's method of referencing OC project--bridging-header

Source: Internet
Author: User

Briefly describe how to refer to the OBJECT-C code in the SWIFT project, citing the Fscalendar project as an example

1. First create a headerfile under the directory you want to refer to


Click Next


Change the file name to ***-bridging-header, select the project name in targets, * * * Modify the required content, click Create

2. You can see the header file just created in the table of contents


The ***-bridging-header.h file in the image above is the newly created file, open it, and I'll open the file directly above it.

Fscalendar-bridging-header.h is the reference header file that I have created, as follows (it has only one row of differences from the * * * created)


You can see that the content is only 3 lines after the comment is dropped, add the OC file to be referenced before endif, where the example is #import "FSCalendar.h"

Don't forget to press Command+s to save when you have finished adding

3. Finally configure the bridge header file, click Target-buildsetting, Search in the search box bridging find objective-c bridging Header, modify its properties

Add the path to the file that you just created


It's done here, you can use the OC method in the project.

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.