I use Xcodeproj gem to add some files in post_install
hook. How can I add nested folder of assets into PBXResourcesBuildPhase
? This is how it looks when I add folder by drag & drop it into Xcode and selecting Create folder references
option:
Project tree aka PBXProj:
Copy Bundle Resources aka PBXResourcesBuildPhase:
Folders need to be added by reference. Any ideas?
It turned out to be quite simple:
project = Xcodeproj::Project.open('MyApp.xcodeproj')
target = project.targets.find { |target| target.to_s == 'MyTarget' }
parent_group = project.groups.select { |group| group.name == 'Parent' }
assets_path = 'path/to/assets'
assets_ref = parent_group.new_reference(assets_path, :group)
target.add_resources([assets_ref])