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.
Asked
Active
Viewed 294 times
0

Naveen Reddy
- 89
- 7
-
how have you added your library to your project? – Priyal Dec 10 '18 at 07:42
-
Actually I added framework in extensions Using drag and drop. – Naveen Reddy Dec 10 '18 at 07:50
-
Can you add image how to have added the framework? – Priyal Dec 10 '18 at 09:29
-
I edited my question please check. – Naveen Reddy Dec 10 '18 at 09:37
-
why haven't you added as embedded binary? – Priyal Dec 10 '18 at 09:41
-
I added and image just showing available extensions. – Naveen Reddy Dec 10 '18 at 09:45
2 Answers
1
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

Aleem
- 3,173
- 5
- 33
- 71
-
Thanks for your response, I can able to access the classes of swift framework. I am not getting any errors like no such modules found. Issue related to architectures if I am not wrong. – Naveen Reddy Dec 10 '18 at 07:46
-
Have you added your swift framework into Embedded section in App target? – Aleem Dec 10 '18 at 07:49
-
-
I don't know what exactly you did wrong but the error "Undefined symbols for architecture armv7" related to Library built for another architecture like i386, Like you built library for Simulator and running on your device, It should be same – Aleem Dec 10 '18 at 08:01
-
Available architectures are i386, x86_64, armv7, arm64. Which means it works for both device and simulator. – Naveen Reddy Dec 10 '18 at 08:48
-
I know by default it support all these, but I'm asking you to build you framework with device lets say Naveen's iPhone and drag same yourFramework on your app and run app on Naveen's iPhone. like 3rd solution on this answer. https://stackoverflow.com/a/6429568/671060 – Aleem Dec 10 '18 at 08:53
-
0
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.

AtulParmar
- 4,358
- 1
- 24
- 45
-
Thanks for your response, actually I tried to add that in framework project like @objc public class Test : NSObject {}. After that I am getting error like duplicate interface definition for class and showing methods in my framework-swift.h file. – Naveen Reddy Dec 10 '18 at 07:49