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') }; }