[英]Using swift framework in objc
I just created a framework in swift, and its working fine in swift project but in objective c I am getting errors like Undefined symbols for architecture armv7:
. 我刚刚在swift中创建了一个框架,并且在swift项目中也可以正常工作,但是在目标c中,我遇到
Undefined symbols for architecture armv7:
等错误。 I just checked the available architectures using lipo -info
, its showing both simulator and device architectures. 我只是使用
lipo -info
检查了可用的体系结构,它显示了模拟器和设备体系结构。 Also I referred this link but no use . 我也提到了这个链接,但没有用 。 Attached image also.
也附有图片。 I'll appreciate any help, Thank you.
谢谢您的帮助,谢谢。
Here below is to do list in your Framework. 以下是您框架中的待办事项列表。
Swift classes usage in Objective C classes Swift在Objective C类中的使用
I followed Apple Mix and Match approach. 我遵循了Apple Mix and Match的方法。 Hope this will help.
希望这会有所帮助。 Thanks
谢谢
To access a swift class in objc, that is not inherited from NSObject you need to: 要访问不是从NSObject继承的objc中的swift类,您需要:
@objc public class yourUtils @objc公共类yourUtils
A Swift class or protocol must be marked with the @objc attribute to be accessible and usable in Objective-C.
Swift类或协议必须使用@objc属性标记,才能在Objective-C中访问和使用。 This attribute tells the compiler that this piece of Swift code can be accessed from Objective-C.
该属性告诉编译器可以从Objective-C访问这段Swift代码。 If your Swift class is a descendant of an Objective-C class, the compiler automatically adds the @objc attribute for you.
如果您的Swift类是Objective-C类的后代,则编译器会自动为您添加@objc属性。
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.