From cde5a2011c1b3e97c5746398463ff338065e8a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Thu, 3 Jun 2021 02:17:24 +0200 Subject: [PATCH] Fix rebundling apps with app extensions (.share only for now) --- index.js | 17 +++++++++++++++-- lib/info-plist.js | 13 ++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index acfe29e..837a3cf 100644 --- a/index.js +++ b/index.js @@ -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(); @@ -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'); diff --git a/lib/info-plist.js b/lib/info-plist.js index f3fe6aa..20405cf 100644 --- a/lib/info-plist.js +++ b/lib/info-plist.js @@ -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); @@ -116,4 +119,4 @@ function supportedDevices (data) { return have; } -module.exports = fix; +module.exports = adjustInfoPlist;