Apple Mach -O Linker (Id) Error? - ios

I am trying to build this xcode workspace which was built from Unity. And after modifying the project a little bit when I getting to the very end of building the project (linking) I get the Apple Mach -O Linker (Id) Error. I can't open the error tab to see what exactly is causing the error. All it says is "Linker command failed with exit code 1 (use -v to see invocation). There are also two Apple Mach -O Linker (Id) Errors which occur but I have no idea how to solve them.
Any help is greatly appreciated!
I can't expand these tabs.. this is all I get told
This is the warning tab expanded, the two Apple Mach -O Linker (Id) warnings are the same

This problem has different solutions , one of them is to set Enable Bitcode to No . ( I don't know why by default it is Yes )
This problem is a ghost like problem . Clearing Cache , Restarting Xcode , Simulator and MAC ,Ensuring proper linking of Frameworks ,Changing app Architecture or , Sometimes just doing nothing can solve this problem .

This issue was connected to "Link Binary With Libraries". I've renamed the target, and there were two .framework files for the Pods. Thus, after removing the outdated one - the issue was solved.

For me the scenario was that I removed one of the dependency in my pods which was not required, after removing it I was getting error that the same dependency not found. So I went to delete its entry from the Project >> Build Settings >> other Linker Flags and then selected the same and deleted it as shown below in the Image. After removing from the linker Flags I started getting the Apple Mach -O Linker (Id) Error? and after trying everything for a day I realised the issue lies inside the linker Flags. Where on deleting any dependecy you have to delete the other line name -framework. you can check the below image to get the clarity.
So I suggest to keep an eye on it while deleting the dependecy from the linker flags, do delete the associated -framework too which lies below the dependency name. In my case it was ObjectMapper

If you just installed/ uninstalled a pod you might want to look at this. Here's what worked for me:
First make sure you are opening the .xcworkspace file not the .xcodeproj. But this is probable not what's causing the issue.
Delete the pod that was recently just installed.
In the project directory on Xcode, open the frameworks folder and if the pod which was just removed is still listed there as one recentlyremovedpod.framework, delete it from there also. This step is what made my project compile eventually.

Another possible cause is if you rename one of your targets (why did I do that?) and you're using pods. You end up with a version of your old target name in the Frameworks folder in your main project (not the Pods project), like pods_oldtarget_framework which no longer exists.
Just delete the old version (or name your target back to it's original and delete the new one), and you should be good to go.

For me it was missing frameworks. Try searching the errors you get on Google and find out which frameworks they're part of, then import them in the Build phases tab.

I was having the same issue, and resolved by
installing the latest CocoaPods
then do pod setup

For me I had the problem because I was using Xcode 9 (beta), then I open the same project with another Xcode 8.3. To solve the problem for me just Clean then Run again.

If building on mac for ios in unity, make sure that in the build settings you disable "Metal Editor Support" under other settings for the ios platform.

I used xcode 9.3 and I got this same error. But with 9.2 it works.
The error may happen because of incompatibilities between the artifacts produced by the two xcodes. The project that threw the error included a framework built with xcode 9.2

I added libstdc++.tbd to "BuildPhases >> Link Binary With Libraries". It works for me.

How I resolved this issue:
I exit Xcode then opened my project's .xcworkspace again.
While Xcode was starting...i saw warnings...xcode is smarter enough and ask you switch to recommended settings...Tap it and let him do the changes.
(Read warning seriously and with positive mind and then you will resolve it) 😊

Related

framework not found RealmSwift

I was installing Realm and imported to my project but when I run the app it shows me an error:
ld: framework not found RealmSwift
clang: error: linker command failed with exit code 1 (use -v to see invocation)
There can be multiple reasons for this issue.
To get the exact issue you can follow the below step :
Right click on error and select 'Reveal in log'. This will give you more insight about the reason of error.
One of the solution is to setting the 'Enabled Bitcode' to No. For this go to Build settings in your target and search 'Bitcode' in the search field.
I have faced this issue multiple times and one of the below solution may work for you.
After installing the pods make sure that you're opening the workspace instead of Xcode project file.
Restart Xcode
Remove derive data for your application
Reintegrate pods using pod deintegrate and pod install for your project
Reset simulator(If you are viewing the output in simulator)
Ensure proper linking of Framework in your project
Restart simulator
Clean project etc.
Hope this may help you.
I was having the same issue.
Initially, I was trying to import the files (Realm.framework and RealmSwift.framework) from download folder but then i was getting the same error like yours.
What i did then, i copied the folder containing the (Realm.framework and RealmSwift.framework) into the project folder and then i imported the files from there. That resolves my issue.
In my case, I've updated the Cocopods to the latest version (1.1.0) via this command sudo gem install cocoapods
is it possible that you are still running the .xcodeproj file. You should run .workspace file in your xcdoe

Apple Mach-O Linker & Ditto Error - Xcode 8

I have just updated my Xcode to Xcode 8 and am now trying to convert my project's code to Swift 2.3. I was able to build a couple times using Xcode 8 without any errors. Now, the following errors came up:
Error #1: Apple Mach-O Linker Error: Linker command failed with exit code 1
ld: file not found: /Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbegcsbcipdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/DownloadsViewController.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't even know what a .o file is. The swift file of DownloadsViewController is there, though.
Error #2: Ditto Error: Command /usr/cin/ditto failed with exit code 1
ditto: can't get real path for source '/Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbbciegrfdpdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp-Swift.h'
Command /usr/bin/ditto failed with exit code 1
The ditto error occurs 3 times: for MyApp.swiftdoc, MyApp.swiftmodule, and MyApp-Swift.h.
Thanks in advance!
Quit Xcode
Restart the System
Select Xcode -> Preferences.
This will open a pop-up window. Select 'Locations'. In Locations, you will see 'Derived Data'. Click on the arrow icon right next to the path.
This will open a folder containing 'Derived Data', delete it.
Clean the Product and Run
Make sure you open the project from the .xcworkspace file instead of the .xcodeproj
step 1 = clicking on the project in the navigation menu
step 2 = select the project
step 3 = build settings
step 4 = search enable bitcode if bitcode is yes than change to No
None of the previous answer have solve my problem.
I think it come from changes in the cocoapods podFile, from using frameworks to not using them
Frameworks was still remind in Target>General Properties>Linked Frameworks. I removed them
I also remove the -framework and corresponding frameworks from other linker flags (saving inherited and objC flags)
Hope that could help
This happened to me after I delete my app while it was running.
I solved it cleaning the project.
Product > Clean or Shift + Command + K
This is because at some point some project file was not compiled. In my case the AppDelegate.swift was not in the compiler. So I added it manually and it worked.
Clean XCode with following cmds and rebuild:
rm -rf ~/Library/Developer/Xcode/DerivedData/
killall Xcode 2> /dev/null
killall Instruments 2> /dev/null
killall 'iOS Simulator' 2> /dev/null
killall Simulator 2> /dev/null
killall 'Simulator (Watch)' 2> /dev/null
killall ibtoold 2> /dev/null
killall simctl 2> /dev/null
# There may be others
# Kill the service itself
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator
For my react native app, I deleted a folder of a test project inProject Navigator and Targets. It solved my problem.
Don't wory ,just go to your project targat and then build setting and search enable bitcode change it to YES to NO.
Turning Bitcode to "No" solved this issue. This is found in the Build Settings.
I had the same problem when I changed Xcode from a previous version 7 to the new XCode 8. In the new Xcode (8.3.3 now) there are more settings in the compiler.
When you update the project settings into new Xcode (using Editor->Validate Settings), these new settings are applied and set to the default value YES. After this update I had the linker error!
In my project I compared the previous version of the file .pbxproj with the new one (after Settings validation) using Beyond compare (or similar).
In this way I can saw the new settings added in the new version of Xcode and I set the new Settings value to NO. After this update all was OK and the linker error disappear.
If you're importing a framework through Build Phases, try to put it inside the folder of your project and add it into Link Binary with libraries. Actually, I've already experienced that problem before, I am very frustrated with that error until I knew that I have to put the .framework inside the folder of my project.
Hope will help
On top of cleaning derived data and the project and restarting xcode, I've found that re converting your project to current swift syntax and re installing pods if you have them also helps.
To re convert your project you will need to set swift_version build setting back to yes so that your target appears in the conversion list.
The issue I found with XCode 8.2.1 (Version 8C1002) after I converted the project to Current Swift Syntax (Swift 3). I just needed to rebuild it after cleaning, and the errors disappeared.
If the procedure of cleaning and the disabling of bitcode does not work, then it's possible that the reason for the errors simply is a more complex syntax error in your code.
I got the same problem because I had defined a class (using #interface), but did not provide an implementation (using #implementation) for it. It was a simple class so even an empty implementation resolved it.
Also just check if you are importing a "*.m" implementation file in any of your classes, that can cause the same issue.
Removing the import statement can fix the issue
For me it was a problem with react native haptic. I think it was because of a change in CocoaPods but also because of changing up file locations. I just removed it and re installed it. Hope this helps someone.
UPDATE
The build succeeded by when running it it would just crash. To solve this I used File > Add Files to Project for the GoogleService-Info.plist and it worked.
Please make sure you have following changes in Workspace setting in your xcode:
Please go to your workspace setting and make the following changes:
Workspace Setting:
Build System:
Legacy Build System
Per -User Workspace
DerivedData:
Workspace relative location
Build System
Use User Setting
Hope it helps:
Follow the below steps:
step1: Go to Build Phase Tab then only expand Link Binary with Library
step2: Then Go to General Tab then Expand Linked Framework & Library
(because Yourprojectname.framework is disable)

1Password Pods iOS library not found

I resume an project from someone else in my company who make a iOS apps using 1password pods.
i have a build error , i search on the web but i dont found a solution.
maybe can you help me.
here the error :
ld: library not found for -l1PasswordExtension
clang: error: linker command failed with exit code 1 (use -v to see invocation)
thanks in advance
I've run into this problem a few times when using cocoapods. Some of the solutions on this SO post have helped me before Cocoapods ld: library not found for -lPods-Projectname
Also, the official cocoapods site has some help for this issue on their troubleshooting page https://guides.cocoapods.org/using/troubleshooting.html:
If Xcode complains when linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
Add the Pods static library, and make sure it's at the top of the list
Clean and build again
If that doesn't work, verify that the source for the spec you are trying to include has been pulled from GitHub. Do this by looking in /Pods/. If it is empty (it should not be), verify that the ~/.cocoapods/master//.podspec has the correct git hub url in it.
If still doesn't work, check your Xcode build locations settings. Go to Preferences -> Locations -> Derived Data -> Advanced and set build location to "Relative to Workspace".
If all else fails, you can always try deleting the Xcode workspace and the Pods directory, then re-running 'pod install' to see if that clears things up.
Thanks Rob T, i edit the scheme and now it's work.
just before to run i made a pod install.

Error "library not found for" after putting application in AdMob

I am getting an error after I put my application in an AdMob. The app was working until today. The error is the following:
ld: library not found for -lGoogleAdMobAds
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can I fix this? Thank you.
I had a similar "library not found" issue. However it was because I accidentally was using the .xcodeproj file instead of the .xcworkspace file.
Sometimes you just remove the reference of the library and add reference again.
Apart from adding the Google Mobile Ads SDK and other libraries again from scratch, I would recommend you checking the Library Search Paths. There are instances when you copy or duplicate a target, Xcode decides that it needs to escape any double quotes " with a '\'. Make sure you remove all the \’s - it should look like this -
I was able to duplicate the error, by doing prefixing my path with multiple '\'.
Select your Target, go to "Build Phases" in "Link Binary With Libraries" remove ".a" file of that library.
Clean and Build.
If error related to Cocoapods as follow:
library not found for -lPod-...
You need to check Other Linker Flags and remove it from there.
Extra Information: If you have an old project that uses cocoapods. And recently you needed to add the use_frameworks! to your podfile.
cocoapods will not add the libraries to your Other Linker Flags
anymore cause its inherited. Therefore, you may need to remove those
manually from the other linker flags which they were added before
using the use_frameworks!
For my case Xcode 7, also worked in Xcode 9.1/9.2
ld: library not found for -ldAfnetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
set Build Active architecture Only to Yes
If error is like following
ld: library not found for -lpods
I found that a file "libPods.a" which is in red colour(like missing files) was created somehow in the Framework group of the project. I just simply removed that file and everything got fine.
EDIT: Another Solution
Another Solution that I have already answered in the similar question is in this link
goto Build Phases -> Link Binary With Libraries and remove library which show errors because that library is not available in project folder
Late for the answer but here are the list of things which I tried.So it will be in one place if anyone wants to try to fix the issue.
Valid architecture = armv7 armv7s
Build Active Architecture only = NO
Target -> Build Settings ->Other Linker Flags = $(inherited)
Target -> Build Settings ->Library Search Path = $(inherited)
Product Clean
Pod Update in terminal
ld: library not found for
It is compile time error for a Static Library that is caused by Static Linker
ld: library not found for -l<Library_name>
1.You can get the error Library not found for when you have not include a library path to the Library Search Paths(LIBRARY_SEARCH_PATHS)
ld means Static Linker which can not find a location of the library. As a developer you should help the linker and point the Library Search Paths
Build Settings -> Search Paths -> Library Search Paths
2.Also you can get this error if you first time open a new project (.xcodeproj) with Cocoapods support, run pod update. To fix it just close this project and open created a workspace instead (.xcworkspace )
[Vocabulary]
As for me this problem occurs because i installed Material Library for IOS.
to solve this issue
1: Go to Build Settings of your target app.
2: Search for Other linker flags
3: Open the other linker flags and check for the library which is mention in the error.
4: remove that flag.
5: Clean and build.
I hope this fix your issue.
In my case there was a naming issue. My library was called ios-admob-mm-adapter.a, but Xcode expected, that the name should start with prefix lib. I've just renamed my lib to libios-admob-mm-adapter.a and fixed the issue.
I use Cocoapods, and it links libraries with Other linker flags option in build settings of my target. The flag looks like -l"ios-admob-mm-adapter"
Hope it helps someone else
Simply, GoogleAdMobAds.a is missing in project target.
For me it was libAdIdAccessLibrary.a Please check attached screenshot
In the case of ld: library not found for -{LIBRARY_NAME} happened because the library file(s) is not existing.
Check the library path on your application targets’ “Build Phases”
Library Search Paths tab.
The library file(s) path must be according to the real path for example if your file(s) in the root of the project you must set the path like $(PROJECT_DIR)
I know this is a bit old, but I just hit a similar issue and running 'pod update' fixed this for me. My library error was with AFNetworking...
Just be careful doing pod update if you don't use explicit versions in your pod file.
This error is very weird.
I had this error with -ldAfnetworking and I only copy my project in other path and works.
I tried renaming my build configuration Release to Production, but apparently cocoa pods doesn't like it. I renamed it again to Release, and everything builds just fine.
#raurora's answer pointed me in the right direction. I was including libraries in my "watchkitapp Extension/lib" path. In this case, the Library Search Path needed to be escaped with a '\', but the linker didn't seem to understand this. To fix / work-around the issue, I moved my lib path up one level so it was no longer in a directory that contained a space in the name.
I just update the pod file 'pod update' and it start to work for me normally.
Running 'pod update' in my project fixed my problem with the 'library not found for -lSTPopup' error.
Remarking Trevor Panhorst's answer:
"Just be careful doing pod update if you don't use explicit versions in your pod file."
Easy solution. Here's how I'd fix the issue:
Go to the directory platforms/ios
Then, execute the command pod install
That's it. This should install the missing library.
Cleaned Build Folder
Restarted XCode
Went away...
I was getting similar bugs on library not found. Ultimately this is how I was able to resolve it
Before starting with Xcode Archive, used flutter build iOS
Changed the IOS Deployment Target to a higher target iOS 11.2 . Earlier I had something like 8.0 which was giving all the above errors.
Made sure that the IOS deployment targets in Xcode are same in the Project, Target and Pods
I was also facing the same issue and spent more than 24 hours to solve this, I tried everything from the above solutions but what finally works for me is
Build settings -> Select Target
Basics
User-defined
Change the VALID_ARCHS to arm64
Dude you need a reinstallation.
Delete simply "rm -rf" pods.
Install Pods "bundle exec pod install"
Works well then.
the same here, but in my case was resolved with answer the kenorb

xcodebuild failure clang:error no such file or directory:

Having a problem when building with xcodebuild. My project/app builds fine with the Xcode - gui. It simply isn't finding/building the libcryptopp library which is part of the build process.
The error is:
clang: error: no such file or directory: '/Users/builder/repo/ioskpay/xcode-cryptopp/cryptopp/build/Release-iphoneos/libcryptopp.a'
This particular file should be derived from another project inside the main app - xcodebuild simply isn't correctly pointing at the right file folder which should be:
~/Library/Developer/Xcode/DerivedData
Any ideas?
To fix this, go to your project settings, go to Targets and select your main project target. Then go to Build phases. Under Target dependencies add the static library project.
This way, when you compile the main project, the static library subproject gets compiled before the main project and your static library will be available.
I had the same problem, but for a resource file .m
I opened target -> build phases -> Compile sources
and I found the file the compiler was tell it can't find duplicated: one with strange icon and the other with a normal icon. I simply removed the one with strange icon and it worked. ( I added the file multiple times and I had a merge conflict before that which made something wrong in the project file)
For your case I think you need to remove the lib from target dependencies list and add it again. This may work for you.
In Xcode Version 9.2 (9C40b) this happened when I drug a bunch of files into the project, some of which were duplicate. Rather than simply not adding the duplicates, it added them again and only the name, not the path.
In Target > Build Phases > Compile Sources each of the duplicates showed with no "...in" after them. Each one caused the clang error.
After removing all of the duplicates that Xcode collected, the project compiled and ran.
It makes you use the Project Navigator instead of managing your source files in the Finder. Then the Project Navigator can't replace duplicates like any decent file management system (ahem Finder). 🤨
My xCode info is:
I faced similar errors during xcode building projects (native swift, flutter, react native, native script) in which I got error messages related to clang compilar. Errors like:
clang-4.0: error: no such file or directory: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
clang-4.0: error: cannot specify -o when generating multiple output files
others
Despite of errors related with DerivedData for native apps can be fixed by deleting the directory and, eventually, restart xCode and even restart the machine... in this case, you will see that after deleting the directory and start building process again, the error comes back.
Then, is the moment of checking the clang installation by running clang --version. The normal output will be something like:
as you can see the InstalledDir is incorrect for xCode. In my case, some days ago I needed to install Anaconda app (R, Python, etc) and, now, I remember that I had to install some dependencies and one of them was clang and its installation was altered.
To fix this problem (in my case that I will not need anaconda any more): (edited)
1.- Delete anaconda and all its dependencies (I recommend to use App Cleaner).
2.- Re-install xCode
After reinstalling xCode, if you type again clang --version, you'll get this:
More info at: https://github.com/flutter/flutter/issues/32457#issuecomment-496161092
Hopefully, this info helps some else.
Best
Ok so by simply adding the correct -target -configuration and -scheme parameters I got this to run correctly. However due to my running this in Jenkins for autobuild purposes it still doesn't work as I'd like - getting stuck in exactly the same place. It's odd because I have the exact same code being built in another job that isn't having this problem. There is no rhyme or reason for it at this point. I will keep shooting rubber bands at it and update when I have an answer...
Sometimes Xcode performs weird.
You have to find that static library project e.g.. "filename.a" under 'Link Binary With Libraries' in Build Phase and then remove it and add it again.
I had the same problem while I was archiving my target. I removed the library and the build succeeded.
For me it was because I had removed a package or pod. I ran pod install and it fixed it
Look for the missing file in the Xcode project i.e the files may be deleted or miss placed.
add the missing files to the xcode, then everything will work fine.
Run this command :
$ conda deactivate

Resources