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.)
If you're building for iOS, tvOS, or watchOS: On your application targets' “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.
Static library: A unit of code linked at compile-time, which does not change. (Can only contain code). The code that the app uses is copied to the generated executable file by a static linker during compilation time. However, iOS static libraries are not allowed to contain images/assets (only code).
Question: Can we create static frameworks using Swift? Answer: Finally, YES! (Xcode 9). CocoaPods announced the support of Swift Static Frameworks in 1.5.
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.
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