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

Can't add a (yet) not existent file to a group. #409

Closed
llinardos opened this issue Apr 24, 2019 · 2 comments · Fixed by #418
Closed

Can't add a (yet) not existent file to a group. #409

llinardos opened this issue Apr 24, 2019 · 2 comments · Fixed by #418
Assignees

Comments

@llinardos
Copy link
Contributor

I'm trying to add a reference to a .framework that is not created yet. I'm sure the file will exist after compiling the target that generates it. But it doesn't exist yet.

The method add file in PBXGroup check for existence of the file, so it throws when I try to add the yet unexistent file.

I solve my issue adding the next method to PBXGroup:

func addFileReference(_ fileReference: PBXFileReference) throws {
        let projectObjects = try objects()
        projectObjects.add(object: fileReference)
        fileReference.parent = self
        if !childrenReferences.contains(fileReference.reference) {
          childrenReferences.append(fileReference.reference)
        }
    }

I know what I'm doing, but I'm not sure if adding this method to the group API is ok. I mean, it allows to add unexistent files references. You guys know much more about the uses of the xcodeproj, what do you think? Is it worth to add it? If is it ok, I can make a PR for this feature.

@pepicrft pepicrft self-assigned this May 2, 2019
@pepicrft
Copy link
Contributor

pepicrft commented May 3, 2019

Hey @llinardos, that's a utterly valid use case.
A PR was merged recently modifying the addFile method to support overriding existing file. You could do add another argument to support adding non-existing files:

func addFile(validatePresence: Bool = true) // Default to true for backwards compatibility. 

@llinardos
Copy link
Contributor Author

Done @pepibumur! Here is the 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