appium-ios-simulator 6.2.1 → 6.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [6.2.3](https://github.com/appium/appium-ios-simulator/compare/v6.2.2...v6.2.3) (2025-05-20)
|
|
2
|
+
|
|
3
|
+
### Miscellaneous Chores
|
|
4
|
+
|
|
5
|
+
* Bump conventional-changelog-conventionalcommits ([#448](https://github.com/appium/appium-ios-simulator/issues/448)) ([d442f17](https://github.com/appium/appium-ios-simulator/commit/d442f171c7de6a11d0e47556a9e312a70c908b82))
|
|
6
|
+
|
|
7
|
+
## [6.2.2](https://github.com/appium/appium-ios-simulator/compare/v6.2.1...v6.2.2) (2025-04-05)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Wait for springboard restart and spotlight application restart after applesimutils invocation ([#447](https://github.com/appium/appium-ios-simulator/issues/447)) ([76d38b3](https://github.com/appium/appium-ios-simulator/commit/76d38b37930318c0c6c6a558903ca0f6bd11f25f))
|
|
12
|
+
|
|
1
13
|
## [6.2.1](https://github.com/appium/appium-ios-simulator/compare/v6.2.0...v6.2.1) (2025-03-25)
|
|
2
14
|
|
|
3
15
|
### Miscellaneous Chores
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../lib/extensions/permissions.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../lib/extensions/permissions.js"],"names":[],"mappings":"AA0CA;;;;;;;;;GASG;AACH,+EALW,MAAM,cACN,MAAM,SACN,MAAM,iBAKhB;AAED;;;;;;;;;;GAUG;AACH,gFAPW,MAAM,0CAUhB;AAED;;;;;;;;GAQG;AACH,+EALW,MAAM,eACN,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAO3B;8CAqQY,OAAO,UAAU,EAAE,aAAa,GAAG,OAAO,UAAU,EAAE,sBAAsB"}
|
|
@@ -11,13 +11,18 @@ const support_1 = require("@appium/support");
|
|
|
11
11
|
const teen_process_1 = require("teen_process");
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
14
|
+
const asyncbox_1 = require("asyncbox");
|
|
14
15
|
const STATUS = Object.freeze({
|
|
15
16
|
UNSET: 'unset',
|
|
16
17
|
NO: 'no',
|
|
17
18
|
YES: 'yes',
|
|
18
19
|
LIMITED: 'limited',
|
|
19
20
|
});
|
|
21
|
+
const SPRINGBOARD_BUNDLE_ID = 'com.apple.SpringBoard';
|
|
22
|
+
const SPOTLIGHT_BUNDLE_ID = 'com.apple.Spotlight';
|
|
20
23
|
const WIX_SIM_UTILS = 'applesimutils';
|
|
24
|
+
const SERVICES_NEED_SPRINGBOARD_RESTART = ['notifications'];
|
|
25
|
+
const SYSTEM_SERVICE_RESTART_TIMEOUT_MS = 15000;
|
|
21
26
|
// `location` permission does not work with WIX/applesimutils.
|
|
22
27
|
// Note that except for 'contacts', the Apple's privacy command sets
|
|
23
28
|
// permissions properly but it kills the app process while WIX/applesimutils does not.
|
|
@@ -201,14 +206,79 @@ async function setAccess(bundleId, permissionsMapping) {
|
|
|
201
206
|
const permissionsArg = lodash_1.default.toPairs(wixPermissions)
|
|
202
207
|
.map((x) => `${x[0]}=${formatStatus(x[1])}`)
|
|
203
208
|
.join(',');
|
|
204
|
-
await execWix.bind(this)([
|
|
209
|
+
const execWixFn = async () => await execWix.bind(this)([
|
|
205
210
|
'--byId', this.udid,
|
|
206
211
|
'--bundle', bundleId,
|
|
207
212
|
'--setPermissions', permissionsArg,
|
|
208
213
|
]);
|
|
214
|
+
const shouldWaitForSystemReadiness = !lodash_1.default.isEmpty(lodash_1.default.intersection(SERVICES_NEED_SPRINGBOARD_RESTART, lodash_1.default.keys(wixPermissions)));
|
|
215
|
+
if (shouldWaitForSystemReadiness) {
|
|
216
|
+
const [didTimeout] = await runAndWaitForSystemReadiness.bind(this)(execWixFn, SYSTEM_SERVICE_RESTART_TIMEOUT_MS);
|
|
217
|
+
if (didTimeout) {
|
|
218
|
+
this.log.warn(`The required system services did not restart after ` +
|
|
219
|
+
`${SYSTEM_SERVICE_RESTART_TIMEOUT_MS}ms timeout. This might lead to unexpected consequences later.`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
await execWixFn();
|
|
224
|
+
}
|
|
209
225
|
}
|
|
210
226
|
return true;
|
|
211
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Waiting for springboard restart and applications process end/restart
|
|
230
|
+
* triggered by the springboard process restart.
|
|
231
|
+
*
|
|
232
|
+
* @this {import('../types').CoreSimulator}
|
|
233
|
+
* @template {any} T
|
|
234
|
+
* @param {() => Promise<T>} fn
|
|
235
|
+
* @param {number} timeoutMs
|
|
236
|
+
* @returns {Promise<[boolean, T]>}
|
|
237
|
+
*/
|
|
238
|
+
async function runAndWaitForSystemReadiness(fn, timeoutMs) {
|
|
239
|
+
const waitForNewPid = async (initialPid, bundleId, timeoutMs) => {
|
|
240
|
+
await (0, asyncbox_1.waitForCondition)(async () => {
|
|
241
|
+
try {
|
|
242
|
+
const pid = (await this.ps()).find(({ name }) => bundleId === name)?.pid;
|
|
243
|
+
return lodash_1.default.isInteger(pid) && initialPid !== pid;
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}, { waitMs: timeoutMs, intervalMs: 500 });
|
|
249
|
+
};
|
|
250
|
+
let initialProcesses = [];
|
|
251
|
+
try {
|
|
252
|
+
initialProcesses = await this.ps();
|
|
253
|
+
}
|
|
254
|
+
catch { }
|
|
255
|
+
;
|
|
256
|
+
const [initialSpringboardPid, initialSpotlightPid] = [
|
|
257
|
+
SPRINGBOARD_BUNDLE_ID, SPOTLIGHT_BUNDLE_ID
|
|
258
|
+
].map((bundleId) => initialProcesses.find(({ name }) => bundleId === name)?.pid);
|
|
259
|
+
const result = await fn();
|
|
260
|
+
if (!lodash_1.default.isInteger(initialSpringboardPid) || !lodash_1.default.isInteger(initialSpotlightPid)) {
|
|
261
|
+
// there is no point to wait if relevant processes were not running before
|
|
262
|
+
return [false, result];
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
// Make sure the springboard process restarted first.
|
|
266
|
+
const timer = new support_1.timing.Timer().start();
|
|
267
|
+
await waitForNewPid(initialSpringboardPid, SPRINGBOARD_BUNDLE_ID, timeoutMs);
|
|
268
|
+
const remainingTimeoutMs = timeoutMs - timer.getDuration().asMilliSeconds;
|
|
269
|
+
if (remainingTimeoutMs <= 0) {
|
|
270
|
+
// no need to check the SPOTLIGHT_BUNDLE_ID
|
|
271
|
+
return [true, result];
|
|
272
|
+
}
|
|
273
|
+
// Then, checking if the new spring board process refreshes applications.
|
|
274
|
+
// Spotlight.app is widely used so the app process can be an indicator to check the refresh.
|
|
275
|
+
await waitForNewPid(initialSpotlightPid, SPOTLIGHT_BUNDLE_ID, remainingTimeoutMs);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return [true, result];
|
|
279
|
+
}
|
|
280
|
+
return [false, result];
|
|
281
|
+
}
|
|
212
282
|
/**
|
|
213
283
|
* Retrieves the current permission status for the given service and application.
|
|
214
284
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../lib/extensions/permissions.js"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../lib/extensions/permissions.js"],"names":[],"mappings":";;;;;AAoDA,sCAEC;AAaD,wCAGC;AAWD,sCAIC;AArFD,oDAAuB;AACvB,6CAAmD;AACnD,+CAAoC;AACpC,gDAAwB;AACxB,wDAAyB;AACzB,uCAA4C;AAE5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAA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,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1C,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC,CAAC;IAEF,8EAA8E;IAC9E,+EAA+E;IAC/E,IAAI,CAAC;QACH,UAAU;QACV,OAAO,MAAM,eAAe,CAC1B,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,EAC5D,YAAY,CACb,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,eAAe,CAC1B,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EACrC,SAAS,CACV,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { fs, util } from '@appium/support';
|
|
2
|
+
import { fs, timing, util } from '@appium/support';
|
|
3
3
|
import { exec } from 'teen_process';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import B from 'bluebird';
|
|
6
|
+
import { waitForCondition } from 'asyncbox';
|
|
6
7
|
|
|
7
8
|
const STATUS = Object.freeze({
|
|
8
9
|
UNSET: 'unset',
|
|
@@ -10,7 +11,11 @@ const STATUS = Object.freeze({
|
|
|
10
11
|
YES: 'yes',
|
|
11
12
|
LIMITED: 'limited',
|
|
12
13
|
});
|
|
14
|
+
const SPRINGBOARD_BUNDLE_ID = 'com.apple.SpringBoard';
|
|
15
|
+
const SPOTLIGHT_BUNDLE_ID = 'com.apple.Spotlight';
|
|
13
16
|
const WIX_SIM_UTILS = 'applesimutils';
|
|
17
|
+
const SERVICES_NEED_SPRINGBOARD_RESTART = ['notifications'];
|
|
18
|
+
const SYSTEM_SERVICE_RESTART_TIMEOUT_MS = 15000;
|
|
14
19
|
// `location` permission does not work with WIX/applesimutils.
|
|
15
20
|
// Note that except for 'contacts', the Apple's privacy command sets
|
|
16
21
|
// permissions properly but it kills the app process while WIX/applesimutils does not.
|
|
@@ -215,16 +220,88 @@ async function setAccess (bundleId, permissionsMapping) {
|
|
|
215
220
|
const permissionsArg = _.toPairs(wixPermissions)
|
|
216
221
|
.map((x) => `${x[0]}=${formatStatus(x[1])}`)
|
|
217
222
|
.join(',');
|
|
218
|
-
await execWix.bind(this)([
|
|
223
|
+
const execWixFn = async () => await execWix.bind(this)([
|
|
219
224
|
'--byId', this.udid,
|
|
220
225
|
'--bundle', bundleId,
|
|
221
226
|
'--setPermissions', permissionsArg,
|
|
222
227
|
]);
|
|
228
|
+
const shouldWaitForSystemReadiness = !_.isEmpty(
|
|
229
|
+
_.intersection(SERVICES_NEED_SPRINGBOARD_RESTART, _.keys(wixPermissions))
|
|
230
|
+
);
|
|
231
|
+
if (shouldWaitForSystemReadiness) {
|
|
232
|
+
const [didTimeout] = await runAndWaitForSystemReadiness.bind(this)(
|
|
233
|
+
execWixFn, SYSTEM_SERVICE_RESTART_TIMEOUT_MS
|
|
234
|
+
);
|
|
235
|
+
if (didTimeout) {
|
|
236
|
+
this.log.warn(
|
|
237
|
+
`The required system services did not restart after ` +
|
|
238
|
+
`${SYSTEM_SERVICE_RESTART_TIMEOUT_MS}ms timeout. This might lead to unexpected consequences later.`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
await execWixFn();
|
|
243
|
+
}
|
|
223
244
|
}
|
|
224
245
|
|
|
225
246
|
return true;
|
|
226
247
|
}
|
|
227
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Waiting for springboard restart and applications process end/restart
|
|
251
|
+
* triggered by the springboard process restart.
|
|
252
|
+
*
|
|
253
|
+
* @this {import('../types').CoreSimulator}
|
|
254
|
+
* @template {any} T
|
|
255
|
+
* @param {() => Promise<T>} fn
|
|
256
|
+
* @param {number} timeoutMs
|
|
257
|
+
* @returns {Promise<[boolean, T]>}
|
|
258
|
+
*/
|
|
259
|
+
async function runAndWaitForSystemReadiness(fn, timeoutMs) {
|
|
260
|
+
const waitForNewPid = async (initialPid, bundleId, timeoutMs) => {
|
|
261
|
+
await waitForCondition(async () => {
|
|
262
|
+
try {
|
|
263
|
+
const pid = (await this.ps()).find(({name}) => bundleId === name)?.pid;
|
|
264
|
+
return _.isInteger(pid) && initialPid !== pid;
|
|
265
|
+
} catch {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}, {waitMs: timeoutMs, intervalMs: 500});
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
let initialProcesses = [];
|
|
272
|
+
try {
|
|
273
|
+
initialProcesses = await this.ps();
|
|
274
|
+
} catch {};
|
|
275
|
+
|
|
276
|
+
const [initialSpringboardPid, initialSpotlightPid] = [
|
|
277
|
+
SPRINGBOARD_BUNDLE_ID, SPOTLIGHT_BUNDLE_ID
|
|
278
|
+
].map((bundleId) => initialProcesses.find(({name}) => bundleId === name)?.pid);
|
|
279
|
+
|
|
280
|
+
const result = await fn();
|
|
281
|
+
if (!_.isInteger(initialSpringboardPid) || !_.isInteger(initialSpotlightPid)) {
|
|
282
|
+
// there is no point to wait if relevant processes were not running before
|
|
283
|
+
return [false, result];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
// Make sure the springboard process restarted first.
|
|
288
|
+
const timer = new timing.Timer().start();
|
|
289
|
+
await waitForNewPid(initialSpringboardPid, SPRINGBOARD_BUNDLE_ID, timeoutMs);
|
|
290
|
+
const remainingTimeoutMs = timeoutMs - timer.getDuration().asMilliSeconds;
|
|
291
|
+
if (remainingTimeoutMs <= 0) {
|
|
292
|
+
// no need to check the SPOTLIGHT_BUNDLE_ID
|
|
293
|
+
return [true, result];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Then, checking if the new spring board process refreshes applications.
|
|
297
|
+
// Spotlight.app is widely used so the app process can be an indicator to check the refresh.
|
|
298
|
+
await waitForNewPid(initialSpotlightPid, SPOTLIGHT_BUNDLE_ID, remainingTimeoutMs);
|
|
299
|
+
} catch {
|
|
300
|
+
return [true, result];
|
|
301
|
+
}
|
|
302
|
+
return [false, result];
|
|
303
|
+
}
|
|
304
|
+
|
|
228
305
|
/**
|
|
229
306
|
* Retrieves the current permission status for the given service and application.
|
|
230
307
|
*
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"ios",
|
|
8
8
|
"simctl"
|
|
9
9
|
],
|
|
10
|
-
"version": "6.2.
|
|
10
|
+
"version": "6.2.3",
|
|
11
11
|
"author": "Appium Contributors",
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"repository": {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/teen_process": "^2.0.2",
|
|
77
77
|
"chai": "^5.1.1",
|
|
78
78
|
"chai-as-promised": "^8.0.0",
|
|
79
|
-
"conventional-changelog-conventionalcommits": "^
|
|
79
|
+
"conventional-changelog-conventionalcommits": "^9.0.0",
|
|
80
80
|
"mocha": "^11.0.1",
|
|
81
81
|
"pem": "^1.8.3",
|
|
82
82
|
"prettier": "^3.0.0",
|