Cross-Project source code reference in Xcode 4
Asked Answered
L

1

6

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

enter image description here

Sub-projct

enter image description here

Lynlyncean answered 3/1, 2012 at 9:32 Comment(0)
L
6

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!

Lynlyncean answered 3/1, 2012 at 21:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.