I am looking for a way to add libraries to an Xcode project, using the command line.
I have been successful in adding files to groups with the XCS tool, but it does not support libraries.
I would, for example, like to be able to add CoreVideo.framework to a specific project with a command on the Terminal.
This project can handle frameworks: https://github.com/kronenthaler/mod-pbxproj
Just add it as a normal file, it will figure out the correct type and how to set everything up (i.e., add it to the link library phase – before using it, you still need to import the header(s), of course).
// libFilePath: Path to the framework
frameworkGroup = project.get_or_create_group('Frameworks')
project.add_file(libFilePath,
parent=frameworkGroup,
tree='SDKROOT',
weak=True)
You can decide whether you want to weak-link frameworks (see code example) or not (just leave out the last parameter, it defaults to False
). You can find the code to open/save Xcode projects in the repository.
Another way to do it is adding linker flags directly, e.g., -framework CoreVideo.framework
. If the framework paths are set up correctly, you don't have to provide absolute paths. The disadvantage of this approach is that the linked frameworks aren't obvious if you open the Xcode project, as they are not part of the link library section, nor does the framework show up in any Xcode group in the Project Navigator.
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