Why do I get iOS linker errors with my static libraries? - ios

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.

Open ios/YourAppName.xcodeproj in Xcode
Right-click on Your App Name in the Project Navigator on the left, and click New File…
Create a single empty Swift file to the project (make sure that Your App Name target is selected when adding)
when Xcode asks, press Create Bridging Header and do not remove Swift file then.
re-run your build.
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:
Adding a new Swift file and a Brigde header:
1) File -> New -> File
2) Select Swift File
3) Confirm Create Bridging Header
Go to 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

I have export my unity project. Earlier it was working just to add empty swift file with press create Bridging Header.
but recently i have updated my xCode to 12.3 and it stop working.
So, tried few other ways.
I have added $(SDKROOT)/usr/lib/swift to Build settings > Search paths > Library search paths.
but still it doesn't work. So, i have added in same path i.e Build settings > Search paths > Library search paths.
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Now it working perfect. Didn't get exact problem or solution but it works well with this way.
I just add these three in Build settings > Search paths > Library search paths.
$(SDKROOT)/usr/lib/swift
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Separately TOOLCHAIN_DIR directories doesn't work. If i add $(SDKROOT)/usr/lib/swift then only it work.

For XCode 11 beta 4 Library Search Paths should be:
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)

Right click project name and add a new swift file leave it as File.swift
it will ask you to create a new bridging header accept
Run the project again

Try this workaround https://stackoverflow.com/a/50495316/1658268
Basically just add a dummy swift file in your project, and re-run your build.

If you have issue after update xCode to version 12 and errors
Could not find or use auto-linked library 'swiftWebKit'
and two more.
Just addd $(SDKROOT)/usr/lib/swift to the Build settings > Search paths > Library search paths.
Hope its help :)

If your Xcode version is >=12.2
Go to
BuildSettings -> Linking -> runpath search path
and add /usr/lib/swift as your 1st argument like this:

Xcode 12.5, React Native.
Change: 'Library Search Paths' from Swift-5.0 to Swift-5.2

What worked for me in a React Native project is to move $(inherited) to the bottom of the list in Build Settings -> Library Search Paths

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

XCode 11.3 beta, Swift 5.0
I just add my targets to the podfile:
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
def shared_pods
# Pods for NamaIOS
pod 'Alamofire'
pod 'RxSwift'
end
target 'MyApp' do
use_frameworks!
shared_pods
end
target 'MyApp-Test' do
use_frameworks!
shared_pods
end
target 'MyApp-Development' do
use_frameworks!
shared_pods
end

if you come from lottie-react-native install instructions just add use_frameworks! to podFile #536 (comment)

I am android programmer.
It took me a while understand what they were doing.
I have currently Xcode 13.2.1
And flutter 1 awful combination I know.
Please edit in other side xcode will take the enter like "I end"
I change Build settings > Search paths > Library search paths.:
From:
$(inherited) $(PROJECT_DIR)/Flutter
to:
$(inherited) $(PROJECT_DIR)/Flutter $(SDKROOT)/usr/lib/swift
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Thats all,
I hope to help some folk.

I am getting this error after installing Lottie-react-native?
The solution only works if it is caused by adding Lottie package.
This worked for me:
yarn add lottie-react-native
yarn add lottie-ios#3.2.3
And then must run:
pod install or pod update
I am using:
"lottie-ios": "3.2.3",
"lottie-react-native": "^5.0.1",
"react": "17.0.2",
"react-native": "0.67.3"

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.

I only forget to Add the new Framework to my pod file :)
target 'Data' do
inherit! :search_paths
pod 'AlamofireObjectMapper', '~> 5.2'
end

for Xcode 12.2
Create an Empty Swift file using Xcode, such as named Void.swift, and every issue will be solved by Xcode automatically.

I ran into this issue with our project and the issue was that there were orphaned references to lottie in our xcode project file. Opening that in a text editor and removing them fixed the issue for me.

