简体   繁体   中英

Changing the source of a static library needs clean and build in xcode 4

I have an iOS project that is built upon a framework project that we use in different iOS projects. The framework is included in the app project as an xcode project. The app project has a dependency on the framework's static library build target. (Similar to most open source libraries like three20)

The problem is that if I change something in the framework source code the static library is not rebuilt when I build&run the app project.

Doing a clean followed by a build&run the changes are compiled correctly. Doing a rebuild every time I change something in the framework is not a good fix for obvious reasons.

Is there a setting that I have to changed so that xcode is correctly identifying my framework as dirty and builds it accordingly?

I'm using xcode 4.0.2

This is a bug in xcode 4.0.2 (might be fixed in future version). From https://devforums.apple.com/thread/91711?start=25&tstart=0 :

  1. Set static libraries in project, under Frameworks to: Relative to Build Products
  2. Close XCode
  3. Edit project.pbxproj and remove all the path components of the static library so that only the filname remains, like this (the important part is "path = libLibrary.a")

    A74F787413566130000D0AFC /* libLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };

Add a script step where you set your main.m file as modified

#Force dependencies' relink
touch MyProject/main.m

You are possibly missing a dependency between your target and the static library.

In order to add a dependency:

  1. drag/drop the static library Xcode project on your project

    1b. add the library to your app frameworks (I understand that it's already there);

  2. select your target; show the Info pane;

  3. go to Dependencies, click on "+", then select your static lib.

These instructions are valid for Xcode 3.2.x but I hope that based on this you can easily find your way out of this with Xcode 4.

EDIT: For Xcode 4, check this and this (the edited part of the question for a workaround).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM