Igo*_*gor 25 xcode linker mach-o dylib ios
从过去xCode 4中的某个点开始抱怨链接器问题:
ld:warning:为MacOSX构建,但是针对为iOS构建的dylib链接:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks//CoreGraphics.framework/CoreGraphics
我已经检查了所有内容,但在配置中仍然没有任何可疑,它编译并运行.我看到它唯一的东西是CoreGraphics.framework之前的双斜线,为什么我不知道.尝试删除并在"构建阶段"上再次添加库,但没有帮助.
有时,通过查看正在使用的命令行的构建日志来调试Xcode问题会更容易.
如果从命令行构建,如果未指定-miphoneos-version-min,则可以获取该消息
This compiles:
(where conftest.c just contains int main() {})
/Applications/Xcode5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -miphoneos-version-min=6.0 conftest.c
And this gives the error:
/Applications/Xcode5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk conftest.c
ld: building for MacOSX, but linking against dylib built for iOS Simulator file '/Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/lib/libSystem.dylib' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
检查您的主要目标和测试目标的框架搜索路径。
我有很多废话。
有用 XCode 4 编写的旧项目,刚刚开始在 XCode 5 中使用单元测试。
这是让我的测试项目运行的最低要求
Project Navigator > click on project at top >
Targets > Build Settings > Framework Search Paths
Run Code Online (Sandbox Code Playgroud)
TARGET:my_project
$(inherited)
"$(SRCROOT)"
"$(SRCROOT)/my_project"
TEST:my_projectTests
"$(SDKROOT)/Developer/Library/Frameworks" <<XCTest.framework is here
"$(DEVELOPER_LIBRARY_DIR)/Frameworks"
"$(SRCROOT)/.."
"$(SRCROOT)" << Documents/my_project
"$(SRCROOT)/my_project" << Documents/my_project/my_project
where directory structure is
Documents/my_project
my_project.xcodeproj
/my_project
Run Code Online (Sandbox Code Playgroud)
注意:如果您将框架拖入 XCode。XCode 5 有硬编码路径的坏习惯
/Users/gbxc/Documents/my_project
Run Code Online (Sandbox Code Playgroud)
应该
"$(SRCROOT)" << Documents/my_project
"$(SRCROOT)/my_project" << Documents/my_project/my_project
Run Code Online (Sandbox Code Playgroud)
所以如果你移动了你的项目可能会遇到问题
检查正确性的最佳方法是创建一个新的单视图项目,该项目可以正常运行测试。
Run the Test action
By default it fails but at least testing is running
then compare the Framework Search Paths.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9379 次 |
| 最近记录: |