After upgrading xcode to 8.0, my application project build with error for device target but building successfully for simulator.
Error is like:
ld: library not found for -lcrt1.3.1.o
What does the solution for this error.
After upgrading xcode to 8.0, my application project build with error for device target but building successfully for simulator.
Error is like:
ld: library not found for -lcrt1.3.1.o
What does the solution for this error.
After spending lots time, i finally got the reason for this error.
Error: ld: library not found for -lcrt1.3.1.o
Solution: If your project source have deployment target from iOS 5.0 then change it to iOS 6.0 or later and your error will be fix. Now that work fine for device too.
Hurray!!!
crt1.3.1.o
is a library that was included in older iOSes (and thus, their SDKs) but is no longer present in newer SDKs. However, when the project's Deployment Target is set to an older iOS (<6.0, as @Sandy has found), Xcode still tries linking against it.
To keep supporting iOS 5.x in newer Xcodes, one only needs to copy crt1.3.1.o
from an older Xcode to the appropriate …/usr/lib/
dir in the newer Xcode. Xcode will only use crt1.3.1.o
if the Deployment Target is <6.0— for projects with a Deployment Target ≥6.0 crt1.3.1.o
remains unused and the resulting linked binary is identical to what it was pre-…/usr/lib/crt1.3.1.o
-addition.
To get a newer Xcode to properly link a project with a iOS 5.x Deployment Target:
Download an older Xcode that still has crt1.3.1.o
from https://developer.apple.com/downloads/.
I used Xcode 5.1.1, though any Xcode that has iOS 5.x support should work (which, according to Wikipedia should be Xcode 4.2-6.4).
Open the Xcode .dmg
and on the disk image, locate the file at /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS….sdk/usr/lib/crt1.3.1.o
.
Since I used Xcode 5.1.1, mine was at …/iPhoneOS7.1.sdk/usr/lib/crt1.3.1.o
.
Copy to the same Xcode.app
-relative directory in your newer Xcode: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/crt1.3.1.o
.
My newer-Xcode at time of writing is the latest release, Xcode 8.1 (which out-of-the-box includes the iOS 10.1 SDK and downloadable iOS Simulator support back to iOS 8.1).
Note that you'll need to re-perform these steps after each Xcode upgrade, since the standard Xcode update process is to just blow away Xcode.app
and everything contained within with the updated Xcode.app
.
Also note that I've successfully tested this using Xcode 8.1 to produce an app with a Deployment Target of iOS 5.0 that'll run on both my iOS 10.1.1 iPad Air 2 & my iOS 6.1.3 iPhone 4S. I have not, however, submitted a build using this process to the iOS App Store. While it's unlikely that Apple's certification would have a problem with this (since it is after all their own iOS crt1.3.1.o
library; and since there is no other way to build an app against the latest SDK while still supporting iOS back to 5.x, which is almost certainly something that some enterprise clients are still doing), I can't make a firm promise here.
remove the -lPods-(someCocoaPod) lines in the 'Other Linker Flags' list BUT only if $(inherited) is at the top. At first I was unsure, but the reassuring sign was that I still saw references to my cocoapods when I left the edit mode(inherited). I tested in debug and release, both of which were giving me errors, and the problem was immediately resolved
Instead of using the libraries from an older Xcode install, you can also just recompile them from sources: https://github.com/mringwal/csu-ios