31

I have an app built with Swift with pods(firebase). I have 18 warnings and 100 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 do I get iOS linker errors with my static libraries?

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

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
Yuto
  • 658
  • 2
  • 8
  • 20

10 Answers10

20

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.

  • Thanks. You made my day! – Muxor Jul 22 '19 at 13:34
  • 1
    For me actually, before I noticed this answer I deleted all of my pods and reinstalled them and that fixed it for me – Yuto Aug 05 '19 at 01:33
  • 3
    I am facing a similar issue while building my `react-native` code for iOS. This solution isn't working for me. Is there anything else that can be done? – LordAnari Apr 20 '20 at 21:03
  • Same issue as @LordAnari . Also getting this in react-native. Any pointers would be much appreciated. – KentAgent May 03 '20 at 21:47
  • @KentAgent which library are you manually linking? For me, I am trying `react-native-razorpay`. Just wondering if it has anything to do with this. – LordAnari May 10 '20 at 21:19
  • @LordAnari I managed to solve my issue. Please check my answer on another question here and see if that solves your problem: https://stackoverflow.com/a/61582562/8576909 – KentAgent May 11 '20 at 23:14
15

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!

Neil Palethorpe
  • 359
  • 4
  • 6
4

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 :

enter image description here

Amir Ardalan
  • 389
  • 3
  • 7
4

In my case, it was a React-Native project after adding a Swift Pods library.

Solution 1:

  1. Adding a new Swift file and a Bridge header:
  1. File -> New -> File File -> New -> File

  2. Select Swift File Select Swift File

  3. Confirm Create Bridging Header enter image description here

Solution 2:

  1. Go to Build Settings and set Always Embed Swift Standard Libraries to YES Always Embed Swift Standard Libraries
Muhammad Numan
  • 23,222
  • 6
  • 63
  • 80
2

Create a swift file in the main project (File.swift) and add the following code to the same

//
// File.swift
//
import Foundation
AliRehman7141
  • 873
  • 3
  • 12
  • 33
2

In my case I accidentally added a test file to the main swift target. Removing it solves the problem

Here are what I did

1. go to compile source for the main target

enter image description here

2. search for test

enter image description here

3. remove it

enter image description here

Piakkaa
  • 740
  • 6
  • 12
1

In case you see the issue after updating React Native from 0.63.x to 0.64.x, try this solution:

  • Create a new 0.64.x project:

    npx react-native init MyApp --template react-native-template-typescript
    
  • Compare package.json of the new project and of your old 0.63.x project, and modify the old one.

  • Do similarly with ios/Podfile.

  • Run yarn install or npm install.

  • Run pod install in ios directory. Probably you need to remove the old Podfile.lock file.

  • Now, when you rebuild your project, hopefully the issue will be fixed.

Ngoc Dao
  • 1,501
  • 3
  • 18
  • 27
0

I recently faced this issue but the offending class was a unit test class. It turned out that a pod reference in my podfile was not included in the test target.

Kai
  • 186
  • 2
  • 10
0

I had added a new test target. I forgot to update my Podfile for the test target. Make sure you add your new target to Podfile. Run "pod deintegrate" and "pod install" after it.

Hemanshu Liya
  • 611
  • 6
  • 10
0

After trying all of these and the suggestions here I reverted and made two simple changes. I added import Foundation to the test file and then I added the offending pod to my testing target in the podfile. That resolved the issue.

Mark
  • 765
  • 8
  • 12