Skip to content

removeResourceWithKey and removeMemberWithKey need documentation #77

Open
@cfilipov

Description

@cfilipov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions