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

别等时光非礼了梦想. 提交于 2019-12-12 10:39:11

问题


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?

来源:https://stackoverflow.com/questions/27584662/adding-linked-or-embedded-swift-framework-myclass-is-unavailable-cannot-find

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!