Skip to content

Commit

Permalink
fix(ios): Added missing flag to code sign TitaniumKit so device build…
Browse files Browse the repository at this point in the history
…s work again. (#10505)

* fix(ios): Added missing flag to code sign TitaniumKit so device builds work again.

Fixes TIMOB-26520.

* fix(ios): Fixed differential build detection for Xcode project changes.

Note: subsequent builds are still broken due to code sign issue.

TIMOB-26520

* fix(ios): Added TitaniumKit.framework to the list of patterns to ignore optimizing of plist files.

* fix(ios): Added missing semicolon.
  • Loading branch information
cb1kenobi authored and ssjsamir committed Dec 19, 2018
1 parent 1699589 commit 23c4929
Showing 1 changed file with 56 additions and 11 deletions.
67 changes: 56 additions & 11 deletions iphone/cli/commands/_build.js
Expand Up @@ -3048,15 +3048,17 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {
pbxProject = xobjs.PBXProject[projectUuid],
mainTargetUuid = pbxProject.targets.filter(function (t) { return t.comment.replace(/^"/, '').replace(/"$/, '') === appName; })[0].value,
mainGroupChildren = xobjs.PBXGroup[pbxProject.mainGroup].children,
buildPhases = xobjs.PBXNativeTarget[mainTargetUuid].buildPhases,
extensionsGroup = xobjs.PBXGroup[mainGroupChildren.filter(function (child) { return child.comment === 'Extensions'; })[0].value],
frameworksGroup = xobjs.PBXGroup[mainGroupChildren.filter(function (child) { return child.comment === 'Frameworks'; })[0].value],
resourcesGroup = xobjs.PBXGroup[mainGroupChildren.filter(function (child) { return child.comment === 'Resources'; })[0].value],
productsGroup = xobjs.PBXGroup[mainGroupChildren.filter(function (child) { return child.comment === 'Products'; })[0].value],
// we lazily find the frameworks and embed frameworks uuids by working our way backwards so we don't have to compare comments
frameworksBuildPhase = xobjs.PBXFrameworksBuildPhase[
xobjs.PBXNativeTarget[mainTargetUuid].buildPhases
.filter(function (phase) {
return xobjs.PBXFrameworksBuildPhase[phase.value];
})[0].value
buildPhases.filter(phase => xobjs.PBXFrameworksBuildPhase[phase.value])[0].value
],
copyFilesBuildPhase = xobjs.PBXCopyFilesBuildPhase[
buildPhases.filter(phase => xobjs.PBXCopyFilesBuildPhase[phase.value])[0].value
],
resourcesBuildPhase = xobjs.PBXResourcesBuildPhase[xobjs.PBXNativeTarget[mainTargetUuid].buildPhases.filter(function (phase) { return xobjs.PBXResourcesBuildPhase[phase.value]; })[0].value],
caps = this.tiapp.ios.capabilities,
Expand All @@ -3067,7 +3069,8 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {
ONLY_ACTIVE_ARCH: 'NO',
DEAD_CODE_STRIPPING: 'YES',
SDKROOT: 'iphoneos',
CODE_SIGN_ENTITLEMENTS: '"' + appName + '.entitlements"'
CODE_SIGN_ENTITLEMENTS: '"' + appName + '.entitlements"',
FRAMEWORK_SEARCH_PATHS: [ '"$(inherited)"', '"Frameworks"' ]
},
legacySwift = version.lt(this.xcodeEnv.version, '8.0.0');

Expand Down Expand Up @@ -3722,12 +3725,54 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {
return product.comment;
});

const hook = this.cli.createHook('build.ios.xcodeproject', this, function (xcodeProject, done) {
// add TitaniumKit.framework
xcodeProject.removeFramework('TitaniumKit.framework', { customFramework: true, embed: true });

const frameworkFileRefUuid = this.generateXcodeUuid(xcodeProject);
const frameworkBuildFileUuid = this.generateXcodeUuid(xcodeProject);
const embedFrameworkBuildFileUuid = this.generateXcodeUuid(xcodeProject);

xobjs.PBXFileReference[frameworkFileRefUuid] = {
isa: 'PBXFileReference',
lastKnownFileType: 'wrapper.framework',
name: '"TitaniumKit.framework"',
path: '"Frameworks/TitaniumKit.framework"',
sourceTree: '"<group>"'
};
xobjs.PBXFileReference[frameworkFileRefUuid + '_comment'] = 'TitaniumKit.framework';

xobjs.PBXBuildFile[frameworkBuildFileUuid] = {
isa: 'PBXBuildFile',
fileRef: frameworkFileRefUuid,
fileRef_comment: 'TitaniumKit.framework'
};
xobjs.PBXBuildFile[frameworkBuildFileUuid + '_comment'] = 'TitaniumKit.framework in Frameworks';

// clean up TitaniumKit project references
xcodeProject.removeFramework('TitaniumKit.framework', { customFramework: true, embed: true });
xcodeProject.addFramework(path.join(this.buildDir, 'Frameworks', 'TitaniumKit.framework'), { customFramework: true, embed: true });
frameworksBuildPhase.files.push({
value: frameworkBuildFileUuid,
comment: xobjs.PBXBuildFile[frameworkBuildFileUuid + '_comment']
});

xobjs.PBXBuildFile[embedFrameworkBuildFileUuid] = {
isa: 'PBXBuildFile',
fileRef: frameworkFileRefUuid,
fileRef_comment: 'TitaniumKit.framework',
settings: { ATTRIBUTES: [ 'CodeSignOnCopy', 'RemoveHeadersOnCopy' ] }
};
xobjs.PBXBuildFile[embedFrameworkBuildFileUuid + '_comment'] = 'TitaniumKit.framework in Embed Frameworks';

copyFilesBuildPhase.files.push({
value: embedFrameworkBuildFileUuid,
comment: xobjs.PBXBuildFile[embedFrameworkBuildFileUuid + '_comment']
});

frameworksGroup.children.push({
value: frameworkFileRefUuid,
comment: 'TitaniumKit.framework'
});

// run the xcode project hook
const hook = this.cli.createHook('build.ios.xcodeproject', this, function (xcodeProject, done) {
const contents = xcodeProject.writeSync(),
dest = xcodeProject.filepath,
parent = path.dirname(dest);
Expand Down Expand Up @@ -6352,7 +6397,7 @@ iOSBuilder.prototype.optimizeFiles = function optimizeFiles(next) {
const file = path.join(dir, name);
if (fs.existsSync(file)) {
if (fs.statSync(file).isDirectory()) {
walk(file);
walk(file, ignore);
} else if (name === 'InfoPlist.strings' || name === 'Localizable.strings' || plistRegExp.test(name)) {
add(plists, name, file);
} else if (pngRegExp.test(name)) {
Expand All @@ -6361,7 +6406,7 @@ iOSBuilder.prototype.optimizeFiles = function optimizeFiles(next) {
}
}
});
}(this.xcodeAppDir, /^(PlugIns|Watch)$/i));
}(this.xcodeAppDir, /^(PlugIns|Watch|TitaniumKit\.framework)$/i));

parallel(this, [
function (next) {
Expand Down

0 comments on commit 23c4929

Please sign in to comment.