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

5

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

Binding answered 31/8, 2015 at 13:30 Comment(1)
Did you manage to resolve the issue?Shultz
T
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.

Tubb answered 17/12, 2015 at 8:31 Comment(3)
This was my issue for external private framework I embeddedNegrillo
so I should provide separate versions of framework for device and simulator? why it happens ?Ballocks
yes @pvllnspk. you need to create separate version.Tubb
N
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.

Nasia answered 10/1, 2017 at 23:35 Comment(0)
C
1

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

Cavallaro answered 31/8, 2015 at 13:34 Comment(0)
I
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.

Inoperative answered 30/12, 2016 at 19:57 Comment(0)
C
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!

Casement answered 3/9, 2018 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.