Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeResourceWithKey and removeMemberWithKey need documentation #77

Open
cfilipov opened this issue May 4, 2016 · 0 comments
Open

Comments

@cfilipov
Copy link

cfilipov commented May 4, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant