How can I import Swift code to Objective-C?

前端 未结 15 2443
南方客
南方客 2020-11-22 02:52

I have written a library in Swift and I wasn\'t able to import it to my current project, written in Objective-C.

Are there any ways to import it?

#i         


        
15条回答
  •  后悔当初
    2020-11-22 03:21

    Find the .PCH file inside the project. and then add #import "YourProjectName-Swift.h" This will import the class headers. So that you don't have to import into specific file.

    #ifndef __IPHONE_3_0
    #warning "This project uses features only available in iPhone SDK 3.0 and later."
    #endif
    
    
    #ifdef __OBJC__
        #import 
        #import 
        #import "YourProjectName-Swift.h"
    #endif
    

提交回复
热议问题