You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to automate the removal of a bunch of source files from a specific target in my project.
I couldn't find this documented anywhere or any mention in issues, but it looks like removeMemberWithKey and removeResourceWithKey are basically the same thing, except the former expects the object key and the later expects the file ref key. In both cases, the method will remove the file from all build phases, which I find confusing based on the names. Based on the name, I thought removeResourceWithKey would remove a member from the "Copy Bundle Resources" build phase, and removeMemberWithKey remove a source file form the "Compile Sources" build phase.
let project = XCProject(filePath: "MyProject")
let target = project.targetWithName("MyTarget")
for m in target.members() where m.name.hasSuffix("-Foo.swift") {
target.removeMemberWithKey(m.key) // Does not work, the keys in the "files" object of the build phase are not the same keys you get from target.members(), which are file ref keys.
target.removeResourceWithKey(m.key) // Works, it looks like this method will find the "files" key corresponding to the file ref key
}
project.save()
Can anyone clarify the intended difference between these methods and document them in the readme?
Perhaps a better API would be to have a removeMember: method that takes an XCSourceFile instead of a key, since the key seems to be an implementation detail that shouldn't be leaked to this level.
Also, nullability annotations would be greatly appreciated, because right now everything is imported to Swift as implicitly unwrapped optionals.
The text was updated successfully, but these errors were encountered:
I was trying to automate the removal of a bunch of source files from a specific target in my project.
I couldn't find this documented anywhere or any mention in issues, but it looks like
removeMemberWithKey
andremoveResourceWithKey
are basically the same thing, except the former expects the object key and the later expects the file ref key. In both cases, the method will remove the file from all build phases, which I find confusing based on the names. Based on the name, I thoughtremoveResourceWithKey
would remove a member from the "Copy Bundle Resources" build phase, andremoveMemberWithKey
remove a source file form the "Compile Sources" build phase.Can anyone clarify the intended difference between these methods and document them in the readme?
Perhaps a better API would be to have a
removeMember:
method that takes anXCSourceFile
instead of a key, since the key seems to be an implementation detail that shouldn't be leaked to this level.Also, nullability annotations would be greatly appreciated, because right now everything is imported to Swift as implicitly unwrapped optionals.
The text was updated successfully, but these errors were encountered: