Import Swift class into Objective c [duplicate]

浪子不回头ぞ 提交于 2019-12-21 21:39:59

问题


I'm trying to use the Swift class in my Object-c project. So far I have created the Objective-C project and imported the swift class and it asked me Would you like to configure an Objective-C bridging header?, then I hit Create Bridging Header so the productname-Bridging-Header.h file is created.

Then I changed

Always Search User Paths-->YES
SWIFT_OBJC_BRIDGING_HEADER-->YES

After that I import the swift class into my viewController.m class

Example: #import "Swiftclass.swift.h"

But it says #import "Swiftclass.swift.h" file not found


回答1:


You need to import ProjectName-Swift.h.

If your project name contain spaces, replace them with underscores (e.g. "My Project" becomes "My_Project-Swift.h")

Like,

 #import "My_Project-Swift.h"

Try like this. it will help you.



来源:https://stackoverflow.com/questions/37292578/import-swift-class-into-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!