-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($compile): update cordova hooks so that you don't need to build u…
…sing Xcode as described by BranchMetrics#271 Cordova has introduced the ability for the user to define their entitlements files: apache/cordova-ios@b5fb016 The provide the base files and you can overwrite for your project. These files get created for the iOS build at: <app name>/platforms/ios/<app name>/Entitlements-<release type>.plist Currently the cordova-ionic-phonegap-branch-deep-linking hook code updates: <app name>/platforms/ios/build/device/<app name>.app/<app name>.entitlements But misses the new entitlement files that the user can provide. If these files are updated by the branchio hook then one can have a reliable means for using cordova in build systems to push out application updates to the user without manual intervention of Xcode.
- Loading branch information
Cliff Cyphers
committed
Feb 28, 2017
1 parent
7f01f61
commit 60d904d
Showing
5 changed files
with
185 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
/** | ||
Hook is executed at the end of the 'prepare' stage. Usually, when you call 'cordova build'. | ||
It will inject required preferences in the platform-specific projects, based on <branch-config> | ||
data you have specified in the projects config.xml file. | ||
*/ | ||
|
||
var configParser = require('./lib/configXmlParser.js'), | ||
androidManifestWriter = require('./lib/android/manifestWriter.js'), | ||
|
||
|
||
// androidWebHook = require('./lib/android/webSiteHook.js'), | ||
iosProjectEntitlements = require('./lib/ios/projectEntitlements.js'), | ||
iosProjectPreferences = require('./lib/ios/xcodePreferences.js'), | ||
IOS = 'ios'; | ||
|
||
module.exports = function (ctx) { | ||
run(ctx); | ||
}; | ||
|
||
/** | ||
* Execute hook. | ||
* | ||
* @param {Object} cordovaContext - cordova context object | ||
*/ | ||
function run(cordovaContext) { | ||
var pluginPreferences = configParser.readPreferences(cordovaContext), | ||
platformsList = cordovaContext.opts.platforms; | ||
|
||
// if no preferences are found - exit | ||
if (pluginPreferences == null) { | ||
return; | ||
} | ||
|
||
// if no host is defined - exit | ||
if (pluginPreferences.hosts == null || pluginPreferences.hosts.length == 0) { | ||
console.warn('No host is specified in the config.xml. Universal Links plugin is not going to work.'); | ||
return; | ||
} | ||
|
||
platformsList.forEach(function (platform) { | ||
if (platform === IOS) { | ||
activateUniversalLinksInIos(cordovaContext, pluginPreferences); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Activate Universal Links for iOS application. | ||
* | ||
* @param {Object} cordovaContext - cordova context object | ||
* @param {Object} pluginPreferences - plugin preferences from the config.xml file. Basically, content from <branch-config> tag. | ||
*/ | ||
function activateUniversalLinksInIos(cordovaContext, pluginPreferences) { | ||
// modify xcode project preferences | ||
//iosProjectPreferences.enableAssociativeDomainsCapability(cordovaContext); | ||
|
||
// generate entitlements file | ||
var buildTypes = ['Debug', 'Release']; | ||
for (var x = 0; x < buildTypes.length; x++) { | ||
iosProjectEntitlements.generateAssociatedDomainsEntitlements(cordovaContext, pluginPreferences, buildTypes[x]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
/** | ||
Hook is executed at the end of the 'prepare' stage. Usually, when you call 'cordova build'. | ||
It will inject required preferences in the platform-specific projects, based on <branch-config> | ||
data you have specified in the projects config.xml file. | ||
*/ | ||
|
||
var configParser = require('./lib/configXmlParser.js'), | ||
androidManifestWriter = require('./lib/android/manifestWriter.js'), | ||
|
||
|
||
// androidWebHook = require('./lib/android/webSiteHook.js'), | ||
iosProjectEntitlements = require('./lib/ios/projectEntitlements.js'), | ||
iosProjectPreferences = require('./lib/ios/xcodePreferences.js'), | ||
IOS = 'ios'; | ||
|
||
module.exports = function (ctx) { | ||
run(ctx); | ||
}; | ||
|
||
/** | ||
* Execute hook. | ||
* | ||
* @param {Object} cordovaContext - cordova context object | ||
*/ | ||
function run(cordovaContext) { | ||
var pluginPreferences = configParser.readPreferences(cordovaContext), | ||
platformsList = cordovaContext.opts.platforms; | ||
|
||
// if no preferences are found - exit | ||
if (pluginPreferences == null) { | ||
return; | ||
} | ||
|
||
// if no host is defined - exit | ||
if (pluginPreferences.hosts == null || pluginPreferences.hosts.length == 0) { | ||
console.warn('No host is specified in the config.xml. Universal Links plugin is not going to work.'); | ||
return; | ||
} | ||
|
||
platformsList.forEach(function (platform) { | ||
if (platform === IOS) { | ||
activateUniversalLinksInIos(cordovaContext, pluginPreferences); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Activate Universal Links for iOS application. | ||
* | ||
* @param {Object} cordovaContext - cordova context object | ||
* @param {Object} pluginPreferences - plugin preferences from the config.xml file. Basically, content from <branch-config> tag. | ||
*/ | ||
function activateUniversalLinksInIos(cordovaContext, pluginPreferences) { | ||
// modify xcode project preferences | ||
//iosProjectPreferences.enableAssociativeDomainsCapability(cordovaContext); | ||
|
||
// generate entitlements file | ||
var buildTypes = ['Debug', 'Release']; | ||
for (var x = 0; x < buildTypes.length; x++) { | ||
iosProjectEntitlements.generateAssociatedDomainsEntitlements(cordovaContext, pluginPreferences, buildTypes[x]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters