Xcode 4 中的跨项目源代码参考
我知道你可以让 Xcode 引用其他项目中的框架/静态库构建目标,但是如果你要引用的项目没有框架/静态库目标,你可以直接引用另一个 Xcode 项目的源代码吗?我尝试使用子项目和 Xcode 4 工作区来执行此操作,但无济于事。调整标头搜索路径后,所有 #import 语句都可以正常工作,但我仍然遇到讨厌的编译器错误,报告未找到符号。
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Products/Debug -F/Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Products/Debug -filelist /Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Intermediates/.build/Debug/.build/Objects-normal/x86_64/.LinkFileList -mmacosx-version-min=10.7 -fobjc-arc -framework Cocoa -o /Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Products/Debug/.app/Contents/MacOS/
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MagicalRecordHelpers", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_MRCoreDataAction", referenced from:
objc-class-ref in ItemsArrayController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
另外,这个新的 Xcode 4 工作区有什么用?它与子项目到底有什么不同?我唯一能发现的是它们在视觉上看起来不同...
工作区
子项目
I know you can have Xcode refer to framework / static lib build targets in other projects, but if the project you want to refer to doesn't have a framework / static lib target, can you directly refer to source code from another Xcode project? I tried to do this using both sub-project and Xcode 4 workspace to no avail. After adjusting the header search path, all the #import statements work correctly, but I'm still getting nasty compiler error repotting symbols not found.
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Products/Debug -F/Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Products/Debug -filelist /Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Intermediates/.build/Debug/.build/Objects-normal/x86_64/.LinkFileList -mmacosx-version-min=10.7 -fobjc-arc -framework Cocoa -o /Users/Tony/Library/Developer/Xcode/DerivedData/-bewprsseyzwgmsdpwvjfuzjiilap/Build/Products/Debug/.app/Contents/MacOS/
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MagicalRecordHelpers", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_MRCoreDataAction", referenced from:
objc-class-ref in ItemsArrayController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Also, what's the deal with this new Xcode 4 workspace? And how exactly is it different from sub-projects? The only thing I could find is that they look visually different...
Workspace
Sub-projct
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个问题的答案显然是“No Xcode无法引用另一个项目中的源文件”。为了编译源文件(.m 文件)。 Xcode 项目必须保存对它们的直接引用。您可以进入目标设置->构建阶段 ->编译资源看看会编译什么。请注意,除非文件直接添加到项目中,否则它们不会显示在要编译的资源下。然而,标头可以在不同的项目之间进行通信。
编辑
我认为第二个问题的答案是,虽然 Xcode 3 始终需要显式管理依赖项,但 Xcode 4 工作区允许隐式管理目标依赖项,只要它们都在同一个工作区中即可。指定依赖性所需要做的就是在摘要页面中添加您想要引用为链接库的其他项目的产品。这些发现花费了太长的时间..(一个完整的富有成效的工作日),有关此的文档可以而且绝对应该改进!
The answer to the first question is apparently "No Xcode cannot refer to source files in another project". In order to compile a source file (.m files). Xcode project must hold direct references to them. You can go to Target setting -> Build Phases -> Compiled resources to see what will be compiled. Note that unless files are added to the project directly, they will not show up under resources to be compiled. Headers however can be communicated across different projects.
EDIT
And I think the answer to the second question is that whereas Xcode 3 requires always explicit management of dependencies, Xcode 4 workspace allow target dependencies to be managed implicitly, so long as they are all in the same workspace. All that is required to specify dependency is to add a the product of the other project you want to refer to as a linked library in the summary page. These findings took much too long.. (a full productive workday), documentation on this can and should definitely be improved!