Using Swift Framework inside Objective C Project

廉价感情. 提交于 2019-12-22 08:24:16

问题


I have an Swift Framework which works perfectly inside Swift Projects. Now I am trying to use it inside of Objective-C project.

Iv'e Change the Class to looks like:

@objc public class Test : NSObject {}

I imported the framework to the Objective-C project, added it to the Embedded Binaries and to the Linked Frameworks and Libraries.

In the ViewController.m I imported the framework like this:

#import <SwiftFramework/SwiftFramework-Swift.h>

And I try to create instance of type Test:

Test* test = [[Test alloc] init];

Test is recognize but when I try to build it to iPhone it's failed with the reason of:

Undefined symbols for architecture arm64: "_OBJC_CLASS_$__TtC14SwiftFramework4Test", referenced from:

And if I build it to a simulator it failed with the reason of:

Undefined symbols for architecture i386: "_OBJC_CLASS_$__TtC14SwiftFramework4Test", referenced from:

I've tried to add the i386 and arm64 to the Valid Architectures,

I've tried to change the Build Active Architecture Only to No.

I've found a lot of solution which did not help me solve the issue.

I'll appreciate any help, Thank you.

SOLVED:

Build Setting -> Build Settings -> Always Embed Swift Standard Libraries -> YES

I updated the framework and the Objective-C project.

来源:https://stackoverflow.com/questions/42693433/using-swift-framework-inside-objective-c-project

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