6

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??

Community
  • 1
  • 1
Rajat
  • 10,977
  • 3
  • 38
  • 55

5 Answers5

7

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.

Gopesh Gupta
  • 707
  • 8
  • 19
3

My fix for this problem was to change the deployment target of the framework from my device to “Generic iOS Device” and then rebuild the framework.

Alan Kinnaman
  • 877
  • 12
  • 20
1

Try adding @objc infront of the MyClass declaration (i.e. @objc class MyClass {...})

Yaser
  • 408
  • 2
  • 6
0

I encountered the same problem, i.e., 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.

0

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!

Lokesh SN
  • 1,583
  • 7
  • 23