Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6aaf755
ci(deps): bump nick-fields/retry from 3 to 4 (#1122)
dependabot[bot] Mar 25, 2026
dd15f48
fix: Avoid keeping strong reference to self instance in delegates (#1…
mykola-mokhnach Apr 12, 2026
71e5659
chore(release): 11.4.2 [skip ci]
semantic-release-bot Apr 12, 2026
046b080
chore(deps-dev): bump typescript from 5.9.3 to 6.0.2 (#1121)
dependabot[bot] Apr 12, 2026
0924871
chore(release): 11.4.3 [skip ci]
semantic-release-bot Apr 12, 2026
5072e25
refactor: remove deprecated WDA settings/capabilities and idb typing …
mykola-mokhnach Apr 14, 2026
1b6c701
chore(release): 12.0.0 [skip ci]
semantic-release-bot Apr 14, 2026
2ca4503
ci: Bump ios version (#1126)
mykola-mokhnach Apr 19, 2026
a8889cd
feat(client): add ability to set headers on requests (#1127)
muvaf Apr 24, 2026
13d61a8
chore(release): 12.1.0 [skip ci]
semantic-release-bot Apr 24, 2026
76d59e8
chore(compile): fix compilation (#1129)
Delta456 Apr 27, 2026
86469ae
chore(release): 12.1.1 [skip ci]
semantic-release-bot Apr 27, 2026
8899895
feat: Ditch bluebird and lodash (#1130)
mykola-mokhnach Apr 29, 2026
381e75c
chore(release): 12.2.0 [skip ci]
semantic-release-bot Apr 29, 2026
11c579b
chore(deps-dev): bump sinon from 21.1.2 to 22.0.0 (#1133)
dependabot[bot] May 6, 2026
abe0e0c
chore(release): 12.2.1 [skip ci]
semantic-release-bot May 6, 2026
2bd1816
fix: linter (#1134)
mykola-mokhnach May 8, 2026
b4c7f59
chore(release): 12.2.2 [skip ci]
semantic-release-bot May 8, 2026
1791c80
ci: add note about Xcode versions (#1136)
KazuCocoa May 13, 2026
8995d24
feat: Drop legacy APIs (#1137)
mykola-mokhnach May 17, 2026
daad857
chore(release): 13.0.0 [skip ci]
semantic-release-bot May 17, 2026
56b5f38
feat: Add helper method to fetch build settings (#1139)
mykola-mokhnach May 21, 2026
fe8adc8
feat: add app icon to WebDriverAgentRunner (#1138)
harsha509 May 21, 2026
b60e3c3
chore(release): 13.1.0 [skip ci]
semantic-release-bot May 21, 2026
17ac1c1
fix: ship Scripts/embed-runner-icon.sh in the npm package (#1141)
harsha509 May 22, 2026
3b78b0e
chore(release): 13.1.1 [skip ci]
semantic-release-bot May 22, 2026
f1f9976
fix: Address compilation warnings (#1143)
mykola-mokhnach May 23, 2026
161ca7d
chore(release): 13.1.2 [skip ci]
semantic-release-bot May 23, 2026
9ada5f6
fix: Scheme for derived data path retrieval (#1142)
mykola-mokhnach May 24, 2026
1807fa8
chore(release): 13.1.3 [skip ci]
semantic-release-bot May 24, 2026
a975b89
feat: Add XPath extensions (#1144)
mykola-mokhnach May 26, 2026
db1ef4a
chore(release): 13.2.0 [skip ci]
semantic-release-bot May 26, 2026
ff7ac36
chore: Refactor settings handling API (#1148)
mykola-mokhnach Jun 6, 2026
f2e5c25
chore(release): 13.2.1 [skip ci]
semantic-release-bot Jun 6, 2026
923b523
chore: Refactor session creation handler (#1149)
mykola-mokhnach Jun 6, 2026
2eb1125
chore(release): 13.2.2 [skip ci]
semantic-release-bot Jun 6, 2026
98d79e7
fix: auto-handle iOS 18+ limited access permission prompt (#1150)
abhinvv1 Jun 7, 2026
23a6181
chore(release): 13.2.3 [skip ci]
semantic-release-bot Jun 7, 2026
eea2229
fix: update WebDriverAgentRunner app icon (#1151)
eglitise Jun 8, 2026
5fe4d83
chore(release): 13.2.4 [skip ci]
semantic-release-bot Jun 8, 2026
e615621
feat: Expose native isAccessibilityElement (#1146)
anton-yereshchenko Jun 9, 2026
c82f61e
chore(release): 13.3.0 [skip ci]
semantic-release-bot Jun 9, 2026
74498f7
feat: bump the deployment target to 15 (#1152)
KazuCocoa Jun 9, 2026
c7fac44
chore(release): 14.0.0 [skip ci]
semantic-release-bot Jun 9, 2026
6b3631a
feat: Add VoiceOver automation support (#1153)
mykola-mokhnach Jun 10, 2026
3474dca
chore(release): 14.1.0 [skip ci]
semantic-release-bot Jun 10, 2026
6618b0b
chore: address runtime version rather than Xcode for selector based m…
KazuCocoa Jun 10, 2026
417db80
chore(release): 14.1.1 [skip ci]
semantic-release-bot Jun 10, 2026
9ea244b
feat: Limit the maximum request body size (#1158)
mykola-mokhnach Jun 18, 2026
4082bce
chore(release): 14.2.0 [skip ci]
semantic-release-bot Jun 18, 2026
93d7043
chore(deps-dev): bump @types/node from 25.9.4 to 26.0.0 (#1159)
dependabot[bot] Jun 19, 2026
4d03d6c
chore(release): 14.2.1 [skip ci]
semantic-release-bot Jun 19, 2026
890d32b
feat: Abstract out platform-specific actions (#1160)
mykola-mokhnach Jun 22, 2026
2409b6e
chore(release): 15.0.0 [skip ci]
semantic-release-bot Jun 22, 2026
bad42ba
Rebase QA Wolf customizations onto upstream WebDriverAgent v15.0.0 (G…
EltonCarreiro Jun 24, 2026
dd75e20
Merge origin/master into the v15 rebase
EltonCarreiro Jun 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ jobs:
fail-fast: false
matrix:
test_targets:
- HOST_OS: 'macos-15'
XCODE_VERSION: '26.1'
IOS_VERSION: '26.1'
IOS_MODEL: iPhone 17
- HOST_OS: 'macos-26'
XCODE_VERSION: '26.4'
IOS_VERSION: '26.4'
IOS_MODEL: 'iPhone 17'
- HOST_OS: 'macos-15'
XCODE_VERSION: '16.4'
IOS_VERSION: '18.4'
IOS_MODEL: iPhone 16 Plus
IOS_VERSION: '18.5'
IOS_MODEL: 'iPhone 16 Plus'
- HOST_OS: 'macos-14'
XCODE_VERSION: '15.4'
IOS_VERSION: '17.5'
IOS_MODEL: iPhone 15 Plus
IOS_MODEL: 'iPhone 15 Plus'

# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
runs-on: ${{matrix.test_targets.HOST_OS}}
Expand All @@ -46,6 +46,7 @@ jobs:
DEVICE_NAME: ${{matrix.test_targets.IOS_MODEL}}
PLATFORM_VERSION: ${{matrix.test_targets.IOS_VERSION}}
run: |
xcrun simctl list devices available
open -Fn "$(xcode-select -p)/Applications/Simulator.app"
udid=$(xcrun simctl list devices available -j | \
node -p "Object.entries(JSON.parse(fs.readFileSync(0)).devices).filter((x) => x[0].includes('$PLATFORM_VERSION'.replace('.', '-'))).reduce((acc, x) => [...acc, ...x[1]], []).find(({name}) => name === '$DEVICE_NAME').udid")
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/publish.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ permissions:
id-token: write # to enable use of OIDC for trusted publishing and npm provenance

env:
# DO NOT USE 26.4+ for a while since it could drop lower iOS versions forcefully
# while the project config allows such lower versions.
# (at least WDA failed to start on iOS 15)
# Xcode 26.3 looks like it's working as expected.
XCODE_VERSION: '16.4'
# Available destination for simulators depend on Xcode version.
# Available destination for simulators depends on Xcode version.
DESTINATION_SIM: platform=iOS Simulator,name=iPhone 17
DESTINATION_SIM_TVOS: platform=tvOS Simulator,name=Apple TV 4K (3rd generation)

Expand Down Expand Up @@ -54,7 +58,7 @@ jobs:
with:
xcode-version: "${{ env.XCODE_VERSION }}"
- name: ${{ matrix.config.name }}
uses: nick-fields/retry@v3
uses: nick-fields/retry@v4
with:
timeout_minutes: 10
max_attempts: 3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
build/
clang/
DerivedData
wdaBuild/

## Various settings
*.pbxuser
Expand Down
173 changes: 173 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,176 @@
## [15.0.0](https://github.com/appium/WebDriverAgent/compare/v14.2.1...v15.0.0) (2026-06-22)

### ⚠ BREAKING CHANGES

* AppleDevice is now abstract and only contains udid; it no longer exposes simctl or devicectl.
* Preinstalled WDA launch/terminate no longer falls back to package-owned simctl or devicectl behavior. Callers must provide hostOps.simulator or hostOps.realDevicePreinstalled for those flows.

### Features

* Abstract out platform-specific actions ([#1160](https://github.com/appium/WebDriverAgent/issues/1160)) ([890d32b](https://github.com/appium/WebDriverAgent/commit/890d32b4ac3fa881784dacc012650d58274941c8))

## [14.2.1](https://github.com/appium/WebDriverAgent/compare/v14.2.0...v14.2.1) (2026-06-19)

### Miscellaneous Chores

* **deps-dev:** bump @types/node from 25.9.4 to 26.0.0 ([#1159](https://github.com/appium/WebDriverAgent/issues/1159)) ([93d7043](https://github.com/appium/WebDriverAgent/commit/93d704317483eb9c29a2d46070a6a2c2943ae014))

## [14.2.0](https://github.com/appium/WebDriverAgent/compare/v14.1.1...v14.2.0) (2026-06-18)

### Features

* Limit the maximum request body size ([#1158](https://github.com/appium/WebDriverAgent/issues/1158)) ([9ea244b](https://github.com/appium/WebDriverAgent/commit/9ea244b29e3c2b160079a620fdf4ef445a3c1e38))

## [14.1.1](https://github.com/appium/WebDriverAgent/compare/v14.1.0...v14.1.1) (2026-06-10)

### Miscellaneous Chores

* address runtime version rather than Xcode for selector based methods ([#1154](https://github.com/appium/WebDriverAgent/issues/1154)) ([6618b0b](https://github.com/appium/WebDriverAgent/commit/6618b0b6ccd06c69fc9e4a0947ef0c88c89b1e48))

## [14.1.0](https://github.com/appium/WebDriverAgent/compare/v14.0.0...v14.1.0) (2026-06-10)

### Features

* Add VoiceOver automation support ([#1153](https://github.com/appium/WebDriverAgent/issues/1153)) ([6b3631a](https://github.com/appium/WebDriverAgent/commit/6b3631aed7a95439b01a9a3bb87189df384dcf06))

## [14.0.0](https://github.com/appium/WebDriverAgent/compare/v13.3.0...v14.0.0) (2026-06-09)

### ⚠ BREAKING CHANGES

* bump the deployment target to 15

### Features

* bump the deployment target to 15 ([#1152](https://github.com/appium/WebDriverAgent/issues/1152)) ([74498f7](https://github.com/appium/WebDriverAgent/commit/74498f79c9f00678f2bc37b9afb50f70e30d0f88))

## [13.3.0](https://github.com/appium/WebDriverAgent/compare/v13.2.4...v13.3.0) (2026-06-09)

### Features

* Expose native isAccessibilityElement ([#1146](https://github.com/appium/WebDriverAgent/issues/1146)) ([e615621](https://github.com/appium/WebDriverAgent/commit/e6156212e6fba6af98a69a400f5fa18b67f1e3e3))

## [13.2.4](https://github.com/appium/WebDriverAgent/compare/v13.2.3...v13.2.4) (2026-06-08)

### Bug Fixes

* update WebDriverAgentRunner app icon ([#1151](https://github.com/appium/WebDriverAgent/issues/1151)) ([eea2229](https://github.com/appium/WebDriverAgent/commit/eea2229f8d2e8bd2dd936fe3ddb69a9458789f49))

## [13.2.3](https://github.com/appium/WebDriverAgent/compare/v13.2.2...v13.2.3) (2026-06-07)

### Bug Fixes

* auto-handle iOS 18+ limited access permission prompt ([#1150](https://github.com/appium/WebDriverAgent/issues/1150)) ([98d79e7](https://github.com/appium/WebDriverAgent/commit/98d79e7c3875424cb4b5fdee55bb079286a14b05))

## [13.2.2](https://github.com/appium/WebDriverAgent/compare/v13.2.1...v13.2.2) (2026-06-06)

### Miscellaneous Chores

* Refactor session creation handler ([#1149](https://github.com/appium/WebDriverAgent/issues/1149)) ([923b523](https://github.com/appium/WebDriverAgent/commit/923b523b55f880b921de2c95a82786ce0699cb9d))

## [13.2.1](https://github.com/appium/WebDriverAgent/compare/v13.2.0...v13.2.1) (2026-06-06)

### Miscellaneous Chores

* Refactor settings handling API ([#1148](https://github.com/appium/WebDriverAgent/issues/1148)) ([ff7ac36](https://github.com/appium/WebDriverAgent/commit/ff7ac368debb22659509169a0eca530bae3dc879))

## [13.2.0](https://github.com/appium/WebDriverAgent/compare/v13.1.3...v13.2.0) (2026-05-26)

### Features

* Add XPath extensions ([#1144](https://github.com/appium/WebDriverAgent/issues/1144)) ([a975b89](https://github.com/appium/WebDriverAgent/commit/a975b89ac998d31a72bf3723b843d85af8867cf0))

## [13.1.3](https://github.com/appium/WebDriverAgent/compare/v13.1.2...v13.1.3) (2026-05-24)

### Bug Fixes

* Scheme for derived data path retrieval ([#1142](https://github.com/appium/WebDriverAgent/issues/1142)) ([9ada5f6](https://github.com/appium/WebDriverAgent/commit/9ada5f6fe2af29278c488e845f8714f22fabfeee))

## [13.1.2](https://github.com/appium/WebDriverAgent/compare/v13.1.1...v13.1.2) (2026-05-23)

### Bug Fixes

* Address compilation warnings ([#1143](https://github.com/appium/WebDriverAgent/issues/1143)) ([f1f9976](https://github.com/appium/WebDriverAgent/commit/f1f9976f4a0a0fb8a8aa3ee1f2483b25275600e6))

## [13.1.1](https://github.com/appium/WebDriverAgent/compare/v13.1.0...v13.1.1) (2026-05-22)

### Bug Fixes

* ship Scripts/embed-runner-icon.sh in the npm package ([#1141](https://github.com/appium/WebDriverAgent/issues/1141)) ([17ac1c1](https://github.com/appium/WebDriverAgent/commit/17ac1c16a0890ee0fbfe73504a3ff570dfe1a7bf)), closes [#1138](https://github.com/appium/WebDriverAgent/issues/1138)

## [13.1.0](https://github.com/appium/WebDriverAgent/compare/v13.0.0...v13.1.0) (2026-05-21)

### Features

* add app icon to WebDriverAgentRunner ([#1138](https://github.com/appium/WebDriverAgent/issues/1138)) ([fe8adc8](https://github.com/appium/WebDriverAgent/commit/fe8adc89923994428783397170de850e11ebb3c6))
* Add helper method to fetch build settings ([#1139](https://github.com/appium/WebDriverAgent/issues/1139)) ([56b5f38](https://github.com/appium/WebDriverAgent/commit/56b5f384ed9ba1a014d4b642ddf26b8573ceaafe))

## [13.0.0](https://github.com/appium/WebDriverAgent/compare/v12.2.2...v13.0.0) (2026-05-17)

### ⚠ BREAKING CHANGES

* quitAndUninstall() removed — use quit() only. App uninstall is out of scope for this module.
* uninstall() removed — WDA must not be uninstalled from this package; callers (e.g. xcuitest-driver) should own that if needed.
* setupCaching() no longer uninstalls WDA — on bundle-id or version mismatch it logs and skips caching instead of removing apps from the device. Also, it now returns the cached url on success.
* appium-ios-device dependency removed — preinstalled WDA on real devices always launches via devicectl (no iOS < 17 Xctest fallback).

### Features

* Drop legacy APIs ([#1137](https://github.com/appium/WebDriverAgent/issues/1137)) ([8995d24](https://github.com/appium/WebDriverAgent/commit/8995d24e16634a4624918319996839993502c7b4))

## [12.2.2](https://github.com/appium/WebDriverAgent/compare/v12.2.1...v12.2.2) (2026-05-08)

### Bug Fixes

* linter ([#1134](https://github.com/appium/WebDriverAgent/issues/1134)) ([2bd1816](https://github.com/appium/WebDriverAgent/commit/2bd181628a1d4525a8f1c459ea295ac0541b514c))

## [12.2.1](https://github.com/appium/WebDriverAgent/compare/v12.2.0...v12.2.1) (2026-05-06)

### Miscellaneous Chores

* **deps-dev:** bump sinon from 21.1.2 to 22.0.0 ([#1133](https://github.com/appium/WebDriverAgent/issues/1133)) ([11c579b](https://github.com/appium/WebDriverAgent/commit/11c579b7ed3a9995715d65590a2959763871aa6d))

## [12.2.0](https://github.com/appium/WebDriverAgent/compare/v12.1.1...v12.2.0) (2026-04-29)

### Features

* Ditch bluebird and lodash ([#1130](https://github.com/appium/WebDriverAgent/issues/1130)) ([8899895](https://github.com/appium/WebDriverAgent/commit/88998951f004daed1d22ce2c06eec89a08129e4f))

## [12.1.1](https://github.com/appium/WebDriverAgent/compare/v12.1.0...v12.1.1) (2026-04-27)

### Miscellaneous Chores

* **compile:** fix compilation ([#1129](https://github.com/appium/WebDriverAgent/issues/1129)) ([76d59e8](https://github.com/appium/WebDriverAgent/commit/76d59e85c75680c97abe9e67fdf4a70cacd46418))

## [12.1.0](https://github.com/appium/WebDriverAgent/compare/v12.0.0...v12.1.0) (2026-04-24)

### Features

* **client:** add ability to set headers on requests ([#1127](https://github.com/appium/WebDriverAgent/issues/1127)) ([a8889cd](https://github.com/appium/WebDriverAgent/commit/a8889cd7cb85c1b58faee306295fb3c5c2a9d0e3))

## [12.0.0](https://github.com/appium/WebDriverAgent/compare/v11.4.3...v12.0.0) (2026-04-14)

### ⚠ BREAKING CHANGES

* remove idb from AppleDevice; clients must stop passing device.idb.
* remove includeNonModalElements WDA setting; clients must stop sending this setting in /settings.
* remove shouldUseTestManagerForVisibilityDetection capability; clients must stop sending this desired capability.

### Code Refactoring

* remove deprecated WDA settings/capabilities and idb typing ([#1124](https://github.com/appium/WebDriverAgent/issues/1124)) ([5072e25](https://github.com/appium/WebDriverAgent/commit/5072e255faa3538f5ff4c8769bf16fd290ee8af9))

## [11.4.3](https://github.com/appium/WebDriverAgent/compare/v11.4.2...v11.4.3) (2026-04-12)

### Miscellaneous Chores

* **deps-dev:** bump typescript from 5.9.3 to 6.0.2 ([#1121](https://github.com/appium/WebDriverAgent/issues/1121)) ([046b080](https://github.com/appium/WebDriverAgent/commit/046b08042df33f507466f55b68b444c91684931a))

## [11.4.2](https://github.com/appium/WebDriverAgent/compare/v11.4.1...v11.4.2) (2026-04-12)

### Bug Fixes

* Avoid keeping strong reference to self instance in delegates ([#1123](https://github.com/appium/WebDriverAgent/issues/1123)) ([dd15f48](https://github.com/appium/WebDriverAgent/commit/dd15f48d33edabef6aea8ac951cf539946b492f2))

## [11.4.1](https://github.com/appium/WebDriverAgent/compare/v11.4.0...v11.4.1) (2026-03-15)

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source "https://rubygems.org"

gem "fastlane", '~> 2.229'
gem "multi_json"
3 changes: 3 additions & 0 deletions PrivateHeaders/XCTest/CDStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ typedef struct {
unsigned short _field3[1];
} CDStruct_27a325c0;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
int _XCTSetApplicationStateTimeout(double timeout);
double _XCTApplicationStateTimeout(void);
#pragma clang diagnostic pop
3 changes: 3 additions & 0 deletions PrivateHeaders/XCTest/XCTestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

#import <WebDriverAgentLib/CDStructures.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
@class NSInvocation, XCTestCaseRun, XCTestContext, _XCTestCaseImplementation;
#pragma clang diagnostic pop

@interface XCTestCase()
{
Expand Down
11 changes: 9 additions & 2 deletions Scripts/build-webdriveragent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const WDA_BUNDLE_TV_PATH = path.join(DERIVED_DATA_PATH, 'Build', 'Products', 'De
const TARGETS = ['runner', 'tv_runner'];
const SDKS = ['sim', 'tv_sim'];

/**
* Build WebDriverAgent and pack the app bundle into a zip archive.
*
* @param {string} [xcodeVersion] Xcode version to include in archive name.
*/
async function buildWebDriverAgent (xcodeVersion) {
const target = process.env.TARGET;
const sdk = process.env.SDK;
Expand Down Expand Up @@ -77,10 +82,12 @@ async function buildWebDriverAgent (xcodeVersion) {
}

if (isMainModule) {
buildWebDriverAgent().catch((e) => {
try {
await buildWebDriverAgent();
} catch (e) {
LOG.error(e);
process.exit(1);
});
}
}

export default buildWebDriverAgent;
Expand Down
87 changes: 87 additions & 0 deletions Scripts/embed-runner-icon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
# Embed the WDA app icon into the wrapping XCTRunner host app so the
# installed WebDriverAgent shows the Appium logo on the iOS home screen
# instead of a blank icon.
#
# Apple's USES_XCTRUNNER auto-generates a Runner.app around UI-testing
# .xctest bundles but does not inherit icons from the test bundle's
# asset catalog. actool produces AppIcon*.png + Assets.car inside
# PlugIns/<product>.xctest/ where iOS never looks. This script lifts
# them up to the Runner.app root and patches Info.plist accordingly.
#
# Limitations:
# - Touches XCTRunner internals; may need updates across Xcode versions.
# - iOS only; tvOS uses different "Brand Assets" and is not handled.
# - Cloud device farms that re-sign WDA must preserve these changes.

set -euo pipefail

RUNNER_APP="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}-Runner.app"
XCTEST="${RUNNER_APP}/PlugIns/${PRODUCT_NAME}.xctest"

if [ ! -d "$RUNNER_APP" ]; then
echo "warning: ${PRODUCT_NAME}-Runner.app not found at $RUNNER_APP; skipping icon embed"
exit 0
fi

if [ ! -d "$XCTEST" ]; then
echo "warning: ${PRODUCT_NAME}.xctest not found inside Runner.app; skipping icon embed"
exit 0
fi

shopt -s nullglob
ICONS=("$XCTEST"/AppIcon*.png)
if [ ${#ICONS[@]} -eq 0 ]; then
echo "warning: no compiled AppIcon*.png found inside $XCTEST; skipping icon embed"
exit 0
fi

cp -f "${ICONS[@]}" "$RUNNER_APP/"
if [ -f "$XCTEST/Assets.car" ]; then
cp -f "$XCTEST/Assets.car" "$RUNNER_APP/"
fi

PLIST="$RUNNER_APP/Info.plist"
/usr/libexec/PlistBuddy -c "Delete :CFBundleIcons" "$PLIST" 2>/dev/null || true
/usr/libexec/PlistBuddy -c "Delete :CFBundleIcons~ipad" "$PLIST" 2>/dev/null || true

/usr/libexec/PlistBuddy -c "Add :CFBundleIcons dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons:CFBundlePrimaryIcon dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconName string AppIcon" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles array" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:0 string AppIcon60x60" "$PLIST"

/usr/libexec/PlistBuddy -c "Add :CFBundleIcons~ipad dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons~ipad:CFBundlePrimaryIcon dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons~ipad:CFBundlePrimaryIcon:CFBundleIconName string AppIcon" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons~ipad:CFBundlePrimaryIcon:CFBundleIconFiles array" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons~ipad:CFBundlePrimaryIcon:CFBundleIconFiles:0 string AppIcon60x60" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleIcons~ipad:CFBundlePrimaryIcon:CFBundleIconFiles:1 string AppIcon76x76" "$PLIST"

# Re-codesign since we modified the bundle after Xcode signed it.
# In a scheme post-action context Xcode's CODE_SIGN_* env vars are not exposed,
# so discover the existing signing identity from the already-signed bundle.
if [ -d "$RUNNER_APP/_CodeSignature" ]; then
# Capture the signature info once. Piping codesign straight into
# `awk ... exit` makes awk close the pipe early, killing codesign with
# SIGPIPE -- which `set -o pipefail` turns into a fatal error. That trips
# only when an Authority line exists, i.e. on every real-device build.
SIGN_INFO=$(codesign -dvv "$RUNNER_APP" 2>&1 || true)
EXISTING_IDENT="${EXPANDED_CODE_SIGN_IDENTITY:-}"
if [ -z "$EXISTING_IDENT" ]; then
EXISTING_IDENT=$(awk -F'=' '/^Authority/ {print $2; exit}' <<< "$SIGN_INFO")
fi
# Simulator builds are ad-hoc signed: there is no Authority line, but the
# bundle can still be re-signed ad-hoc with an identity of "-".
if [ -z "$EXISTING_IDENT" ] && grep -q '^Signature=adhoc' <<< "$SIGN_INFO"; then
EXISTING_IDENT="-"
fi
if [ -n "$EXISTING_IDENT" ]; then
codesign --force --sign "$EXISTING_IDENT" \
--preserve-metadata=identifier,entitlements "$RUNNER_APP"
else
echo "warning: bundle is signed but no identity discovered; signature will be invalid"
fi
fi

echo "embedded icon into $RUNNER_APP"
Loading