Search code examples
iosxcodexcode4workspacexcode4.5

Xcode 4.5: dependencies not updated when using workspaces


I installed Xcode 4.5 today and I have the following problem:

I use workspaces to develop a library and app simultaneously. When I change something in the library and build the app, the library gets rebuilt with the new changes. This works fine in Xcode 4.3/4.4. However, since Xcode 4.5 this doesn't seem to work anymore. I always have to "Clean" the project, otherwise changes are not visible, although the targets are built in correct order (lib, app).

Has anyone experienced the same? Does a workaround exist?

-Alexander


Solution

  • Here's one possible cause of this (there's probably others):

    Make sure the Identity and Type inspector is showing and select the libWhatever.a file in your application's project (not the library). If you see Location: Relative to Project, this is your problem.

    • Click Relative to Project and change it to Relative to Build Products.
    • This will change the type of the link, but it will still be broken.
    • Click the locate button and find the output file.

    Honestly, you're probably better off editing the pbxproj directly. Your patch will look something like this:

    Index: App.xcodeproj/project.pbxproj
    ===================================================================
    --- App.xcodeproj/project.pbxproj     (revision 28061)
    +++ App.xcodeproj/project.pbxproj     (working copy)
    @@ -28,7 +28,7 @@
    
     /* Begin PBXFileReference section */
               A7052F8F1358BFCC00178DAC /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
    -          A74F787413566130000D0AFC /* libLibrary.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libLibrary.a; sourceTree = SOURCE_ROOT; };
    +          A74F787413566130000D0AFC /* libLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };
               A74F787D135665A3000D0AFC /* Macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Macros.h; path = DslExt/Macros.h; sourceTree = "<group>"; };
               A74F787E135665A3000D0AFC /* Foundation-dsl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "Foundation-dsl.m"; path = "DslExt/Foundation-dsl.m"; sourceTree = "<group>"; };
               A74F787F135665A3000D0AFC /* Foundation-dsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Foundation-dsl.h"; path = "DslExt/Foundation-dsl.h"; sourceTree = "<group>"; };
    

    I found this answer here:

    What's the correct way to configure XCode 4 workspaces to build dependencies when needed?