Search code examples
iosstatic-librariescommand-line-tool

add static library to xcode project from command line


I have a static library containing libSomething.a and two.h file which i have to include in my xcode project for doing a specific task . I want to attach the library to xcoce project from command line is there way to do that ? thanks in advance


Solution

  • Not a directly command line way, but you can write a ruby script to do the trick. You can use a gem called xcodeproj to edit the Xcode project file.

    For adding a .a library, you may want to create an Project object with the path of your project file, then use the new_file method of the Project class to add it to the project. It is equivalent to dragging the same file to Xcode. For the header file, you can either add them as new file to the project (the same as the library) or just set the HEADER_SEARCH_PATHS key of the Xcodeproj::Project::Object::XCBuildConfiguration of the project object.

    For more information and usage of xcodeproj, you can refer to the home page and the doc page.