简体   繁体   中英

Bridging Header issue - 'MyClass' is unavailable: cannot find Swift declaration for this class

I have visited this links -

MyClass is unavailable: cannot find Swift declaration for this class - Release Build Only

Adding Linked or Embedded Swift Framework: 'MyClass' is unavailable: cannot find Swift declaration for this class

Swift: using private framework

But none of the above links helped me to solve my problem.

I am developing an App using objective-c, in the app I am integrating ios-charts whose framework is developed in swift.I have merged the project as given in the README file. After integrating i have created a MyClass.swift file and then inherited the MyClass.swift file with a Class which is defined in charts.framework .But this is rising an error

'Class' is unavailable: cannot find Swift declaration for this class

Does anyone help me to solve this error? Any suggestions??

This may be due to possibility that you are building for device and using for simulator and vice-versa. Please check this. This is very important thing. If you compiled or build framework for device, it will not work on simulator.

我对此问题的解决方法是将框架的部署目标从我的设备更改为“ 通用iOS设备 ”,然后重新构建框架。

尝试添加Myoblass声明的@objc infront(即@objc类MyClass {...})

I encountered the same problem, ie, when calling functions from 'MyClass' contained in 'MyFramework', it reports that 'MyClass' is unavailable. It turns out to be the iOS deployment targets of the framework and the application calling it are different. When I set both to be the same, the problem goes away.

This error is just due to the framework's incompatibility for the build that you're trying to run it on..

Fix:-

1) Delete the framework from your project

2) Then:-

  • If you're running a simulator, go to your framework project and build the framework project selecting a simulator from the iOS Simulators list(any device from the simulators list) and then import the framework to the host project

  • If you're running a physical device, go to your framework project and build the framework project selecting "Generic iOS Device"/Physical Device(that's connected) and then import the framework to the host project

It should be working fine now. Hope this helps!

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