Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

swift

I am getting the following error:

MyClass is unavailable: cannot find Swift declaration for this class

but I only get it when doing a release build in Xcode...Debug works fine.

Anyone know what's up? I'm running 6.3

like image 303
Chris Avatar asked Apr 24 '15 15:04

Chris


4 Answers

If MyClass is inside a dynamic framework (Cocoa Touch Framework), It is likely that you're using a build with wrong architecture. To check, browse your MyClass.framework in finder, and check Modules/AirServiceKit.swiftmodule. There should be something like x86_64.swiftmodule or arm64.swiftmodule, if you're using simulator there should be x86, or arm if you're building for device.

like image 71
superarts.org Avatar answered Oct 23 '22 06:10

superarts.org


In case anyone else encounter this problem:

I had the exact same error and turned out that I had built my framework for an specific emulator. I changed the device (in upper left corner) to Generic iOS device and did a clean and build, then I used the generated .framework file. Everything worked just fine after using this generated .framework file.

like image 30
Akram Avatar answered Oct 23 '22 07:10

Akram


In my case, it was because my framework that I am developing was missing one of the Valid Architectures listed in my app's target. All I had to do was the following:

  1. Go to Project file.
  2. Go to Build Settings for the app target you're trying to build. Note the architectures listed under Valid Architectures.
  3. Go to the framework target that is failing.
  4. Make sure all the architectures match.

In my case, my framework was missing arm64.

like image 19
AdamPro13 Avatar answered Oct 23 '22 08:10

AdamPro13


Check the flag value you have set for Build Active Architectures Only in Build Settings for Debug and Release

like image 6
User31 Avatar answered Oct 23 '22 07:10

User31