简体   繁体   中英

Use library classes written in Objective-c inside Swift project

I have a Swift project in which i want to use an sdk which is in a form of library files .a and .h files (written in Objective-C)

How do i use the code inside my swift project?

When i add the files to my project it dont give the option to create an objective-c bridging header

To create a bridging header:

  1. Add a new Header file to your project. File -> New -> Header file. I named it: "Your-Header-file.h"
  2. Go to your project Target -> Build Settings, search for Objective-C Bridging Header and set the header file's path in this field. You can do this by double-click Objective-C Bridging Header field, a panel show up, drag the header file to this panel.

在此处输入图片说明

  1. include .h file you need to use in Your-Header-file.h.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM