-
-
Save niklasberglund/129065e2612d00c811d0 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['Frameworks'].new_file(lib_path); | |
# 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(); | |
I am unable to get the PBXFrameworkBuildPhase all i get is the following classes.
Xcodeproj::Project::Object::PBXProject
Xcodeproj::Project::Object::PBXGroup
Xcodeproj::Project::Object::PBXGroup
Xcodeproj::Project::Object::XCConfigurationList
Xcodeproj::Project::Object::XCBuildConfiguration
Xcodeproj::Project::Object::XCBuildConfiguration
Xcodeproj::Project::Object::PBXGroup
Xcodeproj::Project::Object::PBXFileReference
Following is the code snipet
require 'xcodeproj'
project_path = "/Users/NileshAgrawal/Documents/ca-work/ios/ios-samples/ios-samples/MAAKitchenSink/MAAKitchenSink.xcodeproj";
Create project object
project = Xcodeproj::Project.new(project_path);
lib_path = "/Users/NileshAgrawal/Documents/ca-work/ios/ios-samples/ios-samples/MAAKitchenSink/libCAMobileAppAnalytics.a";
Add the lib file as a reference
libRef = project['Frameworks'].new_file(lib_path);
Get the build phase
framework_buildphase = project.objects.select{|x| x.class == Xcodeproj::Project::Object::PBXFrameworksBuildPhase}[0];
projectobjects.select { |x|
puts x.class
};
Add it to the build phase
framework_buildphase.add_file_reference(libRef);
Save the project
project.save_as(project_path);
hi, could you give an example to add "libz.tbd"
many thanks
Very relevant and useful documentation at: http://rubydoc.info/gems/xcodeproj/Xcodeproj/Project