From 73acee8d7ec49c3431fb9f02dfe16a37016b84dd Mon Sep 17 00:00:00 2001 From: Erisu Date: Sun, 13 Oct 2024 10:20:10 +0900 Subject: [PATCH 1/2] feat(ios): prepare for cordova-ios 8 support - corrected app name --- hooks/fileUtils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hooks/fileUtils.js b/hooks/fileUtils.js index ffe9a86..8049355 100644 --- a/hooks/fileUtils.js +++ b/hooks/fileUtils.js @@ -58,6 +58,14 @@ var fileUtils = (function(){ // Returns project name from config.xml fileUtils.getProjectName = function(){ + // Cordova-iOS 8 and greater has a static app name of "App". + // Check for "App.xcodeproj" and return "App" if it exists. + const xcodeprojPath = path.join(context.opts.projectRoot, 'platforms', 'ios', 'App.xcodeproj'); + if(fs.existsSync(xcodeprojPath)) { + return 'App'; + } + + // Fallback to original behavior. Cordova-iOS < 8 if(!configXmlData) { fileUtils.getConfigXml(); } From d3c90332f70e6b3143da5511e5581453fb156092 Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 16 Oct 2024 17:52:06 +0900 Subject: [PATCH 2/2] feat(ios): get app namefrom xcodeCordovaProj path located in platform api --- hooks/fileUtils.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/hooks/fileUtils.js b/hooks/fileUtils.js index 8049355..4266a27 100644 --- a/hooks/fileUtils.js +++ b/hooks/fileUtils.js @@ -56,20 +56,17 @@ var fileUtils = (function(){ return settings; }; - // Returns project name from config.xml + /** + * Used to get the name of the application from the xcodeCordovaProj directory path. + * The xcodeCordovaProj directory path is defined in the locations property of the Cordova-iOS platform's API. + */ fileUtils.getProjectName = function(){ - // Cordova-iOS 8 and greater has a static app name of "App". - // Check for "App.xcodeproj" and return "App" if it exists. - const xcodeprojPath = path.join(context.opts.projectRoot, 'platforms', 'ios', 'App.xcodeproj'); - if(fs.existsSync(xcodeprojPath)) { - return 'App'; - } + const projectRoot = context.opts.projectRoot; + const platformPath = path.join(projectRoot, 'platforms', 'ios'); + const cordova_ios = require('cordova-ios'); + const iosProject = new cordova_ios('ios', platformPath); - // Fallback to original behavior. Cordova-iOS < 8 - if(!configXmlData) { - fileUtils.getConfigXml(); - } - return configXmlData.findtext('name'); + return path.basename(iosProject.locations.xcodeCordovaProj); }; fileUtils.fileExists = function(filePath){