35

I need to make swift static library for my requirement. I made swift static library which uses swift and Obj-c code. I have included Obj-c files via bridge file. I am able to compile swift static library without any error and get libMySwift.a file. I use Xcode9.3 with Swift4 to compile library.

I include libMySwift.a in obj-c project and also included obj-c compatible header to access my lib in the project. When I try to compile the project it give below warning and more than 200 errors.

Auto-Linking library not found for -lswiftSwiftOnoneSupport
Auto-Linking library not found for -lswiftCore
Auto-Linking library not found for -lswiftQuartzCore
Auto-Linking library not found for -lswiftCoreImage
Auto-Linking library not found for -lswiftCoreGraphics
Auto-Linking library not found for -lswiftObjectiveC
Auto-Linking library not found for -lswiftDispatch
Auto-Linking library not found for -lswiftMetal
Auto-Linking library not found for -lswiftFoundation
Auto-Linking library not found for -lswiftUIKit
Auto-Linking library not found for -lswiftDarwin
Auto-Linking library not found for -lswiftCoreFoundation

Please let me know if I am missing any steps or need to add anything.

2

6 Answers 6

69

An update to Alex's answer:

In my case it was a React-Native project after adding a Swift Pods library. Maybe just the step 2 can work:

  1. Adding a new Swift file and a Brigde header:

1) File -> New -> File <code>File -> New -> File</code>

2) Select Swift File Select <code>Swift File</code>

3) Confirm Create Bridging Header enter image description here

  1. Go to Build Settings and set Always Embed Swift Standard Libraries to YES Always Embed Swift Standard Libraries
8
  • 1
    but the issue still present if you remove that swift file later :/ Jul 14, 2019 at 8:14
  • 1
    Thank you so much, it solved my issue. By the way, I'm trying to build using react-native. Oct 18, 2019 at 6:28
  • I've been spending two days trying to fix this issue and you saved me!
    – romin21
    Nov 15, 2019 at 15:56
  • 5
    why i cant see Confirm Create Bridging Header dialog? Jan 18, 2020 at 13:15
  • @TuanNguyen just create an empty header file by yourself. In the same directory and targets as your empty swift file. It worked for me. Mar 11, 2020 at 14:01
68

I've got the same error on my demo project when added first Swift file in my pod compiled as static library. For me solution was simple - just added empty Swift file to my demo project which was previously in Objective-C only. This solved all linker errors.

3
  • by creating Objective-C bridging Header is resolved the issue. Nov 3, 2018 at 4:57
  • Sweet. Kind of elegant solution. Xcode shows as warnings not errors. This solution fixed warnings and all erros caused by warnings.
    – fct
    Jan 5, 2019 at 21:40
  • I did this and still get the same error. Trying to ad adMob. Could not find auto-linked framework 'FBLPromises'
    – Curtis
    May 18, 2020 at 6:53
0

This answer worked for me: Add $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) to the library search paths.

0
  1. Right click on your project name and select new file
  2. Create an empty "Swift File" called File.Swift
  3. It will prompt to create a bridge header file then click create
0

If create empty "Swift File" errors

This method may be useful, can try : https://blog.cpming.top/p/react-native-0-62-undefined-symbol

0

I just follow AlVelig steps and still can't build the app, after making some hours on it finally works for me: in Build, Setting -> Build Active Architecture Only -> Select yes for Release too (it was No)

Build Active Architecture Only:

enter image description here

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.