Skip to content

Commit

Permalink
Fix rebundling apps with app extensions (.share only for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae committed Jun 4, 2021
1 parent 1d9a904 commit cde5a20
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
17 changes: 15 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ class Applesign {
}
}

async adjustAllInfoPlists () {
const infoPlistPath = path.join(this.config.appdir, 'Info.plist');
adjustInfoPlist(infoPlistPath, this.config, this.emit.bind(this));
const ls = new AppDirectory();
const res = await ls.loadFromDirectory(this.config.appdir);
for (let appex of ls.appexs) {
const lidx = appex.lastIndexOf('/');
if (lidx !== -1) {
const plistPath = path.join (appex.substring(0,lidx), 'Info.plist');
adjustInfoPlist(plistPath, this.config, this.emit.bind(this));
}
}
}

async signAppDirectory (ipadir, skipNested) {
fchk(arguments, ['string', 'boolean']);
this._pullMobileProvision();
Expand Down Expand Up @@ -143,8 +157,7 @@ class Applesign {
if (this.config.insertLibrary !== undefined) {
await insertLibrary(this.config);
}
const infoPlistPath = path.join(this.config.appdir, 'Info.plist');
adjustInfoPlist(infoPlistPath, this.config, this.emit.bind(this));
await this.adjustAllInfoPlists ();
if (!this.config.pseudoSign) {
if (!this.config.mobileprovision) {
throw new Error('warning: No mobile provisioning file provided');
Expand Down
13 changes: 8 additions & 5 deletions lib/info-plist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ const plist = require('simple-plist');
const appleDevices = ['iPhone', 'iPad', 'AppleTV', 'AppleWatch'];
const objectFromEntries = (x) => Array.from(x, (k) => ({ [k]: [] })); // ES7 is not yet here

function fix (file, options, emit) {
const { appdir, bundleid, forceFamily, allowHttp } = options;
if (!file || !appdir) {
throw new Error('Invalid parameters for fixPlist');
function adjustInfoPlist (file, options, emit) {
let { bundleid, forceFamily, allowHttp } = options;
if (!file) {
throw new Error('Invalid parameters for adjustInfoPlist');
}
if (file.indexOf('.appex/') != -1) {
bundleid += '.share';
}
let changed = false;
const data = plist.readFileSync(file);
Expand Down Expand Up @@ -116,4 +119,4 @@ function supportedDevices (data) {
return have;
}

module.exports = fix;
module.exports = adjustInfoPlist;

0 comments on commit cde5a20

Please sign in to comment.