Skip to content

fix(environment): return a value on visionOS from isAppExtension - #262

Open
paulb777 wants to merge 2 commits into
mainfrom
pb-visionos-return-values
Open

paulb777 wants to merge 2 commits into
mainfrom
pb-visionos-return-values

Conversation

@paulb777

Copy link
Copy Markdown
Member

On visionOS, three functions in GULAppEnvironmentUtil.m end without returning a value: +isAppExtension, HasSCInfoFolder() and HasEmbeddedMobileProvision(). Their #if covered TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH and then TARGET_OS_OSX, but TARGET_OS_IOS is 0 on visionOS, so neither branch is compiled there. The caller gets whatever is left in the return register or on the stack. SwiftPM builds pass -Wno-return-type, and CI doesn't run the tests on visionOS, so nothing reported it.

Effects on visionOS

  • +isAppExtension can return YES in an app. Then GULAppDelegateSwizzler and GULSceneDelegateSwizzler skip swizzling, and +supportsBackgroundURLSessionUploads returns NO. FirebaseCore uses it to decide whether a second configure call is allowed, and FIRBundleUtil uses it when matching bundle IDs.
  • On devices, +isFromAppStore could be wrong, because it depends on HasSCInfoFolder() and HasEmbeddedMobileProvision(). On simulators it returns NO before reaching them.

We found this in firebase/firebase-ios-sdk#17142. There, an unrelated change to FirebaseCore altered the stack contents, and the visionOS Simulator jobs on Xcode 26 started seeing isAppExtension return YES.

Fix

Each function now checks TARGET_OS_OSX first and uses the bundle-based check in the #else branch. So visionOS gets the same checks as iOS, and no platform can fall through without returning. Behavior on iOS, Mac Catalyst, tvOS, watchOS and macOS is unchanged. Building the package with -Wreturn-type for each platform now reports no warnings; before this change, visionOS reported these three.

Tests

  • testIsAppExtensionInAppExtensionBundle swizzles -[NSBundle bundlePath] to return an .appex path, and expects isAppExtension to be YES everywhere except macOS. testIsAppExtension checks that the test runner isn't reported as an extension.

Not included: visionOS in CI

CI still doesn't run the tests on visionOS. On a visionOS Simulator the full suite has two other failures: testProxyRemoteNotificationsMethodsEmptyAppDelegate and testProxyRemoteNotificationsMethodsEmptyAppDelegateAfterInitialProxy expect application:handleEventsForBackgroundURLSession:completionHandler: to be proxied on visionOS. GULAppDelegateSwizzler only proxies it under TARGET_OS_IOS || TARGET_OS_TV. Fixing that changes swizzling behavior on visionOS, so it should be a separate PR, after which visionOS can join the spm matrix.

Testing

  • visionOS 27.2 Simulator (Xcode 27.2), full GoogleUtilities-Package test scheme: 170 unit tests ran, and only the two swizzler tests above failed. They're unrelated to this change.
  • visionOS 27.2 Simulator, GULAppEnvironmentUtilTest: all 9 tests pass with the fix. With only the test change, testIsAppExtensionInAppExtensionBundle fails.
  • macOS (Xcode 27.2, swift build and xctest): all 9 GULAppEnvironmentUtilTest tests pass.
  • swift build -Xcc -Wreturn-type for the visionOS, iOS, tvOS and watchOS Simulators and for macOS: no -Wreturn-type warnings.
  • clang-format reports the changed files as clean.

This PR was prepared with AI assistance.

+isAppExtension, HasSCInfoFolder() and HasEmbeddedMobileProvision() only
had branches for TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH and for
TARGET_OS_OSX. TARGET_OS_IOS is 0 on visionOS, so they ended without
returning a value there, and callers got whatever was left over. Check
TARGET_OS_OSX first and use the bundle-based checks everywhere else, so
visionOS gets the same checks as iOS.
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.

2 participants