Skip to content

fix(ios): prevent keychain precondition crash on unsigned and test builds#1440

Merged
datlechin merged 1 commit into
mainfrom
fix/ios-tests-keychain-launch-crash
May 27, 2026
Merged

fix(ios): prevent keychain precondition crash on unsigned and test builds#1440
datlechin merged 1 commit into
mainfrom
fix/ios-tests-keychain-launch-crash

Conversation

@datlechin
Copy link
Copy Markdown
Member

Problem

The iOS Tests CI job has failed on every commit since it was added (back to mid-May), with:

TableProMobile encountered an error (Early unexpected exit, operation never finished bootstrapping. Test crashed with signal trap before establishing connection.)

The result bundle shows passedTests: 0 — the host app crashes at launch before a single test runs. Not specific to any recent PR.

Root cause

KeychainSecureStore.resolveAccessGroup() called preconditionFailure(...) when AppIdentifierPrefix is absent or still the unsubstituted literal $(AppIdentifierPrefix). That is exactly the case in the CI build, which runs with CODE_SIGNING_ALLOWED=NO (no signing means no AppIdentifierPrefix). KeychainSecureStore() is constructed in AppState.init, which runs at app launch, so the precondition trips (SIGTRAP) before tests connect. Signed device/TestFlight builds always have the prefix, so they never hit it.

Fix

  • The keychain access group is only needed to share items with the widget extension; an app works fine on its own default keychain without one. resolveAccessGroup() now returns String? and logs a warning instead of crashing when the prefix is unavailable. Queries include kSecAttrAccessGroup only when an access group is present. Signed builds are unchanged (they still get the shared group).
  • Hardened the documented "skip launch side-effects under tests" guard: it keyed off XCTestConfigurationFilePath, which is not set under Swift Testing (the suite uses @Suite/@Test). New TestRuntime.isActive also checks XCTestBundlePath and NSClassFromString("XCTestCase"), so analytics, CloudKit sync, widget, and Spotlight side-effects are reliably skipped during tests as the author intended. Centralizes a check that was duplicated in AppState and TableProMobileApp.

Notes

  • No user-facing behavior change for signed builds, so no CHANGELOG entry.
  • This unblocks the iOS Tests job for the first time; the run on this PR should now actually execute the suite.

@datlechin datlechin force-pushed the fix/ios-tests-keychain-launch-crash branch from da29256 to 46c24c7 Compare May 27, 2026 17:36
@datlechin datlechin merged commit c5c9208 into main May 27, 2026
3 checks passed
@datlechin datlechin deleted the fix/ios-tests-keychain-launch-crash branch May 27, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant