alloy
alloy

Reputation: 21048

Make Xcode automatically link against the libraries needed by objects in static library

I have a xcode project with a target that builds a ‘Cocoa Touch Static Library’, the user can successfully depend on this project from her app project and link against the library.

However, some of the objects in the archive depend on other libraries, so the user has to add these to the app project herself. Is there a way with Xcode to eliminate this step? I.e. can I specify in the library’s project on which libraries it depends which are then automatically linked in to the app? (In the library project, or as a xcconfig file, or whatever works.)

Upvotes: 10

Views: 2996

Answers (2)

alloy
alloy

Reputation: 21048

I’ve ended up going with a xcconfig that the user's app target configurations are based on. This xcconfig contains:

USER_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)
ALWAYS_SEARCH_USER_PATHS = YES
OTHER_LDFLAGS = -framework SystemConfiguration -framework CFNetwork -framework MobileCoreServices -l z.1.2.3 -l xml2.2.7.3
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2"

This together with the library in a workspace together with the app makes it all work.

Upvotes: 6

alloy
alloy

Reputation: 21048

It seems that the ‘Fake Framework’ template from https://github.com/kstenerud/iOS-Universal-Framework might do the trick, although apparently it will introduce a warning in the user’s project build… :-/

Haven't tried it yet, though, so if you know other/better ways (without generating a warning) please do tell.

Upvotes: 0

Related Questions