This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-node-xcode.git
The following commit(s) were added to refs/heads/master by this push:
new 022c69e [MAJOR] Add new optional paramter to pbxProject.addTarget
(#79)
022c69e is described below
commit 022c69ef1615f934f7ac0e6560e47633b2a4c6cb
Author: Niklas Merz <[email protected]>
AuthorDate: Thu Apr 9 09:42:12 2020 +0200
[MAJOR] Add new optional paramter to pbxProject.addTarget (#79)
Allows plugins to set bundle ids for extensions.
---
lib/pbxProject.js | 13 +++++++++++--
test/addTarget.js | 21 ++++++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/lib/pbxProject.js b/lib/pbxProject.js
index 3097678..a92d807 100644
--- a/lib/pbxProject.js
+++ b/lib/pbxProject.js
@@ -1385,13 +1385,14 @@ pbxProject.prototype.hasFile = function(filePath) {
return false;
}
-pbxProject.prototype.addTarget = function(name, type, subfolder) {
+pbxProject.prototype.addTarget = function(name, type, subfolder, bundleId) {
// Setup uuid and name of new target
var targetUuid = this.generateUuid(),
targetType = type,
targetSubfolder = subfolder || name,
- targetName = name.trim();
+ targetName = name.trim(),
+ targetBundleId = bundleId;
// Check type against list of allowed target types
if (!targetName) {
@@ -1433,6 +1434,14 @@ pbxProject.prototype.addTarget = function(name, type,
subfolder) {
}
];
+ // Add optional bundleId to build configuration
+ if (targetBundleId) {
+ buildConfigurationsList = buildConfigurationsList.map((elem) => {
+ elem.buildSettings.PRODUCT_BUNDLE_IDENTIFIER = '"' +
targetBundleId + '"';
+ return elem;
+ });
+ }
+
// Build Configuration: Add
var buildConfigurations =
this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build
configuration list for PBXNativeTarget "' + targetName +'"');
diff --git a/test/addTarget.js b/test/addTarget.js
index 6e44625..2ad819a 100644
--- a/test/addTarget.js
+++ b/test/addTarget.js
@@ -27,7 +27,8 @@ function cleanHash() {
var TARGET_NAME = 'TestExtension',
TARGET_TYPE = 'app_extension',
- TARGET_SUBFOLDER_NAME = 'TestExtensionFiles';
+ TARGET_SUBFOLDER_NAME = 'TestExtensionFiles',
+ TARGET_BUNDLE_ID ="com.cordova.test.appextension";
exports.setUp = function (callback) {
proj.hash = cleanHash();
@@ -93,6 +94,24 @@ exports.addTarget = {
test.done();
},
+ 'should create a new target with bundleid': function (test) {
+ var target = proj.addTarget(TARGET_NAME, TARGET_TYPE,
TARGET_SUBFOLDER_NAME, TARGET_BUNDLE_ID);
+
+ test.ok(typeof target == 'object');
+ test.ok(target.uuid);
+ test.ok(target.pbxNativeTarget);
+ test.ok(target.pbxNativeTarget.isa);
+ test.ok(target.pbxNativeTarget.name);
+ test.ok(target.pbxNativeTarget.productName);
+ test.ok(target.pbxNativeTarget.productReference);
+ test.ok(target.pbxNativeTarget.productType);
+ test.ok(target.pbxNativeTarget.buildConfigurationList);
+ test.ok(target.pbxNativeTarget.buildPhases);
+ test.ok(target.pbxNativeTarget.buildRules);
+ test.ok(target.pbxNativeTarget.dependencies);
+
+ test.done();
+ },
'should add debug and release configurations to build configuration list':
function (test) {
var pbxXCBuildConfigurationSection =
proj.pbxXCBuildConfigurationSection(),
pbxXCConfigurationList = proj.pbxXCConfigurationList(),
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]