What solved it for me when trying to integrate Lottie in my React Native project was to uninstall the lottie-ios and lottie-react-native modules with npm.
npm uninstall lottie-react-native lottie-ios
Make sure the files are unlinked as well
npx react-native unlink lottie-react-native lottie-ios
I also had the bridging-file in my project from previously trying that method without success so in order to replicate my process, follow the suggested answer and add that file to your project as well.
After these steps, I went ahead and deleted my Pods folder, cleaned my build from xcproject and xcworkspace (maybe one of these is enough).
After that I went ahead and installed the modules again
npm i --save lottie-react-native lottie-ios#3.1.3
(Make sure to check the current docks over at the lottie repo for the up-to-date versions.)
After you have reinstalled the modules, cd into your ios folder and run pod install.
Open up your xcworkspace in Xcode and run your project (make sure your build is clean).
This solved my issue.
Best of luck.

Related

Unable to build Project after pod init in an old xcode project

I am trying to init pod in an old code base. Whatever I do, I am not able to run my project after git init. There is always build error. I am getting following error,
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FBSDKCoreKit'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FBSDKShareKit'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FacebookCore'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FacebookShare'
ld: framework not found FBSDKCoreKit
Even if my dependency pod file is empty then I get
pods framework not found.
My Framework Search Paths is set to to $(inherited), which is build/Debug-iphoneos/FBSDKCoreKit.. I have also tried to set this path to pods folder under project. But nothings works. Even I have same issue with another project also.
Xcode version : 12.3
Code base is in Objective C.
I have experienced a similar problem before in the past, using FacebookSDK frameworks.
Of course, if you were using Swift, you could easily import it with Swift Package Manager.
Try to perform the following steps
1. Edit your podfile
Making explicit reference to the version and project name
pod 'FBSDKCoreKit', ‘version’ :project_name => ‘myapp’
2. Delete build data
MyApp-some_code being the appropriate folder name for your app
~/Library/Developer/Xcode/DerivedData/MyApp-some_code
3. Reinstall your pods
The command that you have probably tried a couple of times already
pod deintegrate
pod install
4. Manually add FBSDKCoreKit in Link Binary with Libraries
Navigate to Project->Targets->Build Phases->Link Binary With Libraries
From there click on the plus button and manually add the FBSDKCoreKit framework
5. Deselect copy items to destination's group folder
As per Facebook official documentation, available here.
Check out the point number 3, in particular.

Error "No such module" when import framework in Swift file [duplicate]

