-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hook to update development team for ios
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 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,41 @@ | ||
// update the development team for Universal Links | ||
(function () { | ||
// properties | ||
'use strict' | ||
var fs = require('fs') | ||
var path = require('path') | ||
var encoding = 'utf-8' | ||
var filepath = 'platforms/ios/cordova/build.xcconfig' | ||
|
||
// entry | ||
module.exports = { | ||
addDevelopmentTeam: addDevelopmentTeam | ||
} | ||
|
||
function addDevelopmentTeam (context, preferences) { | ||
if (context.opts.cordova.platforms.indexOf('ios') === -1) return | ||
if (!context.opts.options) return | ||
if (!context.opts.options.buildConfig) return | ||
|
||
var buildType = context.opts.options.release ? 'release' : 'debug' | ||
|
||
var buildConfigPath = context.opts.options.buildConfig | ||
if (!path.isAbsolute(buildConfigPath)) { | ||
buildConfigPath = path.join(context.opts.projectRoot, context.opts.options.buildConfig) | ||
} | ||
var config = require(buildConfigPath) | ||
|
||
if (!config.ios) return | ||
if (!config.ios[buildType]) return | ||
if (!config.ios[buildType].developmentTeam) return | ||
|
||
var xcconfig = fs.readFileSync(filepath, encoding) | ||
|
||
if (xcconfig.indexOf('DEVELOPMENT_TEAM') === -1) { | ||
var content = '\nDEVELOPMENT_TEAM = ' + config.ios[buildType].developmentTeam | ||
|
||
xcconfig += content | ||
fs.writeFileSync(filepath, xcconfig, encoding) | ||
} | ||
} | ||
})() |