Naveen Reddy
Naveen Reddy

Reputation: 99

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:. I just checked the available architectures using lipo -info, its showing both simulator and device architectures. Also I referred this link but no use. Attached image also. I'll appreciate any help, Thank you.

Upvotes: 0

Views: 309

Answers (2)

Aleem
Aleem

Reputation: 3291

Here below is to do list in your Framework.

Swift classes usage in Objective C classes

  • Use Open Keyword before class name in Swift
  • Use @objc Keyword before Open Keyword of Swift class
  • Import all header of objective c classes in Umbrella file YourProject.h those are consuming Swift Classes.
  • Use #import in Objective c

I followed Apple Mix and Match approach. Hope this will help. Thanks

Upvotes: 1

AtulParmar
AtulParmar

Reputation: 4570

To access a swift class in objc, that is not inherited from NSObject you need to:

@objc public class yourUtils

A Swift class or protocol must be marked with the @objc attribute to be accessible and usable in Objective-C. This attribute tells the compiler that this piece of Swift code can be accessed from Objective-C. If your Swift class is a descendant of an Objective-C class, the compiler automatically adds the @objc attribute for you.

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

Upvotes: 0

Related Questions