From 7bcd9b3537ac8aa553231c1c4c0858db913ea041 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Thu, 26 Sep 2024 22:58:14 -0700 Subject: [PATCH] fix(project): Validate that App.xcodeproj exists This is a guard against running a newer version of Cordova iOS tools against an older project with a different name (which will fail due to now-hardcoded assumptions about the project name). --- lib/Api.js | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/lib/Api.js b/lib/Api.js index 347810861..c131f1b83 100644 --- a/lib/Api.js +++ b/lib/Api.js @@ -81,39 +81,20 @@ class Api { setupEvents(events); - let xcodeProjDir; - let xcodeCordovaProj; - - try { - const xcodeProjDir_array = fs.readdirSync(this.root).filter(e => e.match(/\.xcodeproj$/i)); - if (xcodeProjDir_array.length > 1) { - for (let x = 0; x < xcodeProjDir_array.length; x++) { - if (xcodeProjDir_array[x].substring(0, 2) === '._') { - xcodeProjDir_array.splice(x, 1); - } - } - } - xcodeProjDir = xcodeProjDir_array[0]; - - if (!xcodeProjDir) { - throw new CordovaError(`The provided path "${this.root}" is not a Cordova iOS project.`); - } - - const cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep) + 1, xcodeProjDir.indexOf('.xcodeproj')); - xcodeCordovaProj = path.join(this.root, cordovaProjName); - } catch (e) { - throw new CordovaError(`The provided path "${this.root}" is not a Cordova iOS project.`); + const xcodeProjDir = path.join(this.root, 'App.xcodeproj'); + if (!fs.existsSync(xcodeProjDir)) { + throw new CordovaError(`The provided path "${this.root}" is not an up-to-date Cordova iOS project.`); } this.locations = { root: this.root, www: path.join(this.root, 'www'), platformWww: path.join(this.root, 'platform_www'), - configXml: path.join(xcodeCordovaProj, 'config.xml'), + configXml: path.join(this.root, 'App', 'config.xml'), defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'), - pbxproj: path.join(this.root, xcodeProjDir, 'project.pbxproj'), - xcodeProjDir: path.join(this.root, xcodeProjDir), - xcodeCordovaProj + pbxproj: path.join(xcodeProjDir, 'project.pbxproj'), + xcodeProjDir, + xcodeCordovaProj: path.join(this.root, 'App') }; }