Search code examples
rubyxcodexcode-projectxcodeproj

How to add folder reference to PBXGroup?


I want to add 'folder reference' to PBXGroup using ruby. Can't find a solution in github.com/CocoaPods/Xcodeproj

   file_path = File.join(to_folder, folder_to_fetch)
    file_reference = destination_group.new_file(file_path, :group)

    project.native_targets.each do |target|
#        ... ???
    end

Solution

  • Founded a solution - on blind:

    file_path = destination_folder_path 
    file_reference = destination_group.new_file(file_path, :project)
    file_reference.path = file_path 
    file_reference.include_in_index = '0' 
    file_reference.set_explicit_file_type('folder') 
    file_reference.last_known_file_type = 'folder'
    
    project.native_targets.each do |target| 
       target.add_resources([file_reference]) 
    end 
    
    project.save