From b2c5784764225319648e26aa5d3f42ede6d1b289 Mon Sep 17 00:00:00 2001 From: Walter Amorim Date: Fri, 29 Dec 2017 10:03:17 -0200 Subject: [PATCH 1/4] Update manifestWriter.js to fix #133 in Cordova 8. --- hooks/lib/android/manifestWriter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/lib/android/manifestWriter.js b/hooks/lib/android/manifestWriter.js index 59f5cc90..2cdbc3e7 100644 --- a/hooks/lib/android/manifestWriter.js +++ b/hooks/lib/android/manifestWriter.js @@ -18,7 +18,7 @@ module.exports = { * @param {Object} pluginPreferences - plugin preferences as JSON object; already parsed */ function writePreferences(cordovaContext, pluginPreferences) { - var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'AndroidManifest.xml'); + var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'AndroidManifest.xml'); var manifestSource = xmlHelper.readXmlAsJson(pathToManifest); var cleanManifest; var updatedManifest; From 00b88bc2339ff0b0500e557ae357115baed655d4 Mon Sep 17 00:00:00 2001 From: Walter Amorim Date: Mon, 22 Jan 2018 10:47:43 -0200 Subject: [PATCH 2/4] Fix install in IOS platform for Cordova 7 --- hooks/lib/ios/xcodePreferences.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hooks/lib/ios/xcodePreferences.js b/hooks/lib/ios/xcodePreferences.js index 015ffbdc..1079168d 100644 --- a/hooks/lib/ios/xcodePreferences.js +++ b/hooks/lib/ios/xcodePreferences.js @@ -142,8 +142,16 @@ function loadProjectFile() { projectFile = platform_ios.parseProjectFile(iosPlatformPath()); } catch (e) { // let's try cordova 5.0 structure - platform_ios = context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios'); - projectFile = platform_ios.parseProjectFile(iosPlatformPath()); + try { + platform_ios = context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios'); + projectFile = platform_ios.parseProjectFile(iosPlatformPath()); + } catch(e) { + // try cordova 7.0 structure + var iosPlatformApi = require(path.join(iosPlatformPath(), '/cordova/Api')); + var projectFileApi = require(path.join(iosPlatformPath(), '/cordova/lib/projectFile.js')); + var locations = (new iosPlatformApi()).locations; + projectFile = projectFileApi.parse(locations); + } } return projectFile; From a7cef1c65b5558c46afc5a3f2fcc640523d80c20 Mon Sep 17 00:00:00 2001 From: Tobias Wingerter Date: Fri, 4 May 2018 09:53:33 +0200 Subject: [PATCH 3/4] introducing backwards compatibility for AndroidManifest tampering --- hooks/lib/android/manifestWriter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hooks/lib/android/manifestWriter.js b/hooks/lib/android/manifestWriter.js index 2cdbc3e7..564d0f18 100644 --- a/hooks/lib/android/manifestWriter.js +++ b/hooks/lib/android/manifestWriter.js @@ -3,6 +3,7 @@ Class injects plugin preferences into AndroidManifest.xml file. */ var path = require('path'); +var fs = require('fs'); var xmlHelper = require('../xmlHelper.js'); module.exports = { @@ -19,6 +20,10 @@ module.exports = { */ function writePreferences(cordovaContext, pluginPreferences) { var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'AndroidManifest.xml'); + if(fs.existsSync(pathToManifest)){ // fallback for older cordova-android version, where the AndroidManifest resides in the root folder of the generated android project + pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'AndroidManifest.xml'); + } + var manifestSource = xmlHelper.readXmlAsJson(pathToManifest); var cleanManifest; var updatedManifest; From 551b4404823e171e224f68e796f2fb7d082f58f7 Mon Sep 17 00:00:00 2001 From: Tobias Wingerter Date: Fri, 4 May 2018 10:10:35 +0200 Subject: [PATCH 4/4] fixing if statement --- hooks/lib/android/manifestWriter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/lib/android/manifestWriter.js b/hooks/lib/android/manifestWriter.js index 564d0f18..f52e05c3 100644 --- a/hooks/lib/android/manifestWriter.js +++ b/hooks/lib/android/manifestWriter.js @@ -20,7 +20,7 @@ module.exports = { */ function writePreferences(cordovaContext, pluginPreferences) { var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'AndroidManifest.xml'); - if(fs.existsSync(pathToManifest)){ // fallback for older cordova-android version, where the AndroidManifest resides in the root folder of the generated android project + if(!fs.existsSync(pathToManifest)){ // fallback for older cordova-android version, where the AndroidManifest resides in the root folder of the generated android project pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'AndroidManifest.xml'); }