Skip to content

allow setting empty path #23

Closed
Closed

Description

@n1ru4l

When path is set to undefiend or null the following code is generated:

8E63D5C4EFE34B3BAE93815F /* Frameworks */ = {
			isa = PBXGroup;
			children = (
				18285FBD1A3D4F05A3F47AC4 /* GoogleInterchangeUtilities.framework */,
			);
			name = Frameworks;
			path = undefined;
			sourceTree = "<group>";
		};

Since it is possible to create groups without a path it would be nice to not set a path when the path is undefined or null. Furthermore a path that equals undefined or null makes the Group appear red in xcode. This would also be fixed by simply dropping the path

Activity

  1. janpio commented on Dec 7, 2018

    @janpio
    Member

    Can you share the code used to produce this? Would make finding the correct parts of the library to change a lot easier. Thanks.

  2. n1ru4l commented on Dec 7, 2018

    @n1ru4l
    ContributorAuthor

    @janpio I used addFramework on a pbxProject instance, but it also happens when using addPbxGroup on a pbxProject instance (which is used by addFramework).

  3. janpio commented on Dec 7, 2018

    @janpio
    Member

    So

    pbxProject.prototype.addFramework = function(fpath, opt) {
    var customFramework = opt && opt.customFramework == true;
    var link = !opt || (opt.link == undefined || opt.link); //defaults to true if not specified
    var embed = opt && opt.embed; //defaults to false if not specified
    if (opt) {
    delete opt.embed;
    }
    var file = new pbxFile(fpath, opt);
    file.uuid = this.generateUuid();
    file.fileRef = this.generateUuid();
    file.target = opt ? opt.target : undefined;
    if (this.hasFile(file.path)) return false;
    this.addToPbxBuildFileSection(file); // PBXBuildFile
    this.addToPbxFileReferenceSection(file); // PBXFileReference
    this.addToFrameworksPbxGroup(file); // PBXGroup
    if (link) {
    this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase
    }
    if (customFramework) {
    this.addToFrameworkSearchPaths(file);
    if (embed) {
    opt.embed = embed;
    var embeddedFile = new pbxFile(fpath, opt);
    embeddedFile.uuid = this.generateUuid();
    embeddedFile.fileRef = file.fileRef;
    //keeping a separate PBXBuildFile entry for Embed Frameworks
    this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile
    this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase
    return embeddedFile;
    }
    }
    return file;
    }
    and
    pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTree) {
    var groups = this.hash.project.objects['PBXGroup'],
    pbxGroupUuid = this.generateUuid(),
    commentKey = f("%s_comment", pbxGroupUuid),
    pbxGroup = {
    isa: 'PBXGroup',
    children: [],
    name: name,
    path: path,
    sourceTree: sourceTree ? sourceTree : '"<group>"'
    },
    fileReferenceSection = this.pbxFileReferenceSection(),
    filePathToReference = {};
    for (var key in fileReferenceSection) {
    // only look for comments
    if (!COMMENT_KEY.test(key)) continue;
    var fileReferenceKey = key.split(COMMENT_KEY)[0],
    fileReference = fileReferenceSection[fileReferenceKey];
    filePathToReference[fileReference.path] = { fileRef: fileReferenceKey, basename: fileReferenceSection[key] };
    }
    for (var index = 0; index < filePathsArray.length; index++) {
    var filePath = filePathsArray[index],
    filePathQuoted = "\"" + filePath + "\"";
    if (filePathToReference[filePath]) {
    pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath]));
    continue;
    } else if (filePathToReference[filePathQuoted]) {
    pbxGroup.children.push(pbxGroupChild(filePathToReference[filePathQuoted]));
    continue;
    }
    var file = new pbxFile(filePath);
    file.uuid = this.generateUuid();
    file.fileRef = this.generateUuid();
    this.addToPbxFileReferenceSection(file); // PBXFileReference
    this.addToPbxBuildFileSection(file); // PBXBuildFile
    pbxGroup.children.push(pbxGroupChild(file));
    }
    if (groups) {
    groups[pbxGroupUuid] = pbxGroup;
    groups[commentKey] = name;
    }
    return { uuid: pbxGroupUuid, pbxGroup: pbxGroup };
    }

    The solution would be to change the latter to check if a path is provided, and if not drop the path key from the array?

  4. n1ru4l commented on Dec 7, 2018

    @n1ru4l
    ContributorAuthor

    What about 57e6e98?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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