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

0

7

I have a Swift Cocoa Touch Framework project (we'll call it MySwiftFramework) that has some nifty code in it that I'd like to reference in another project/workspace.

When attempting to reference that framework, I get the following error in the code that references the swift classes of the aforementioned framework:

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

I've checked the auto-generated file: MySwiftFramework.framework/Headers/MySwiftFramework-Swift.h and it includes the auto-generated headers for the swift classes in MySwiftFramework:

SWIFT_CLASS("_TtC16MySwiftFramework12MySwiftClass")
@interface MySwiftClass : NSObject
@property (nonatomic, copy) NSString * coolThingName;
- (instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end

The only way I can get it to work is if I drag MySwiftFramework into the workspace I'm trying to reference it with. Then it will compile, but when I try to archive the app, it archives the project as "Xcode Generic Archive" instead of an "iOS App Archive".

There's got to be a way to reference a swift framework by just embedding the MySwiftFramework.framework file.

Does anyone know what might be causing this error?

Bister answered 20/12, 2014 at 21:55 Comment(1)
Did you solve this already? If so, please write down an answer. If not, would following the following guide help: raywenderlich.com/99386/create-cocoapod-swift ?Behah

© 2022 - 2024 — McMap. All rights reserved.