Why linker link static libraries with errors? iOS

拈花ヽ惹草 提交于 2019-11-27 01:57:49
Nathan

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

  1. Open ios/YourAppName.xcodeproj in Xcode
  2. Right-click on Your App Name in the Project Navigator on the left, and click New File…
  3. Create a single empty Swift file to the project (make sure that Your App Name target is selected when adding)
  4. when Xcode asks, press Create Bridging Header and do not remove Swift file then. re-run your build.

This should fix the problem

For XCode 11 beta 4 Library Search Paths should be:

$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)

Try this workaround https://stackoverflow.com/a/50495316/1658268

Basically just add a dummy swift file in your project, and re-run your build.

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

2) Select Swift File

3) Confirm Create Bridging Header

  1. Go to Build Settings and set Always Embed Swift Standard Libraries to YES

I've got the same errors when accidentally compiling a project with a Swift 5.0 Snapshot configured in the Xcode preferences » Components » Toolchain.

In case you encounter this error while using Xcode 11 beta 4 in combination with carthage see this workaround:

https://github.com/Carthage/Carthage/issues/2825

Basically it consists of creating a xcconfig with the fixes and inject these into each build.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!