I'm currently coding in Swift, and I've got an error:
No such module Social
But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries".
The frameworks is in Objective-C, so I wrote a Bridge Header for it.
Please, how can I make Xcode recognize the framework?
In case it's Friday afternoon or anytime after 1am:
Opening xcodeproj instead of xcworkspace will cause an error like this...
I'm not sure why this happens, but one way to solve your issue is to go into your build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
Make sure that the naming of you configurations in the sub projects matches that of the "parent" project. If the configuration naming don't match exactly (case-sensitive), Xcode will abort the archive process and show the error "No such module ..."
That is, if you have a "parent" project with a configuration named "AppStore" you must make sure that all subprojects also have this configuration name.
See my attached screenshots.
I am not quite sure why Martin R's answer in the comments for the question is so disregarded:
Make sure that you tried simply skipping import of the framework as it is already added with the bridging header.
Hope this helps
I had the same issue using Cocoapods and Swift. I didn't notice the following lines in the Podfile:
# Uncomment this line if you're using Swift
# use_frameworks!
So, all I had to do was change it to:
# Uncomment this line if you're using Swift
use_frameworks!
...aaand it worked :)
The following steps worked for me.
Quit xcode
Run "pod update" in terminal
Open .xcworkspace and build again.
Please compare this screenshot with your build setting.
It may this work.
Go to the framework search path:
I was experiencing this problem as well. The fix for me was that the Archive schemes between the two projects didn't match. I have an xcworkspace with a framework project and an app project. The problem was that in the Archive scheme for my app, I was using a different Build Configuration than the framework was using for it's Archive scheme. I set both Build Configurations to Release, and that fixed the issue.
In my case, after many attempts to figure out what I was doing wrong importing a framework I eventually discovered that the framework itself was the problem. If you are not getting your framework from a trusted source you should inspect the framework and ensure that it contains a Modules folder with a module.modulemap file inside it. If module.modulemap is not present, you will get the "No such module 'MyFramework'" error.
If the Modules folder is missing the "MyFramework.swiftmodule" folder then the framework will be found but Xcode won't know about its contents so you will get different errors.
No such module Compile error
It is compile time error. You can get it in a lot of case:
.xcodeproj was opened instead of .xcworkspace
module.modulemap or .swiftmodule[About]
Objective-C Library/Framework Target
make sure that generated binary contains module.modulemap file and it's headers are located in Build Phases -> Headers section
Framework Search Paths
consumer -> framework
If you try to build an app without setting the Framework Search Paths(consumer). After setting the Framework Search Path to point to the framework resources, Xcode will build the project successfully. However, when you run the app in the Simulator, there is a crash for reason: Image not foundabout
It can be an absolute path or a relative path like $(SRCROOT) or $(SRCROOT)/.. for workspace
Import Paths
Swift consumer -> Swift static library
The Import Paths(consumer) should point to .swiftmodule
Find Implicit Dependencies
When you have an implicit dependency but Find Implicit Dependencies was turned off
CocoaPods
Check if this dependency is existed in a target
pod deintegrate
pod install
CocoaPods UI Test Bundle
for App Target where used additional dependency from CocoaPods. To solve it use inherit![About] in Podfile
[Recursive path]
Assuming the Framework really is there and in the path, etc... delete the ~/Library/Developer/Xcode/DerivedData/ModuleCache directory (and clean the project and delete the project-specific derived data for good measure).
When you do the standard cleanup, the ModuleCache directory doesn't get rebuilt.
Be sure, that Find implicit Dependencies in Build options in Scheme is on!
There are several potential misconfigurations the issue can arise for,
Please confirm that you have opened the .xcworkspace but not .xcodeproj file. Also make sure you have build Social first before you build TriviaApp.
Make sure that iOS Deployment Target is set same for all modules with main app. For example is TriviaApps deployment target is set to 9.0, Socials deployment target also need to be set to 9.0.
Make sure your main module (TriviaApp) and your used framework (Social) have same set of configurations. i.e. If your Project has three configurations, Debug, Release, ReleasePremium than your Social framework also need to have three configurations Debug, Release, ReleasePremium. Also make sure that the archive configuration is set same for both TriviaApp and Social. i.e. if your TriviaApps archive scheme is set to ReleasePremium, your Socials archive scheme also need to be set into ReleasePremium.
Please assure that you do not need to import Social in each .swift files when its already added in the Bridging-Header.h.
In case of issue came from Pod files, make sure you have uncommented #use_frameworks! into use_frameworks! from you Podfile. Sometime re installing pod works if Social has any dependency on pods.
If none of the above steps works, delete your derived data folder and try re building.
For me Build Active Architecture Only was set to Yes for the selected configuration. This did the trick:
Select "Pods" from the left project navigator > Select "Build Settings" > Build Active Architecture Only to No
What worked for me is this solution to another question. Closing Xcode and reopening the project as workspace. Go to your project folder and open .xcodeworkspace file.
Once you open the workspace (instead of project), Pods should appear as top level project in Project Navigator.
I also encountered the same error a few days back. Here's how I resolved the problem:
The error is "module not found"
Create Podfile in your root project directory
Install cocoapods (a dependency manager for Swift and iOS projects)
Run pod install
Go to Project Build Settings:
Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project)
Drag and drop the library header file from left side to bridging header (see image attached)
Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above)
In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h"
In your Swift file the code should be:
Import Mixpanel (i.e name of library)
That's all.
Ok, how the same problem was resolved for me was to set the derived data location relative to the workspace directory rather than keeping it default.
Go to preferences in xcode. Go to locations tab in preferences and set Derived data to Relative.
Hope it helps.
I was getting same error for
import Firebase
But then noticed that I was not adding pod to the main target section but only adding to Test and TestUI targets in Podfile.
With the command
pod init
for an xcode swift project, the following Podfile is generated
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
So, need to make sure that one adds pods to any appropriate placeholder.
Sometimes pod deintegrate and then pod install helps me, too.
As for xCode 12 and simulators,
the error might disappear when you navigate to Pods.xcodeproj in project navigator,
and in build settings under the 'Excluded Architectures', for every Debug and Release, chose 'Any iOS Simulator SDK' with value arm64.
If you're building for a platform like tvOS, make sure you have an Apple TV (i.e. matching) simulator selected.
Building a tvOS app with an iOS simulator selected gave me exactly this error. Spent the better part of an hour looking for all sorts of build issues... doh.
I was getting the same error as i added couple of frameworks using Cocoapods. If we are using Pods in our project, we should use xcodeworkspace instead of xcodeproject.
To run the project through xcodebuild, i added -workspace <workspacename> parameter in xcodebuild command and it worked perfectly.
In my case the app the IPHONEOS_DEPLOYMENT_TARGET was set to 9.3 whereas in my newly created framework it was set to 10.2
The implicit dependencies resolver ignored my new framework because the requirements of the target platform are higher than the app requirements.
After adjusting the framework iOS Deployment Target to match my application deployment target the framework compiled and linked successfully.
I was having a similar issue with xcode 10.3. xCode was unable to recognise files from pods. Here I have solved this way:
Go to Build Phase
Link Binary with Libraries
Add framework from pods (in my case EPSignature.framwork)
Clean & build the project
Error is gone.
TL;DR: Check your Podfile for target-specific shared_pods
After beating my head against the wall and trying literally every single other answer posted here over the last week, I finally found a solution.
I have two separate targets - one for release and one for development. The development target was created long after the release target, which lead me to forget some setup steps for that target.
I was able to get my project to compile properly using my release target, but my development target was having an issue.
After looking at my Podfile for the twentieth time, I noticed that I only had the following, under my shared_pods definition:
target 'Release' do
shared_pods
end
What I needed to do was add my second target to my Podfile, and that fixed the issue:
target 'Release' do
shared_pods
end
target 'Development' do
shared_pods
end
Hopefully this saves someone a few days of frustration.
Resolve issue of Webview of apple iOS xcode Version 12.3 (12C33)
Simply Do 3 steps:
Open project with .xcodeproj
Quit Xcode
Reopen project from .xcworkspace
All Done
I found that the Import Paths in the Build Settings was wrong for a custom (MySQL) module. After pointing that to the right direction the message was gone.
I fixed this with
Targets -> General -> Linked frameworks and libraries
Add the framework which should be at the top in the Workspace folder. Pain in the arse.
I just deleted my cocoapod. Then, I did a pod install to remove it. Then, I just added it back into my podfile and re-installed it. That made it work. Not sure why.
I had already installed pods. Build worked without any problems when I builded application on my device, but archive didn't work. I just run:
pod install
no new pods were installed, just .xcodeproj file got regenerated and archive started working

