Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created March 4, 2014 08:10
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save onevcat/9342209 to your computer and use it in GitHub Desktop.
Save onevcat/9342209 to your computer and use it in GitHub Desktop.
require 'xcodeproj'
project_path = "your_project_path";
# Create project object
project = Xcodeproj::Project.new(project_path);
lib_path = "your_lib_path";
# Add the lib file as a reference
libRef = project.new_file(lib_path, "Frameworks");
# Get the build phase
framework_buildphase = project.objects.select{|x| x.class == Xcodeproj::Project::Object::PBXFrameworksBuildPhase}[0];
# Add it to the build phase
framework_buildphase.add_file_reference(libRef);
# Save the project
project.save_as(project_path);
@niklasberglund
Copy link

Thanks a lot, this example was really useful to me. It's broken in recent versions of xcodeproj though. I forked and updated it: https://gist.github.com/niklasberglund/129065e2612d00c811d0

@tennysondy
Copy link

hi, could you give an example to add "libz.tbd"

many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment