I'm attempting to write a Ruby script that will delete certain files from the Xcode project. I can find the files based on the absolute path and remove them from the project using the remove_from_project
method of PBXFileReference
. However this leaves source files (e.g. .m
or .swift
files) in the "Compile Sources" build phase of whatever target(s) it is a member of, but without a name.
I know I need to also remove the file from the target(s) but there seems to be no easy link between a PBXFileReference
and a target (PBXNativeTarget
).
From what I can make out I need to iterate through each of the project's targets, then iterate through the files
or files_references
of that target's source_build_phase
looking for the PBXFileReference
I already have.
Is this correct or am I missing some obvious link such e.g. file_ref.target_memberships
?