adding pods to compile sources (iOS App)

in our last sprint we tried to add some cocoapods to the project.
Unfortunately, the pods are not added automatically to the compile sources in the base project in Xcode.
That means that I needed to copy some relevant .m files to the list.
Well, it worked just fine for one pod.. But now I'm trying to add ShakeKit Pod and it's just not right! Plus, I don't see the benefits of using cocoapods if I need to import every .m file to my project.
Anyone here knows to tell me what I'm doing wrong?
Environment Details:
iOS SDK - 8.3
Xcode - 6.3
I've found that $(inherited) was missing from my Other Linker Flags build setting. Applying this option fixed a missing library issue I was seeing.
Just like the guy from this thread :
Error: ld: library not found for -lPods with CocoaPods

Getting error "No such module" using Xcode, but the framework is there

I'm currently coding in Swift, and I've got an error:
No such module Social
But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries".
The frameworks is in Objective-C, so I wrote a Bridge Header for it.
Please, how can I make Xcode recognize the framework?
In case it's Friday afternoon or anytime after 1am:
Opening xcodeproj instead of xcworkspace will cause an error like this...
I'm not sure why this happens, but one way to solve your issue is to go into your build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
Make sure that the naming of you configurations in the sub projects matches that of the "parent" project. If the configuration naming don't match exactly (case-sensitive), Xcode will abort the archive process and show the error "No such module ..."
That is, if you have a "parent" project with a configuration named "AppStore" you must make sure that all subprojects also have this configuration name.
See my attached screenshots.
I am not quite sure why Martin R's answer in the comments for the question is so disregarded:
Make sure that you tried simply skipping import of the framework as it is already added with the bridging header.
Hope this helps
I had the same issue using Cocoapods and Swift. I didn't notice the following lines in the Podfile:
# Uncomment this line if you're using Swift
# use_frameworks!
So, all I had to do was change it to:
# Uncomment this line if you're using Swift
use_frameworks!
...aaand it worked :)
The following steps worked for me.
Quit xcode
Run "pod update" in terminal
Open .xcworkspace and build again.
Please compare this screenshot with your build setting.
It may this work.
Go to the framework search path:
I was experiencing this problem as well. The fix for me was that the Archive schemes between the two projects didn't match. I have an xcworkspace with a framework project and an app project. The problem was that in the Archive scheme for my app, I was using a different Build Configuration than the framework was using for it's Archive scheme. I set both Build Configurations to Release, and that fixed the issue.
In my case, after many attempts to figure out what I was doing wrong importing a framework I eventually discovered that the framework itself was the problem. If you are not getting your framework from a trusted source you should inspect the framework and ensure that it contains a Modules folder with a module.modulemap file inside it. If module.modulemap is not present, you will get the "No such module 'MyFramework'" error.
If the Modules folder is missing the "MyFramework.swiftmodule" folder then the framework will be found but Xcode won't know about its contents so you will get different errors.
No such module Compile error
It is compile time error. You can get it in a lot of case:
.xcodeproj was opened instead of .xcworkspace
module.modulemap or .swiftmodule[About]
Objective-C Library/Framework Target
make sure that generated binary contains module.modulemap file and it's headers are located in Build Phases -> Headers section
Framework Search Paths
consumer -> framework
If you try to build an app without setting the Framework Search Paths(consumer). After setting the Framework Search Path to point to the framework resources, Xcode will build the project successfully. However, when you run the app in the Simulator, there is a crash for reason: Image not foundabout
It can be an absolute path or a relative path like $(SRCROOT) or $(SRCROOT)/.. for workspace
Import Paths
Swift consumer -> Swift static library
The Import Paths(consumer) should point to .swiftmodule
Find Implicit Dependencies
When you have an implicit dependency but Find Implicit Dependencies was turned off
CocoaPods
Check if this dependency is existed in a target
pod deintegrate
pod install
CocoaPods UI Test Bundle
for App Target where used additional dependency from CocoaPods. To solve it use inherit![About] in Podfile
[Recursive path]
Assuming the Framework really is there and in the path, etc... delete the ~/Library/Developer/Xcode/DerivedData/ModuleCache directory (and clean the project and delete the project-specific derived data for good measure).
When you do the standard cleanup, the ModuleCache directory doesn't get rebuilt.
Be sure, that Find implicit Dependencies in Build options in Scheme is on!
There are several potential misconfigurations the issue can arise for,
Please confirm that you have opened the .xcworkspace but not .xcodeproj file. Also make sure you have build Social first before you build TriviaApp.
Make sure that iOS Deployment Target is set same for all modules with main app. For example is TriviaApps deployment target is set to 9.0, Socials deployment target also need to be set to 9.0.
Make sure your main module (TriviaApp) and your used framework (Social) have same set of configurations. i.e. If your Project has three configurations, Debug, Release, ReleasePremium than your Social framework also need to have three configurations Debug, Release, ReleasePremium. Also make sure that the archive configuration is set same for both TriviaApp and Social. i.e. if your TriviaApps archive scheme is set to ReleasePremium, your Socials archive scheme also need to be set into ReleasePremium.
Please assure that you do not need to import Social in each .swift files when its already added in the Bridging-Header.h.
In case of issue came from Pod files, make sure you have uncommented #use_frameworks! into use_frameworks! from you Podfile. Sometime re installing pod works if Social has any dependency on pods.
If none of the above steps works, delete your derived data folder and try re building.
For me Build Active Architecture Only was set to Yes for the selected configuration. This did the trick:
Select "Pods" from the left project navigator > Select "Build Settings" > Build Active Architecture Only to No
What worked for me is this solution to another question. Closing Xcode and reopening the project as workspace. Go to your project folder and open .xcodeworkspace file.
Once you open the workspace (instead of project), Pods should appear as top level project in Project Navigator.
I also encountered the same error a few days back. Here's how I resolved the problem:
The error is "module not found"
Create Podfile in your root project directory
Install cocoapods (a dependency manager for Swift and iOS projects)
Run pod install
Go to Project Build Settings:
Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project)
Drag and drop the library header file from left side to bridging header (see image attached)
Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above)
In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h"
In your Swift file the code should be:
Import Mixpanel (i.e name of library)
That's all.
Ok, how the same problem was resolved for me was to set the derived data location relative to the workspace directory rather than keeping it default.
Go to preferences in xcode. Go to locations tab in preferences and set Derived data to Relative.
Hope it helps.
I was getting same error for
import Firebase
But then noticed that I was not adding pod to the main target section but only adding to Test and TestUI targets in Podfile.
With the command
pod init
for an xcode swift project, the following Podfile is generated
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
So, need to make sure that one adds pods to any appropriate placeholder.
Sometimes pod deintegrate and then pod install helps me, too.
As for xCode 12 and simulators,
the error might disappear when you navigate to Pods.xcodeproj in project navigator,
and in build settings under the 'Excluded Architectures', for every Debug and Release, chose 'Any iOS Simulator SDK' with value arm64.
If you're building for a platform like tvOS, make sure you have an Apple TV (i.e. matching) simulator selected.
Building a tvOS app with an iOS simulator selected gave me exactly this error. Spent the better part of an hour looking for all sorts of build issues... doh.
I was getting the same error as i added couple of frameworks using Cocoapods. If we are using Pods in our project, we should use xcodeworkspace instead of xcodeproject.
To run the project through xcodebuild, i added -workspace <workspacename> parameter in xcodebuild command and it worked perfectly.
In my case the app the IPHONEOS_DEPLOYMENT_TARGET was set to 9.3 whereas in my newly created framework it was set to 10.2
The implicit dependencies resolver ignored my new framework because the requirements of the target platform are higher than the app requirements.
After adjusting the framework iOS Deployment Target to match my application deployment target the framework compiled and linked successfully.
I was having a similar issue with xcode 10.3. xCode was unable to recognise files from pods. Here I have solved this way:
Go to Build Phase
Link Binary with Libraries
Add framework from pods (in my case EPSignature.framwork)
Clean & build the project
Error is gone.
TL;DR: Check your Podfile for target-specific shared_pods
After beating my head against the wall and trying literally every single other answer posted here over the last week, I finally found a solution.
I have two separate targets - one for release and one for development. The development target was created long after the release target, which lead me to forget some setup steps for that target.
I was able to get my project to compile properly using my release target, but my development target was having an issue.
After looking at my Podfile for the twentieth time, I noticed that I only had the following, under my shared_pods definition:
target 'Release' do
shared_pods
end
What I needed to do was add my second target to my Podfile, and that fixed the issue:
target 'Release' do
shared_pods
end
target 'Development' do
shared_pods
end
Hopefully this saves someone a few days of frustration.
Resolve issue of Webview of apple iOS xcode Version 12.3 (12C33)
Simply Do 3 steps:
Open project with .xcodeproj
Quit Xcode
Reopen project from .xcworkspace
All Done
I found that the Import Paths in the Build Settings was wrong for a custom (MySQL) module. After pointing that to the right direction the message was gone.
I fixed this with
Targets -> General -> Linked frameworks and libraries
Add the framework which should be at the top in the Workspace folder. Pain in the arse.
I just deleted my cocoapod. Then, I did a pod install to remove it. Then, I just added it back into my podfile and re-installed it. That made it work. Not sure why.
I had already installed pods. Build worked without any problems when I builded application on my device, but archive didn't work. I just run:
pod install
no new pods were installed, just .xcodeproj file got regenerated and archive started working

