I have a project in Xcode 4 (the latest non-beta version) that builds fine when built in Xcode itself. Specifically, the Ld command correctly uses the derived data directory (wh
Check if you didn't import the .m files in your header files! Changing .m to .h fixed this for me!
Personally, I had this issue when I was developing a static library
. I had the static library
target with all the production code, and a test target that pulled in the MyStaticLib.a
file as a framework.
Tests ran just fine in Xcode, but not in the terminal using xcodebuild
. The problem ended up being that the static library
target was compiling for Standard architectures
, while the test target wanted to compile for Standard architectures (including 64-bit)
. Switching the test target to Standard architectures
fixed everything.
All of a sudden I got the same problem after a Clean, at first I panicked wen I watched:
linker command failed with exit code 1 (use -v to see invocation)
... but it turned to be really easy to fix, no command line needed!
I clicked on my project's root (the one on the top with the blueprint icon with an "A") in the Navigator, then clicked the PROJECT section (you can click on the TARGET section as well) and then clicked the button in the bottom-middle called "Validate Settings".
XCode itself validated the project files and told me that the problem was a duplicated target definition, and offered to fix it... and voilá, the problem its gone!
Good luck!
I had a similar exception encountered, it turn out that i got some (null) reference in project.pbxproj after I clean up those null reference in the project.pbxproj, the command line build was success just like the xcode previously does. Take a look at Xcode 4 project: utility to clean up pbxproj file? utility-to-clean-up-pbxproj-file
for more reference
I resolve the issue by going to "Library search path", and make sure all entries are correct.
Ok, so nearly 6 (billable) hours later, I've gotten the build to work correctly in Xcode and on the command line (and on the build server, the whole point of this exercise).
Along the way I would fix one problem just to cause another - I would apparently fix the linker/Ld problem, only to cause problems in compilation ("SomeClass undeclared (first use in this function)" or "SomeHeader.h: No such file or directory" errors were common).
It was one of those times that I adjusted nearly every setting I could find, so it's hard to say what exactly what wrong and what exactly fixed it.
Things I think might have helped are are as follows:
$(BUILT_PRODUCTS_DIR)
$(BUILT_PRODUCTS_DIR)
(recursive)Final build command looks like this:
xcodebuild -workspace ClientName.xcworkspace -scheme AppName -configuration "ProdAdHoc" -sdk iphoneos -arch "armv6 armv7"
Some useful resources I used while debugging this issue:
Anyway, I hope I've peppered enough keywords above that anybody who has any similar build issues in the future stumbles upon this and finds it useful. I have no clue how a workflow I did many times in Xcode 3.x got so messed up when I moved to Xcode 4, here's hoping Apple is able to clean this up in future releases.
This was a heck of a learning experience for me, and going through all of this did seem to clear up issues with autocomplete I was having beforehand. I will say things could have been much worse; I could still be developing for SharePoint.