简体   繁体   中英

Objective-C bridging issue. How do I use an Obj-C framework in a Swift project?

I must have started from scratch about 4 times already. I've followed the solutions listed below but I still have an issue (which I think has something to do with the bridging header file). Note: I have tried manually creating the bridging header as well as the automated solution Xcode offers when you drag some Objective-C files into a Swift project.

Swift Bridging Header import issue

Connect Objective C framework to Swift iOS 8 app (Parse framework)

Here are the main errors I am seeing. I've tried moving the header file up a level/down a level and it still claims to not see it. Everything is currently where Xcode put it when I selected "Yes" when prompted to created the bridging header automatically. You can also see the full contents of my bridging header. 在此处输入图片说明第一个错误

第二次错误

默认值

The "Cannot find protocol declaration for NSObject " error usually refers to circular references problems.

I'm wondering why you put all those standard Apple frameworks in the bridging header? This might be the problem. This special file is supposed to "bridge" Swift and Objective C worlds together, so if you've already referenced and linked your app against those frameworks in your Swift code, you shouldn't need to do it again in the bridging header.

Try to remove all Apple-provided frameworks from your bridging header and only leave the specific ones (IBM....h), and see if it works?

If it doesn't, then start with Foundation/Foundation.h only...

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