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.
-
how have you added your library to your project?Priyal– Priyal2018-12-10 07:42:57 +00:00Commented Dec 10, 2018 at 7:42
-
Actually I added framework in extensions Using drag and drop.Naveen Reddy– Naveen Reddy2018-12-10 07:50:51 +00:00Commented Dec 10, 2018 at 7:50
-
Can you add image how to have added the framework?Priyal– Priyal2018-12-10 09:29:42 +00:00Commented Dec 10, 2018 at 9:29
-
I edited my question please check.Naveen Reddy– Naveen Reddy2018-12-10 09:37:34 +00:00Commented Dec 10, 2018 at 9:37
-
why haven't you added as embedded binary?Priyal– Priyal2018-12-10 09:41:55 +00:00Commented Dec 10, 2018 at 9:41
2 Answers
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
7 Comments
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.