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

Again adding of files to PBXBuildPhase #377

Closed
danilsmakotin opened this issue Feb 27, 2019 · 1 comment · Fixed by #380
Closed

Again adding of files to PBXBuildPhase #377

danilsmakotin opened this issue Feb 27, 2019 · 1 comment · Fixed by #380
Assignees

Comments

@danilsmakotin
Copy link

Context 🕵️‍♀️

My code:

let sourcesBuildPhase = try target.sourcesBuildPhase()
_ = try sourcesBuildPhase?.add(file: file)

That works fine when I add a file to a target first time. But for files which already added to the target this code add them again.

What 🌱

    func add(file: PBXFileElement) throws -> PBXBuildFile {
        if let existing = files.first(where: { $0.fileReference == reference }) {
            return existing
        }
        let projectObjects = try objects()
        let buildFile = PBXBuildFile(file: file)
        projectObjects.add(object: buildFile)
        files.append(buildFile)
        return buildFile
    }

I think that first line of this method has a typing error. I've changed it to
if let existing = files.first(where: { $0.fileReference == file.reference })
and it works correctly now.

If this is a new issue I can push a fix.

@pepicrft
Copy link
Contributor

Nice catch, that's definitively an issue. Your fix looks good so feel free to push it and open a PR.

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

Successfully merging a pull request may close this issue.

2 participants