Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25652] iOS: Ad-hoc build fails when packaging with WatchApp #9722

Merged
merged 4 commits into from
Jan 22, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions iphone/cli/hooks/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ exports.init = function (logger, config, cli) {
exportsOptions.provisioningProfiles = {};
exportsOptions.provisioningProfiles[builder.tiapp.id] = pp.uuid;

builder.extensions.forEach(function (ext) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but this code does not work. It always uses the app's provisioning profile uuid because item.ppUUIDs does not have a property called target. Second, you code does not work for iOS Extensions because it checks the target name to see if it matches "WatchKit App" or "WatchKit Extension". Furthermore, those names are arbitrary and could be changed.

You need to look up each target's bundle identifier by walking the native targets and their build configurations. If it helps, here's the code:

builder.extensions.forEach(function (ext) {
	const nativeTargets = ext.objs.PBXNativeTarget;
	ext.targets.forEach(function (extTarget) {
		if (extTarget.ppUUIDs[target]) {
			const targetUUID = Object.keys(nativeTargets).filter(uuid => typeof nativeTargets[uuid] === 'object' && nativeTargets[uuid].name.replace(/^"/, '').replace(/"$/, '') === extTarget.name)[0];
			const buildConf = targetUUID && ext.objs.XCConfigurationList[nativeTargets[targetUUID].buildConfigurationList].buildConfigurations.filter(c => c.comment === 'Release');
			const confUUID = buildConf && buildConf.length && buildConf[0].value;
			const id = confUUID && ext.objs.XCBuildConfiguration[confUUID].buildSettings.PRODUCT_BUNDLE_IDENTIFIER;
			if (id) {
				exportsOptions.provisioningProfiles[id] = extTarget.ppUUIDs[target];
			}
		}
	});
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cb1kenobi, updated. Thanks!

ext.targets.forEach(function (item) {
let id;
if (item.name.indexOf('WatchKit Extension') !== -1) {
id = builder.tiapp.id + '.watchkitapp.watchkitextension';
} else if (item.name.indexOf('WatchKit App') !== -1) {
id = builder.tiapp.id + '.watchkitapp';
}
id && (exportsOptions.provisioningProfiles[id] = item.ppUUIDs.target || pp.uuid);
});
});

// check if the app is using CloudKit
const entitlementsFile = path.join(builder.buildDir, builder.tiapp.name + '.entitlements');
if (fs.existsSync(entitlementsFile)) {
Expand Down