From 1f8b81e7b4f1413ae4f211ee327af6c5b23ef924 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Tue, 9 May 2017 15:32:12 -0700 Subject: [PATCH 1/5] fix: updated plist dependency to 2.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 845a0fee..873badd1 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "husky": "^0.13.2", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", - "plist": "^2.0.1", + "plist": "^2.1.0", "semantic-release": "^6.3.6", "validate-commit-msg": "^2.11.2", "xml2js": "^0.4.17" From 0312dca92c4fd0c8543c31b5bd52ae843f16e856 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Tue, 9 May 2017 15:33:18 -0700 Subject: [PATCH 2/5] chore: updated npm version to 2.5.17 --- package.json | 2 +- plugin.template.xml | 2 +- plugin.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 873badd1..311de681 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "branch-cordova-sdk", "description": "Branch Metrics Cordova SDK", "main": "www/branch.js", - "version": "2.5.16", + "version": "2.5.17", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.template.xml b/plugin.template.xml index 1f8eb81a..95fc82b8 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="2.5.17"> diff --git a/plugin.xml b/plugin.xml index 76285fb3..5321382c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="2.5.17"> From de7cc9db43712d0a9e00d648c0f620f5cc87df51 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Tue, 9 May 2017 15:33:39 -0700 Subject: [PATCH 3/5] fix: removed es6-promise-plugin dependency --- plugin.template.xml | 5 ----- plugin.xml | 5 ----- 2 files changed, 10 deletions(-) diff --git a/plugin.template.xml b/plugin.template.xml index 95fc82b8..9d7f8936 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -37,11 +37,6 @@ SOFTWARE. https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues - - - diff --git a/plugin.xml b/plugin.xml index 5321382c..1f821182 100644 --- a/plugin.xml +++ b/plugin.xml @@ -37,11 +37,6 @@ SOFTWARE. https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues - - - From 862f14e510ccccd2f44372ed4d5fc9ed29e88b89 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Tue, 9 May 2017 15:33:59 -0700 Subject: [PATCH 4/5] fix: added support for cordova 7.0.0 --- src/scripts/ios/enableEntitlements.js | 7 ++-- src/scripts/npm/processConfigXml.js | 50 +++++++++++++++++++++++++-- testbed/init.sh | 1 + 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/scripts/ios/enableEntitlements.js b/src/scripts/ios/enableEntitlements.js index aa180d3f..72f8dac6 100755 --- a/src/scripts/ios/enableEntitlements.js +++ b/src/scripts/ios/enableEntitlements.js @@ -15,11 +15,10 @@ // updates the xcode preferences to allow associated domains function enableAssociatedDomains (preferences) { var entitlementsFile = path.join(preferences.projectRoot, 'platforms', 'ios', preferences.projectName, 'Resources', preferences.projectName + '.entitlements') - var projectFile = preferences.iosProjectModule.parseProjectFile(path.join(preferences.projectRoot, 'platforms', 'ios')) - activateAssociativeDomains(projectFile.xcode, entitlementsFile) - addPbxReference(projectFile.xcode, entitlementsFile) - projectFile.write() + activateAssociativeDomains(preferences.iosProjectModule.xcode, entitlementsFile) + addPbxReference(preferences.iosProjectModule.xcode, entitlementsFile) + preferences.iosProjectModule.write() } // adds entitlement files to the xcode project diff --git a/src/scripts/npm/processConfigXml.js b/src/scripts/npm/processConfigXml.js index e2c86e2d..79d080e5 100644 --- a/src/scripts/npm/processConfigXml.js +++ b/src/scripts/npm/processConfigXml.js @@ -105,14 +105,58 @@ // read iOS project module from cordova context function getProjectModule (context) { - // try pre-5.0 cordova structure + var projectRoot = getProjectRoot(context) + var projectPath = path.join(projectRoot, 'platforms', 'ios') + + // try pre 5.0 cordova structure try { - return context.requireCordovaModule('cordova-lib/src/plugman/platforms').ios + return context.requireCordovaModule('cordova-lib/src/plugman/platforms').ios.parseProjectFile(projectPath) } catch (e) { - return context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios') + // try pre 7.0 cordova structure + try { + return context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios').parseProjectFile(projectPath) + } catch (e) { + return getProjectModulePlugman(context) + } } } + function getProjectModulePlugman (context) { + var projectRoot = getProjectRoot(context) + var projectPath = path.join(projectRoot, 'platforms', 'ios') + var projectFiles = context.requireCordovaModule('glob').sync(path.join(projectPath, '*.xcodeproj', 'project.pbxproj')) + + if (projectFiles.length === 0) { + throw new Error('BRANCH SDK: Unable to locate the Xcode project file.') + } + + var pbxPath = projectFiles[0] + var xcodeproj = context.requireCordovaModule('xcode').project(pbxPath) + xcodeproj.parseSync() + + var xCodeProjectFile = { + 'xcode': xcodeproj, + 'write': function () { + var fs = context.requireCordovaModule('fs') + var frameworksFile = path.join(projectPath, 'frameworks.json') + var frameworks = {} + try { + frameworks = context.requireCordovaModule(frameworksFile) + } catch (e) {} + + fs.writeFileSync(pbxPath, xcodeproj.writeSync()) + if (Object.keys(frameworks).length === 0) { + // If there is no framework references remain in the project, just remove this file + context.requireCordovaModule('shelljs').rm('-rf', frameworksFile) + return + } + fs.writeFileSync(frameworksFile, JSON.stringify(this.frameworks, null, 4)) + } + } + + return xCodeProjectFile + } + // validate properties within config.xml function validateBranchPreferences (preferences) { if (preferences.projectRoot === null) { diff --git a/testbed/init.sh b/testbed/init.sh index e4b14966..340dfd73 100755 --- a/testbed/init.sh +++ b/testbed/init.sh @@ -62,6 +62,7 @@ main() { npm uninstall mkpath node-version-compare plist xml2js fi rm -rf ../.installed + rm -rf ./node_modules rm -rf ./plugins rm -rf ./platforms rm -rf ./build.json From 6f1a2a5b032f8d6a32f0417f56ff218b5ec793b2 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Wed, 10 May 2017 10:04:33 -0700 Subject: [PATCH 5/5] fix: cleaned up cordova 7.0.0 fix --- .gitignore | 1 + src/scripts/npm/processConfigXml.js | 39 ++++++++++++++++------------- testbed/init.sh | 1 + 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index bacd909f..daafabfd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ testbed/platforms testbed/plugins testbed/hooks testbed/build.json +testbed/package.json node_modules .installed .gradle/ diff --git a/src/scripts/npm/processConfigXml.js b/src/scripts/npm/processConfigXml.js index 79d080e5..a77fc086 100644 --- a/src/scripts/npm/processConfigXml.js +++ b/src/scripts/npm/processConfigXml.js @@ -108,53 +108,56 @@ var projectRoot = getProjectRoot(context) var projectPath = path.join(projectRoot, 'platforms', 'ios') - // try pre 5.0 cordova structure try { + // pre 5.0 cordova structure return context.requireCordovaModule('cordova-lib/src/plugman/platforms').ios.parseProjectFile(projectPath) } catch (e) { - // try pre 7.0 cordova structure try { + // pre 7.0 cordova structure return context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios').parseProjectFile(projectPath) } catch (e) { - return getProjectModulePlugman(context) + // post 7.0 cordova structure + return getProjectModuleGlob(context) } } } - function getProjectModulePlugman (context) { + function getProjectModuleGlob (context) { + // get xcodeproj var projectRoot = getProjectRoot(context) var projectPath = path.join(projectRoot, 'platforms', 'ios') var projectFiles = context.requireCordovaModule('glob').sync(path.join(projectPath, '*.xcodeproj', 'project.pbxproj')) - - if (projectFiles.length === 0) { - throw new Error('BRANCH SDK: Unable to locate the Xcode project file.') - } - + if (projectFiles.length === 0) return var pbxPath = projectFiles[0] var xcodeproj = context.requireCordovaModule('xcode').project(pbxPath) + + // add hash xcodeproj.parseSync() - var xCodeProjectFile = { + // return xcodeproj and write method + return { 'xcode': xcodeproj, 'write': function () { + // save xcodeproj var fs = context.requireCordovaModule('fs') + fs.writeFileSync(pbxPath, xcodeproj.writeSync()) + + // pull framework dependencies var frameworksFile = path.join(projectPath, 'frameworks.json') var frameworks = {} + try { frameworks = context.requireCordovaModule(frameworksFile) } catch (e) {} - - fs.writeFileSync(pbxPath, xcodeproj.writeSync()) + // If there are no framework references, remove this file if (Object.keys(frameworks).length === 0) { - // If there is no framework references remain in the project, just remove this file - context.requireCordovaModule('shelljs').rm('-rf', frameworksFile) - return + return context.requireCordovaModule('shelljs').rm('-rf', frameworksFile) } - fs.writeFileSync(frameworksFile, JSON.stringify(this.frameworks, null, 4)) + + // save frameworks + fs.writeFileSync(frameworksFile, JSON.stringify(frameworks, null, 4)) } } - - return xCodeProjectFile } // validate properties within config.xml diff --git a/testbed/init.sh b/testbed/init.sh index 340dfd73..fd75d3e5 100755 --- a/testbed/init.sh +++ b/testbed/init.sh @@ -66,6 +66,7 @@ main() { rm -rf ./plugins rm -rf ./platforms rm -rf ./build.json + rm -rf ./package.json # build (platforms added before plugin because before_plugin_install does not work on file reference) if [[ "$run_ios" == "true" ]]; then