简体   繁体   中英

Import Swift code to Objective-C file

I have created a Swift project and imported Objective-C files. During import Xcode asked me to create a bridging header and created a header.

Now in the Objective-C files of the same project I want to use Swift class methods. I googled about importing Swift code in an Objective-C file. I found that we have to import ProjectName-Swift.h in the Objective-C file. My questions are as follows:

  1. ProjectName-Swift.h is not been created by Xcode. How do I create that file?
  2. After creation of ProjectName-Swift.h file, how do I use the Swift file methods in Objective-C files?

This seems really messed up, but the ProjectName-Swift.h file isn't visible. You just have to #import ProjectName-Swift.h in your Obj-C classes, and it'll work.

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