Closed draveness closed 9 years ago
Here's an example of finding/creating a group, then adding a file to it: https://github.com/CocoaPods/cocoapods-acknowledgements/blob/master/lib/cocoapods_acknowledgements.rb#L8-L26
Thx a lot!
Why do I add files with this code, the compiler remind me file not exist? Is the file path relative to the root folder?
I use these code to add files to target but every time, the compiler path is wrong it is prefix with pod/classes
def add_files_to_project(path, json_path)
j = JSON.parse File.read(json_path)
project = Xcodeproj::Project.open(path)
target = project.targets.first
group_path = 'DKNightVersion/Pod/Classes/UIKit'
j.each do |group, files|
new_group = project.main_group.find_subpath(File.join(group_path, group), true)
file_refs = []
files.each do |f|
file_ref = new_group.new_reference(f)
file_refs << file_ref
end
target.add_file_references(file_refs)
end
project.save
end
I find these file are not in compile sources how can I add these files to it..
you also have to add it to the build phases alas
I have already fix it. Because I didn't set the source tree to SOURCE_ROOT
I google this but didn't find any pieces of code can run. And I find nothing in this document about this...And what is the
source_tree
is it a group?