Cannot fix “Could not find or use auto-linked libr

2020-08-17 05:46发布

问题:

I have an app built with Swift with pods(firebase). I have 18 triangle and 100 red errors which weren't there before. They only appear when I try to archive my app.

I have tried all of these (Adding search paths, Adding blank swift files, deleting framework paths)

It gives errors when using Swift Static library with Objective-C project

Why linker link static libraries with errors? iOS

ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftsimd'
ld: warning: Could not find or use auto-linked library 'swiftGLKit'
ld: warning: Could not find or use auto-linked library 'swiftMetal'
ld: warning: Could not find or use auto-linked library 'swiftSpriteKit'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftModelIO'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftAVFoundation'
ld: warning: Could not find or use auto-linked library 'swiftCoreMedia'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftCoreAudio'

Environment: Xcode 11 beta 4 / Target: iOS 12 and up

回答1:

Apple mentioned similar issue in known issues section:

Targets that contain Swift code with the Enable Bitcode build setting set to Yes fail to link correctly when built with the Archive action.

And give us a workaround:

Add a custom build setting with the name LD_VERIFY_BITCODE, and set it to NO. Make a note to yourself to delete this custom build setting once this issue is resolved.



回答2:

I had a same error... my problem solved with -> add the library (framework) in the Frameworks and Libraries that you used in any target

for Example :



回答3:

My ObjectiveC project was including a Swift pod which was then throwing the above errors. I found all I had to do was add a swift header file into the base of my project and it suddenly all built.

What gave it away for me was when I went into the Build Settings of my Target project and did a search for 'swift' I was only seeing a very minimal amount of results when I knew I should be seeing more - after adding the header file I suddenly saw a lot more options here. Below are the steps I took.

  1. Right click on your root project in the Project Navigator
  2. Select 'New File'
  3. Select a 'Swift File'
  4. Give it a name of 'BridgeHeader' (you don't need to specify the .swift - it'll add the extension automatically)
  5. Run a clean + build and hopefully the errors will have disappeared!

I'm unsure if the name is important, nor am I sure on the position of the file but this is what worked for me!



标签: ios swift xcode