I accidentally deleted my target in xcode.
so i created a new one with the exact same name. in the target settings i again selected the proper codesigning identity
but now i can't compile for the device anymore. as soon as i want to build, i get:
CodeSign build/Release-iphoneos/myApp.app
....somestuff....
/Volumes/XCodeProj/myApp/build/Release-iphoneos/myApp.app: object file format invalid or unsuitable
Connad /usr/bin/codesign failed with exit code 1
I already tried to clean targets.
what could cause this problem and how to solve it?
May also be an issue with your install. Symlinking to the latest codesign_allocate cleared up the issue in my case:
sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin
In Mountain Lion, you can try to run this before codesign:
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
Make sure the 'Executable Name' (CFBundleExecutable) entry in your target's info.plist matches the 'Product Name' specified in your target settings.
I had this issue when I was trying to codesign from the terminal. I had just installed Xcode 4.4 after uninstalling Xcode 3.0. Took a look at the Downloads in Xcode preferences and noticed that the Command Line Tools had not been installed. My issue was fixed after I installed this. I'm guessing the problem is more complex given the solutions here, but this might be something that future users want to check before they have to start diving deeper.
For me, this was occurring after upgrading to XCode 4.5.
The solution was simply to go to Preferences / Downloads and install the latest Command Line Tools.
I had the same problem and tried all sorts of build settings GCC4.0, search paths etc etc. It turned out to be nothing to do with the build settings in my case the problem was I put a dot in the target name i.e. I was targeting v3.0 SDK so I called the target Granade3.0.
I started a brand new project named "Grenade3zero", imported the sources from the original, fixed the appdelegate name to match the project name etc. build and go and it loaded first time onto the device and the simulator was also fine when I checked it. Looks like some characters are illegal in target names!
Thought I'd add my solution to this problem too... I've been struggling for a couple of weeks with this problem... having checked ALL the solutions above and changing more.
My solution was in the target build settings.
I had put in two options, armv6 and armv7. I changed this back to one single entry of normal and it built!
emcmanus answer worked for me but since Xcode 4.3 is now installed in the Applications folder and I removed the old /Developer folder, I had to change the path to codesign_allocate:
sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin
I tried all the above to no avail. What worked for me was to add the following to my build script:
export
CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
I came across this post while researching my problem:
http://mobiledevelopertips.com/mac-osx/code-signing-error-object-file-format-unrecognized-invalid-or-unsuitable.html
For Mountain Lion before starting signing process Please run below command as first command.
For Xcode 4.x:
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
For XCode 5:
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"
Faced a similar issue in Jenkins running on Mountain Lion and Xcode 5.x.x without any command line utilities.
since the command line utilities are now bundled with Xcode 5.1.x
the following worked
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate /usr/bin/
Go to 'Build Settings'
Go to 'Build Options' tab
Inside of the build options tab go find 'Debug Information Format' and change it's value from 'DWARF' to 'DWARF with dSYM File'. Should be in the dropdown.
It should work for you guys.
If your app has special characters in the Product Name in the target build settings, remove them.
For example, rename "Mat's app" to "Mats app" and it will build. You can of course have special characters in the display name.
I also had the same problem, and the cause was that my app target was linked to a static library and didn't provide its own source files (all sources were in the library and the app target only provided resources). Once I moved out one of the sources from the library to the app target, it fixed the code sign error.
I think that it was cause by one of Xcode DP(developer preview).
It could change default Xcode.app Path to Xcode DP.
So, U can check Xcode path by xcode-select --print-path
If U got some wrong directory then U could change path by xcode-select --switch
check this thread.
change xcrun developer path
It is better to use xcrun to locate the correct version of codesign_allocate as it can be different depending on whether it is an OS X binary or iOS.
This also allows Apple to change the location of various tools without breaking your script.
Use something like:
export CODESIGN_ALLOCATE=$(xcrun --sdk iphoneos --find codesign_allocate)
I would get the error when trying to sign my OS/X (not iOS) application with a digital certificate my company purchased from a root Certification Authority different from Apple. The problem would occur whenever I downloaded the certificate via Safari. Downloading the certificate using Firefox helped me get rid of the error.
Related
After upgrading Xcode to v5.0.1, I started receiving following warning in terminal when trying to run git commands inside project folder:
[MT] PluginLoading: Required plug-in compatibility UUID
37B30044-3B14-46BA-ABAA-F01000C27B63 for plug-in at path
'~/Library/Application
Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin' not present
in DVTPlugInCompatibilityUUIDs
I am not getting any warning inside Xcode and the project is compiling just fine but there must be a reason. Any ideas why is this happening and how to fix it?
I modified a shell commands I found here to fix this for all my plugins.
To fix this issue:
XCODEUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
for f in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*; do defaults write "$f/Contents/Info" DVTPlugInCompatibilityUUIDs -array-add $XCODEUUID; done
Try to do : xcode-select --install. It resolved my problem
In my case of Xcode 7, remove all Xcode plugins fixed my issue.
rm -rf ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*
I believe the issue is that you have an Xcode plugin installed that has a missing (or has an incorrect) DVTPlugInCompatibilityUUIDs key-value pair in its plist file. See what this plugin did to solve it: https://github.com/gfontenot/XVim/commit/35bbf24bc074e330a9bea852c190d8fdcbfff1ea
Maybe check if your plugin (looks like it's for Unity) has an updated version.
I had deleted unity from my machine. After installing unity the builds worked for me. I was trying to build an app using robovm.
Maybe it is a bit late, but I had just to restart Xcode after an Xcode update and press the install components button when it showed up. Then my git problems were gone.
I've recently stumbled upon a rather odd problem with Xcode which occurs when I build an IPA and attempt to install it, I've tried installing using Xcode, iTunes and iPhone Config Utility, all of which give the same error
A signed resource has been added, modified, or deleted.
I can successfully debug the app on my phone using XCode, it's only when I try to install an IPA I see the error.
I've tried unzipping the IPA and running the codesign validation tool which throws up the following response:
a sealed resource is missing or invalid In architecture: armv7
resource missing:
/Users/dev1/Documents/PoleTester.app/Settings.bundle/._Root.plist
This led me to look at the Settings.bundle file and ensure that it's being included in the build, which it is. Interestingly though, if I remove the Settings.bundle file, build an IPA and attempt to install it on my iPhone the install succeeds, however this of no use as I need the Settings.bundle file installing with the app.
Further investigations on some of my previous XCode projects has shown that I can build an IPA, with the Settings.bundle file included, and successfully install it. However, if I make a simple change to the Settings.bundle file, such as adding or removing a row, build an IPA and then attempt to install it I get the
"A signed resource has been added, modified, or deleted" error.
I'm at a bit of a loss as to what's causing this error and why the Settings.bundle file is causing the install to fail.
Has anyone seen this error before or potentially shed some light on what's causing it?
I'm using Xcode 4.6.3 and an iPhone 4 running iOS 6.1.3.
Clean Build Folder (⌘⌥⇧-K) has resolved this for me 3 out of 3 times.
I just ran into this issue using Xcode 6 beta 6 installing to my iPhone 5 running iOS 8 beta 5. The app I'm building uses a Today extension (aka widget).
It appears the issue stemmed from my having not set up dependencies properly. I have a third party framework (Alamofire) set up as part of the project as a dependency of the overall project, but not as a dependency of the today widget. I could build fine but when installing to device I would get this "signed resource has been..." error.
By adding Alamofire as a dependency of the Today widget this resolved the issue.
It's a bit late but I ran into the exact same issue today with Xcode 5.0.1.
According to https://developer.apple.com/library/ios/technotes/tn2318/index.html, "the resource missing: my.app/..*" error could be caused by:
The file prefixed with "._" is considered an AppleDouble file and it can result from copying the uncompressed Xcode project folder onto a non-HFS+ formatted disk. The AppleDouble files must be removed using the 'dot_clean' command. The Xcode project folder is the argument to dot_clean as illustrated below.
Steps I did to resolve this:
Close Xcode
Run "dot_clean /path/to/My_Xcode_Project" in Terminal
Open Xcode again and make a new build
Oddly enough most of these _* files don't seem to cause any issues except those inside Settings.bundle (Nearly every file in my directory had one, but only after I added Settings.bundle, the IPA failed to install).
I also faced the same issue and this post solved my problem:
http://code-ninja.org/blog/2012/04/17/signed-resource-has-been-added-modified-or-deleted/
It turns out that the problem was caused by having special character in the product name – in my case, a ?. Removing the ? from the product name fixed the problem.
In my case, what helped was adding a bash script into build phases (just before "compile sources"):
find ~/Library/Developer/Xcode/DerivedData -name "YouAppName.appex" | xargs -I % find % -type f -maxdepth 1 | xargs rm
What this script does, is to clean files in project's appex dir (e.g. assets), but leaving sub-directories (e.g. compiled storyboard). In effect, using this script while building is much faster to execute than full project clean.
I used a cocoa static library in my application. When I compile my library I got the following error:
Shell Script invocation error:can't open input file:
/Users/sijuthomas/Library/Developer/Xcode/DerivedData/SCXML2-
bbttehupryhijphhjdiemcytkvgy/Build/Products/Debug-iphonesimulator/
libSCXMLParser.a (No such file or directory)
Command /bin/sh failed with exit code 1
How can I fix this?
Click On Run checkbox if not selected.
I had this issue because i denied keychain access and in order to solve it you need to open keychain,
Then click on the lock on top right of the screen to lock it again,
after that you can archive and it will work
Deleting "Derived Data" worked for me.
In Xcode go to File > Workspace Settings > Click the arrow next to the Derived Data file path > move the "Derived Data" folder to the trash.
Seems you are running a shell script and it can't find your specific file. Look at Target -> Build-Phases -> RunScript if you are running a script.
You can check if a script is running in your build output (in the navigator panel). If your script does something wrong, the build-phase will stop.
I had same issue got it fixed. Use below steps to resolve issue in Xcode 6.4.
Click on Show project navigator in Navigator window
Now Select project immediately below navigator window
Select Targets
Select Build Phases tab
Open Run Script drop-down option
Select Run script only when installing checkbox
Now, clean your project (cmd+shift+k) and build your project.
Cleaning the build folder (Cmd + Shift + Alt + K) worked for me
1) Delete the pod folder and .xcworkspace file
2) Open the folder in terminal
3) Type "pod install"
Did you add the .a library to the xcode projet ? (project -> build phases -> Link binary with libraries -> click on the '+' -> click 'add other' -> choose your library)
And maybe the library is not compatible with the simulator, did you try to compile for iDevice (not simulator) ?
(I've already fight with the second problem, I got a library that was not working with the simulator but with a real device it compiles...)
In My case there was space in the path that was failing the script.If you are using variables like $PROJECT_DIR or $TARGET_BUILD_DIR then replace them "$PROJECT_DIR" or "$TARGET_BUILD_DIR" respectively.After adding quotes my script ran successfully.
For me, my certificate is expired. I have created a new certificate.
I did all above and spent an hour on the issue.
Tried everything above as well as restarted Xcode.
Finally, restarted computer and everything working normally again!
I tried restarting Xcode (7) and nothing (the have you tried switching it off and on again of iOS development for me :-)). I then tried by restarting my box and that worked.
In my case the script was failing when copying a file from a location to another one. I think it could have been related to Finder screwing with writing rights over certain folders.
For me this error was occuring because I changed the version number from 1 to 1.0 and build number from 6 to 1.1 as I pulled the code from source tree. I just changed it back and changed the build number from 6 to 7and it worked fine.
just put your script in a file and run that file with 2>/dev/null at the end of command line!
This way, if there is a problem with the command whatsoever, it will not halt your xcode build
in my case I was running just a command to uninstall my previous copy of the app from a connected iphone, so it could give an error if the iphone is not there. To solve it:
$mobiledevice uninstall_app com.my.app 2>/dev/null
The only thing worked for me:
1) Delete Derived Data with CleanMyMac: System Junk -> Xcode Junk -> Xcode Derived Data
Deleting Derived Data with CleanMyMac
2) Then in Xcode: Product -> Clean
I'll list things I did that did not work for me and finally what did
First, the accepted answer of Run script only when installing did not work.
Deleting derived data did not work.
What did work:
I added a new build phase in Build Phases
New Copy Files Phase
Drag & Drop the chosen framework into the drop target
Set the 'Destination' to Frameworks
Credit due to Kevin Le's Medium post
For those who doesn't want to uncheck that option (using cocoapods for example), the problem might be with the certificate/key.
Xcode (or whatever tool you are using, like a command line tool) needs to be able to use the certificate/key from the keychain. For this open the Keychain, locate the certificate that you want to use (Usually on login keychain, My Certificates), right click on the key, select Get Info, click on Access Control tab and add the app to the list.
If this doesn't work, try unlocking the keychain.
Another option can be select Allow all applications to access this item instead of specific apps and/or move the certificate/key to System keychain which is shared between all the user accounts on that Mac.
Also check that the certificate is not expired.
1) option :
2) option : pod update, clean derive data,
In my case, one of the script (related to SwiftGen) was failing during compilation.
I fixed the issue by removing the Pods and then updating them again.
Remove the problematic pod under Pods directory or use pod deintegrate
Install / Update the pods using pod install or pod update
P.S. It is possible your dependency is Global and is not in pods. In that case you can also try to reinstall that dependency.
READ THIS IF YOU USE Crashlytics AND ARE HAVING THIS ISSUE...
I was having the same issue as above Command /bin/sh failed with exit code 1 more specifically [31merror: Could not fetch upload-symbols settings: An unknown error occurred fetching settings.[0m
The first solution (enabling the run script only when installing) allowed me to build my target in the simulator, but I could not archive my build.
I solved this Archive issue by enabling Crashlytics on firebase. I am still used to Fabric where Crashlytics is automatically enabled. Once I enabled Crashlytics in the firebase console for the corresponding GoogleService-Info.plist I was able to Archive without this error.
Remove all pods and install again.
Steps:
comment all pods and run pod install
uncomment all pods and run pod install
While attempting to debug a build created using the 3.2 SDK on an iPhone device I receive the message "A signed resource has been added, modified, or deleted.".
I can clean, rebuild, then install with no error, but if I try to install without cleaning the error shows.
Anyone have an idea as to what might be causing this?
I found a workaround for the bug.
If you delete the .app file in build/Debug-iphoneos/ before building for the device, the app gets installed without errors.
And there is a simple way to do that before every build.
Make sure you have selected "Device" in the dropdown overview menu.
In XCode go to Project > New target...
Then find "Shell Script target" under MacOSX/Other
Name it and add it to the current project
Now, in the left navigation panel, under targets, expand your newly created target and double-click on Run Script.
In the window that opens replace "# shell script goes here" with "rm -fr build/Debug-iphoneos/*.app" (without the quotes).
Now open your main target preferences and under Direct Dependencies add your newly created target.
Build and Go! :)
This error occurs when there is a special character in the Product Name. In my case it was a "?"
If you change the Product Name it automatically updates the "Bundle Name" and "Bundle Display Name" so it is often the best choice to rename an app.
If you want to include special characters in the app name you have to manually rename the "Bundle Name" and "Bundle Display Name"
Bundle Name: This is the actual app bundle name in the file system such as "Awesome App.app". It is generally not visible to the user.
Bundle Display Name: This is a short name displayed under the app icon on the device. Since the bundle name would be truncated to "Awes…tion" you have the option to have a shorter name which fits better such as "Awesome App". It should be similar to the App Store name (set in iTunes Connect)
This is pretty clearly a bug in the 3.2 SDK, but I don't want to downgrade. I've found that doing a Clean by pushing Command+Shift+K, then Return is pretty fast before pushing Command+R to build.
Xcode 8, reason of the "A signed resource has been added, modified, or deleted." was that target was signed with an enterprise provision profile.
In my case, it happened when no changes were made. Make a change to any file and run again.
This can have several causes. The fastest way to figure out what is causing it is to go into Xcode, Window menu, Devices, then click the reveal button at the bottom of the pane to show the Console. Now attempt to run. You should see log output that names the specific files it is complaining about.
Most of the solutions previously posted are just artificial ways of getting Xcode to regenerate the contents of the build folder and/or re-sign the files.
In my case, my WatchKit extension was somehow acquiring references to Cocoapods frameworks that were only targeted toward the main app so they got signed during the build, then pruned later (as they were not used). Then on device, iOS complained that they were missing from the .appex folder for the extension. I ended up not needing any pods in the extension so I just removed them all and removed the extension as a target, then did some minor cleanup to remove the pod-related debris left in the build steps. Now everything works perfectly.
(SOLVED) This is a weird one. I tried everything I could find. Eventually I changed the product name from "Unit Tests (device)" to "Device Unit Tests" - removing the brackets. Now everything works. The spaces in it appear to be fine.
Previously on stackoverflow:
I've just run into this bug with two static library projects. One builds and tests using the GHUnit test runner on the device without a problem. The other projects will not install and gets this error. That means it's something thats different between these two projects. I've so far tried wiping the build directory, taking spaces out of the executable name, and various clean and builds as suggested here.
Same for me, thought it has something to do with multiple targets etc. because I changed a lot there. But it's highly possible that it's a Bug in the 3.2.2 release since I did not test extensively in this sdk version before the massive target changes in my project.
solved my issue!!!
I found out by accident that somehow a space " " found it's way into the Product Name of my app so it was called "First Second.app" instead of "FirstSecond.app". After deleting the space the issue was gone!
I changed it here:
right click on target
Get Info
Build Tab
Packaging Section
Product Name <- The name here will be used for the bundle (.app) name
Hope this helps, let me know!
Cheers,
nils
I could solved by changing project name.
[project]-[Rename] menu. "phase1 (new)" -> "pahse1"
I was getting this same error, but intermittently. I tried all the above and it still didn't work. Today I found what was causing it.
The error seems to occur when editing a xib in interface builder. If you try to run while the interface builder is open in xcode it will cause the above error. To solve just close the interface builder editor. i.e. just select a code file from your project so you are in the Source Editor.
The simplest (and probably most common cause) appears to be rebuilding without any changes.
So the simplest thing to cure it is to make a trivial change to a source file (such as adding a space, then deleting it), and then rebuilding.
If this doesn't work, feel free to try all the other answers here.
For months, I'd get this error without realizing it was due to such a simple cause. I'd usually do a Clean Build to get rid of it.
When I created ipa through terminal using xcodebuild commands, ipa created but while installing it I was getting same error. exportOptionsPlist solved my issue.
xcodebuild -exportArchive -archivePath projectPath/myapp.xcarchive -exportPath projectPath/myApp.ipa -exportOptionsPlist ProjectFolder/exportPlist.plist
In my case, Quit and restarting XCode worked.
For me the issue was related to the provisioning profile settings. The clue to this was that debug builds were installing ok, but release builds were not. I wanted to test a release build, so I ran the scheme with that build configuration.
I fixed it by duplicating the Release Configuration, then modifying those fields in the Build Settings to have the same provisioning stuff as if I am debugging it.
(Adding another build configuration will give you headaches if you are using Cocoapods however, then you'll have to modify your Podfile)
I'm getting the same thing, when installing on a iPod Touch. I can't link for the simulator (for other reasons), so can't say whether the problem occurs there.
Yes, rebuilding clean or deleting the app from the device allows me to install again. Neither are desirable, iterative solutions!
The minimal "cleaning" I've come across as a work around is manually deleting the Foo.app in the build/Debug-iphoneos directory.
it seems this is a bug in xcode 3.2.2:
iphonedevsdk
I had the same problem in Xcode 3.2.1 when I put a + in my app name. Specifically the "product name" in the build settings. It is fine to have a + in the bundle name in your Info.plist. The same probably applies to other punctuation characters.
Go to Window > Organizer > Projects > Find your project and delete derived data
I got this error intermittently while installing app using iPhone config utility on Windows7. Following solution works - Go to C:\Users\{lanusername}\AppData\Local\Temp and delete app specific folders (e.g. abc.app) and try installing app again.
I reported this bug on ICU (Windows versions) to Apple in June 2011. With the following workarounds:
The workaround is this ....
Win XP
1) Close ICU
2) Delete the temp folder: c:\Documents and Settings\[username]\Local Settings\Temp\[AppName].app
3) Delete the deploy folder: c:\Documents and Settings\[username]\Application Data\AppleComputer\MobileDevice
4) Restart ICU. Drag in the App and install normally.
============================
Win 7
1) Close ICU
2) Delete the temp folder: c:\Users\[username]\AppData\Local\Temp\[AppName].app
3) Delete the deploy folder: c:\Users\[username]\AppData\Local\Apple Computer\MobileDevice\Applications\[AppName].app
4) Restart ICU. Drag in the App and install normally.
=========================================================
I simply rebuilt my app, and that solved the issue.
I also faced the same issue. After wasting lot of time I realized that my product name has a special character "?" which cased the problem
Having the DerivedData folder at a network location caused this problem for me.
After trying everything else, I found out my workstation couldn't agree with the University server about what the time was. (It thought everything was always modified). I also had to clean for every rebuild to avoid that frustrating message.
In the end I gave up and built locally, changing Xcode > Preferences > Locations ... feeling altogether pretty dumb for having ever built over the network.
We ran into this issues on XCode_6.3.1. We were building a AppleWatch app, with an extension. We do have a bunch of Pods.. After debugging the issue for almost a bunch of hours, what we found was that there was an issue with the way a file was adde to the project..
It seems like some references to a unused file was sitting in the iPhone App, though it was used in the Watch App.. It turns out that the error XCode was showing was totally useless.
After removing this file and re adding it back to the project the project started working fine & was able to install to the device. To make it even harder to debug the issues, the debug version was installed without an issue, but was unable to install the norman version..
Make sure you add your files to the right target and, look at git history and see if there are lingering fragments that are added to the wrong target.
This is a very general error message indicating something is wrong during the validation process of the code signature. To find out the specific error, you can go to Xcode->Window->Devices and check your device log.
In my case, I have following console spew
Feb 1 18:53:07 iPod-touch installd[40] : 0x1001f8000 -[MICodeSigningVerifier performValidationWithError:]: 192: Failed to verify code signature of : 0xe8008017 (Signed resources have been added, removed, or modified)
Check on this 3rd party framework again, I found an extra CodeResources file under the framework root. Remove that file fixed the problem.
Just upgraded to Snow Leopard, installed Xcode 3.2, then installed iPhone SDK 3 for SL.
In a project, I now get the following error on build:
ld: library not found for -lcrt1.10.6.o
I've searched around the net, but nothing helpful can be found.
Edit Project Settings -> In the build tab -> For Mac OS X Deployment Target, change it to 10.5 for XCode 3 (not 10.6 even if on 10.6) and see if that helps.
For XCode 4, you'll need to set it to 10.6
P.S. Make sure you set that for all targets, not just release or debug. (if you didn't, one would fail, the other wouldn't)
Add the following to ~/.profile (for Mac OS X 10.5):
export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
I was able to fix this problem by adding the following to my Makefile:
CFLAGS="$(OTHER_CFLAGS) -mmacosx-version-min=10.5"
LDFLAGS="$(OTHER_LDFLAGS) -mmacosx-version-min=10.5"
Ostensibly, this is only required when building outside of Xcode. This problem frustrated me long enough that I figured it would be useful to share my experience here.
It looks like you're picking up libraries from /usr/lib, which is wholly inappropriate for the iPhone SDK. I would assume you've changed your build settings to add /usr/lib to the library search paths. This should be completely unnecessary in the first place, as /usr/lib is in the compiler's standard search paths, but if you need to have a modified search path like this, make sure to use $(SDKROOT)/usr/lib instead.
Setting deployment target to compiler defaults solved the problem. Don't change anything else.
The compiler normally uses crt1.o combined with crt[i/n].o and crt[begin/end].o to support the constructors and destructors (functions called before and after main and exit).
This error could be caused by this missing library file for the specific deployment target.
First, do some investigation, like:
List all your deployment targets:
ls -la /Developer/SDKs
Find which crt1 libraries do you have for which environment
find /Developer/SDKs -name crt1\*
You could see something like:
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.o
As you can see in above example, crt1.10.6.o is missing for MacOSX10.5.
Solution 1
You can solve that by creating the link to the missing file pointed to the other environment, or you could change your deployment target.
E.g.
ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o /Developer/SDKs/MacOSX10.5.sdk/usr/lib/
Other reason why it's missing, is that you could have different gcc installed in your system. E.g.:
which gcc
xcrun -find gcc
brew list | grep gcc; brew list gcc47
Solution 2
So when you're compiling using make, you can actually specify the right compiler by CC variable. E.g.
CC=/path/to/gcc-3.4 make
Solution 3
What you can also try is specifying the right target deployment environment variable for gcc, e.g.:
export MACOSX_DEPLOYMENT_TARGET=10.5
If this works, then you can add this library path to your shell profile (~/.profile).
E.g.
export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
Or by temporary exporting them.
How to test
Create the example conftest.c file with the following code:
#ifdef __GNUC__
yes;
#endif
And try to compile it via:
gcc conftest.c
cc conftest.c
cc conftest.cc conftest.c
Wasted few hours on this one...
Interestingly, for me the problem was only for Simulator-Debug.
It wasnt complaining for Simulator-Release or Device Debug/Release!
anyway, Changing Deployment Target to 10.5 solved this for me!!
This problem solved by setting Mac OS X Deployment Target to 10.5 and after this set back to Compiler Default :)
I had this problem when I was using Xcode 4 on one machine and Xcode 3.2.6 on another. The two versions are supposed to be able to swap .xcodeproj files between them but I found that in the project.pbxproj file (inside the .xcodeproj directory), there were still a couple of places that read:
MACOSX_DEPLOYMENT_TARGET = 10.6;
I quit Xcode and went and changed the three occurrences to:
MACOSX_DEPLOYMENT_TARGET = 10.5;
After reopening the project, I could build again. Whew!
I had the same error message, none of the above solutions worked for me. I resolved it by deleting the *.pbxuser and *.mode1v3 files inside the xcodeproj file.
Control/click the xcode *.xcodeproj file
Select the "show package contents" option from the menu
A window will open with the contents
Delete the pbxuser/mode1v3 files that start with your user name
Rebuild the project
I had the same issue in a Fortran Makefile.
Added the following option after the compiler (For OSX 10.5):
-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib
e.g.,
g77 -L/Developer/SDKs/MacOSX10.5.sdk/usr/lib
Now the compiler will find the library you want !
Add the following to ~/.profile (for Mac OS X 10.5):
export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
Given Kirandan's limited scenario (Snow Leopard, Xcode 3.2.1, iphone, library path error), Stefan's answer (above) worked for me, except my exception was with 10.5 (-lcrt1.10.5.o).
Elsewhere, I'd seen an answer by Gabor Cselle (author of reMail), and he fixed this specific issue by using a symbolic link (someone referenced this page, by the way), but he noted this was not the best way.