I have a problem with linking my mixed language framework to a project.
I create a framework with Swift and Objective-C classes.
The main logic was stored in the Swift file. For example the class with a method that calls NSLog("Swift log was called").
Objective-C file has a class that has a method in which I create an instance of Swift class and call Swift-log method.
I link this framework with my Objective-C project, I can call all that I need in this project, but when I want to build this project I receive error linker command failed with exit code 1 (use -v to see invocation)
And warnings:
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
I also saw the solution with importing empty Swift-file, but it necessary to make a project without any trash.
This should fix the problem
In my case it was a React-Native project after adding a Swift Pods library. Maybe just the step 2 can work:
1) File -> New -> File
2) Select Swift File
3) Confirm Create Bridging Header
Build Settings
and set Always Embed Swift Standard Libraries
to YES
Apparently for pure objective-c projects you will need to add this $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
to the library search paths of your target. This worked for me when I was including a library written in swift to a project in objective-c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With