Cocoapods ld: library not found for -lPods-Projectname

I've installed cocoa pods library and some frameworks through it. Now when I compile project the build fails.
Error:
ld: library not found for -lPods-Project
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here part of text:
Ld /Users/polzovatel/Library/Developer/Xcode/DerivedData/Project-bybevfqrgvqqldbzsgewqafpmylj/Build/Products/Debug-iphonesimulator/Project app/Project normal i386
cd /Users/polzovatel/Projects/iOS-master/Project_iPhone
export IPHONEOS_DEPLOYMENT_TARGET=6.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
What I need to do to fix this problem?
Fixed it by deleting the -lPods-Projectname.a in Link Binary (for newer versions, delete the -lPods-Projectname.a under the Frameworks group).
Whenever I execute "pod install" it leads me to spend several hours fixing build errors. So, I deleted CocoaPods stuff and do not have problems any more! Now I am lucky and happy man.
Start using Swift Package Manager (SPM). If your 3rd party lib still do not support SPM I encourage you to take action on adding SPM support on your own. Here is instructions.
Or create an issue for the 3rd party lib about adding support for SPM.
The exact location that you should remove your libs is at:
Remove -lyourlibname.a in "Link Binary With Libraries" on "Build Phases" of your target.
You can try "Build Active Architecture Only" = YES . it may be solving problem.
Ensure that Build Active Architectures Only settings for both of your project and the Pods project were equal for debug and release configuration! That's was a problem in my case.
Make sure Build Active Architectures Only in your Project/Target and in your Pod/Target and Pod are the same.
We often set the debug yes and set the release no.
I realized the xcproject file was opened instead of the updated workspace. This fixed my error. Hope this information will help others too.
If none of the other answers help you, try this:
Deintegrate cocoa pods using pod deintegrate. Check this link https://github.com/kylef/cocoapods-deintegrate.
Search on the build settings for target and project file for "pod". Anything that looks like it belonged to cocoa pods, remove.
Finally, run pod install once again.
Go to Product > Scheme > Edit Scheme... > Build > + > Add the Pods-Projectname.a and drag it to the top > Clean & Build your project.
I had a very different experience. I tried removed the library from build settings to no avail. And honestly, I couldn't see the logic behind it.
What I did was try a new pod install. And so it gave me this error
[!] The ProjectName [Debug] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target.
[!] The ProjectName [Release] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target.
So I did what it told me to, I added the $(inherited) flag to build settings. And all worked well
In my case I found that a mis-match of deployment target of the Project (iOS 11.4) versus the Target (iOS 10.3). Updating the target to iOS 11.4 fixed the issue.
Project > Info > Deployment Target > iOS Deployment Target
Project > Target > General > Deployment Target > Target
Podfile:
platform :ios, '11.4'
I had this problem when I accidentally opened project instead of workspace so Cocoapods where missing....
Check your Project -> Targets -> Build Phases -> Link Binary With Libraries
Point to your Pods project, set the BaseSDK to iOS SDK since 'pod install' process clear it.
Also set Build Valid Architecture Only to NO
That should work.
I experienced a similar error which affected one of my computers but not the other when compiling the same project.
I reinstalled cocoapods, all gems, rebuilt the project and none of it worked. I finally got it to compile but required me to completely remove Xcode and related data (iPhone simulator, DerivedData) then reinstall Xcode.
I've had this error after adding a new build configuration.
pod install helped, because it adds separate settings for each build configuration.
i also had the same sort of issue. So Check your pod file's platform :ios . and check Deployment info target versions. and please make sure version of both files are same. if both are not same the issue will be executed. i also had the issue after library updating my react native project
(Target info = select your project, then select target, In general section Deployment info is available.)

Resources