I am fighting with Xcode 4 workspaces. Currently Xcode 4 wins. Thus, my situation:
I have the workspace with the iOS app project. There is also static library project iOS app depends on in the this workspace.
I try to configure like this:
libmystaticlib.a
);USER_HEADER_SEARCH_PATHS
to $(TARGET_BUILD_DIR)/usr/local/include $(DSTROOT)/usr/local/include
;SKIP_INSTALL
to YES
.And important thing: both projects must have configurations named the same. Otherwise, if I have, e.g., configuration named Distribution (Ad Hoc) for the app and Release for the static library, Xcode can't link the app with the library.
With this configuration archiving results to an archive with the application and public headers from static library projects. Of course, I am not able to share *.ipa
in this case. :(
I have also tried another configuration:
ADDITIONS_PROJECT
;libmystaticlib.a
);USER_HEADER_SEARCH_PATHS
to $(ADDITIONS_PROJECT)/**
;SKIP_INSTALL
to YES
.I still need to care about configuration names for both projects. But in result I can build and archive successfully. In the result I get archive and I can share *.ipa
.
I don't like the second solutions, because in this case I don't get any real advantage of the Xcode 4 workspace. The same effect I can add get, if I add the static lib project inside the app project. Therefore, I think something is wrong with my solution. Any suggestion how better to link a static libraries?
A static library is a collection of compiled object files combined into a single library file, that may be linked into an app or framework target just like single object files are linked.
Static framework contain a static library packaged with its resources. Dynamic framework aka Embedded framework - from iOS v8 - contains the dynamic library and resources. In addition to that, dynamic framework can include different versions of the same dynamic library in a single bundle ( versioned bundle ).
To create a workspace and add projects to it: In Xcode, choose File > New > Workspace. Specify a name for the workspace and save it to the file system. In the Project navigator, Control-click in the empty space and choose Add Files to “workspaceName”.
I also found a solution that works with build and with archive.
In your static library set the Public Headers Folder Path to ../../Headers/YourLib
In your app config set the Header Search Paths to $(BUILT_PRODUCTS_DIR)/../../Headers
In your app you will be able to code #import <YourLib/YourFile.h>
Don't forget the Skip Install = YES
option in your static lib.
We've found an answer, finally. Well, kind of. The problem occurred because Xcode 4 places public headers into InstallationBuildProductsLocation folder during build for archive. Apparently, when archiving it sees the headers and tries to put them into archive as well. Changing Public Headers Folder Path of the lib to somewhere outside of InstallationBuildProductsLocation, for example, to $(DSTROOT)/../public_folders and adding this path to Header Search Path solve the problem. This solution doesn't look very elegant, but for us it seems to be the only option. May be you'll find this useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With