Adding Linked or Embedded Swift Framework: 'My

2019-06-17 09:30发布

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?

0条回答
登录 后发表回答