Skip to content

Commit

Permalink
Merge pull request #325 from BranchMetrics/fix-cordova-7
Browse files Browse the repository at this point in the history
fix: added support for cordova 7.0.0
  • Loading branch information
ethanneff authored May 10, 2017
2 parents 2a8483c + 6f1a2a5 commit 1425658
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ testbed/platforms
testbed/plugins
testbed/hooks
testbed/build.json
testbed/package.json
node_modules
.installed
.gradle/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 1 addition & 6 deletions plugin.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="branch-cordova-sdk"
version="2.5.16">
version="2.5.17">

<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->

Expand All @@ -37,11 +37,6 @@ SOFTWARE.
<issue>https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues</issue>

<!-- Dependencies -->
<dependency
id="es6-promise-plugin"
version="3.0.2">
</dependency>

<engines>
<engine name="cordova" version=">=3.5.0" />
</engines>
Expand Down
7 changes: 1 addition & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="branch-cordova-sdk"
version="2.5.16">
version="2.5.17">

<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->

Expand All @@ -37,11 +37,6 @@ SOFTWARE.
<issue>https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues</issue>

<!-- Dependencies -->
<dependency
id="es6-promise-plugin"
version="3.0.2">
</dependency>

<engines>
<engine name="cordova" version=">=3.5.0" />
</engines>
Expand Down
7 changes: 3 additions & 4 deletions src/scripts/ios/enableEntitlements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 50 additions & 3 deletions src/scripts/npm/processConfigXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +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 {
return context.requireCordovaModule('cordova-lib/src/plugman/platforms').ios
// pre 5.0 cordova structure
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
return context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios').parseProjectFile(projectPath)
} catch (e) {
// post 7.0 cordova structure
return getProjectModuleGlob(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) return
var pbxPath = projectFiles[0]
var xcodeproj = context.requireCordovaModule('xcode').project(pbxPath)

// add hash
xcodeproj.parseSync()

// 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) {}
// If there are no framework references, remove this file
if (Object.keys(frameworks).length === 0) {
return context.requireCordovaModule('shelljs').rm('-rf', frameworksFile)
}

// save frameworks
fs.writeFileSync(frameworksFile, JSON.stringify(frameworks, null, 4))
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions testbed/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ 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
rm -rf ./package.json

# build (platforms added before plugin because before_plugin_install does not work on file reference)
if [[ "$run_ios" == "true" ]]; then
Expand Down

0 comments on commit 1425658

Please sign in to comment.