问题
Here is the linker error:
i686-apple-darwin10-gcc-4.2.1: /Users/william/Documents/SettingsLibrary/build/Debug-iphonesimulator/libSettingsLibrary.a: No such file or directory Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
A couple of weird things, which may be clues to what is going on:
1) In my "library search paths", I have included the recursive path to the library project:
../SettingsLibrary/**
However, SettingsLibrary builds itself to SettingsLibrary/build/Debug/iphoneos/libSettingsLibrary.a
Meanwhile, based on the error message, the linker appears to be looking in:
SettingsLibrary/build/Debug-iphonesimulator/libSettingsLibrary.a
2) I have included the library project in my main project. When I right click under groups and files, there is an option to include the libSettingsLibrary.a file in my target or not. In at least one other library-using project I have looked at, that checkbox is not there for the .a file.
回答1:
It's difficult to say what the problem is with your project. Can you check the following in the Groups & File view of the main project:
- Does the static library project (SettingsLibrary.xcodeproj) appear as a node below your app (the very first node)?
- Does the library file (libSettingsLibrary.a) appear just below?
- Does the static library (SettingsLibrary (from SettingsLibrary.xcodeproj) ) appear as a node below the main target (at Targets / YourApp)?
- Does the library file (libSettingsLibrary.a) appear just below the node Link Binary With Libraries (in the targets section)?
If not, what's missing?
Furthermore, my Library Search Path is empty. If I look at the command line for the linker, it explicitly contains the full path to the static library (SettingsLibrary/build/Debug/iphoneos/libSettingsLibrary.a in your case).
And the checkbox you mention (right-clicking on the static library project within Groups & Files): I have it as well, but it's not checked.
来源:https://stackoverflow.com/questions/4530886/xcode-cant-find-my-static-library