Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions lib/pbxProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
filePathToReference = {};

//path is mandatory only for the main group
if(!opt.filesRelativeToProject) {
if(!opt.filesRelativeToProject && path) {
pbxGroup.path = path;
}

Expand Down Expand Up @@ -885,7 +885,7 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function(file) {
pbxProject.prototype.addToFrameworksPbxGroup = function(file) {
var pluginsGroup = this.pbxGroupByName('Frameworks');
if (!pluginsGroup) {
this.addPbxGroup([file.path], 'Frameworks');
this.addPbxGroup([file.path], 'Frameworks', 'Frameworks', null, { isMain: true, filesRelativeToProject: true});
} else {
pluginsGroup.children.push(pbxGroupChild(file));
}
Expand Down Expand Up @@ -1320,11 +1320,23 @@ pbxProject.prototype.pbxResourcesBuildPhaseObj = function(target) {
}

pbxProject.prototype.pbxFrameworksBuildPhaseObj = function(target) {
return this.buildPhaseObject('PBXFrameworksBuildPhase', 'Frameworks', target);
let buildPhase = this.buildPhaseObject('PBXFrameworksBuildPhase', 'Frameworks', target);
if (!buildPhase) {
// Create Frameworks phase in parent target
const phase = this.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', target, 'frameworks');
buildPhase = phase.buildPhase;
}
return buildPhase;
}

pbxProject.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) {
return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks', target);
let buildPhase = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks', target);
if (!buildPhase) {
// Create CopyFiles phase in parent target
const phase = this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Embed Frameworks', target, 'frameworks');
buildPhase = phase.buildPhase;
}
return buildPhase;
};

// Find Build Phase from group/target
Expand Down Expand Up @@ -1554,7 +1566,11 @@ pbxProject.prototype.addToHeaderSearchPaths = function(file, productName) {
buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED];
}

buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this));
// Check if the search path is already in the HEADER_SEARCH_PATHS and add it if it's not.
const searchPath = searchPathForFile(file, this);
if (buildSettings['HEADER_SEARCH_PATHS'].indexOf(searchPath) < 0) {
buildSettings['HEADER_SEARCH_PATHS'].push(searchPath);
}
}
}

Expand Down Expand Up @@ -2143,7 +2159,7 @@ function correctForFrameworksPath(file, project) {
function correctForPath(file, project, group) {
var r_group_dir = new RegExp('^' + group + '[\\\\/]');

if (project.pbxGroupByName(group).path)
if (project.pbxGroupByName(group)?.path)
file.path = file.path.replace(r_group_dir, '');

return file;
Expand Down Expand Up @@ -2393,7 +2409,7 @@ pbxProject.prototype.getPBXGroupByKey = function(key) {
};

pbxProject.prototype.getPBXVariantGroupByKey = function(key) {
return this.hash.project.objects['PBXVariantGroup'][key];
return this.hash.project.objects['PBXVariantGroup']?.[key];
};


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "nativescript-dev-xcode",
"description": "parser for xcodeproj/project.pbxproj files",
"main": "index.js",
"version": "0.7.0",
"version": "0.7.1-alpha.4",
"files": [
"lib",
"!lib/parser/pbxproj.pegjs"
Expand Down