Skip to content

fix(device-utils): expose LaunchOptionsStore singleton to ObjC runtime#59

Merged
huhuanming merged 2 commits into
mainfrom
fix/ios-launch-options-store-objc-accessor
May 29, 2026
Merged

fix(device-utils): expose LaunchOptionsStore singleton to ObjC runtime#59
huhuanming merged 2 commits into
mainfrom
fix/ios-launch-options-store-objc-accessor

Conversation

@huhuanming
Copy link
Copy Markdown
Contributor

Problem

On iOS, getStartupTime() always returned 0 because the app's AppDelegate could never write into LaunchOptionsStore.shared.

Root cause

The app reaches the singleton through an NSClassFromString + KVC bridge (value(forKeyPath: "shared")). A Swift static let stored type property is not exposed to the Objective-C runtime even under @objcMembers, so the lookup returned nil and every setValue(_:forKey:) (startupTime, deviceToken, launchOptions) silently no-opped. startupTime stayed at its default 0, so launch timing events were never reported on iOS (Android, which sets the value via a real static method, was unaffected).

Fix

Add a sharedInstance() class method to LaunchOptionsStore (static funcs are exposed to the ObjC runtime, unlike static-let stored properties), mirroring the working BundleUpdateStore pattern. The app then resolves the singleton via perform("sharedInstance").

Published as @onekeyfe/react-native-device-utils@3.0.38; consumed in app-monorepo via OneKeyHQ/app-monorepo#11833.

Add a sharedInstance() class method so the app's NSClassFromString +
perform() bridge can reach the singleton. A Swift static let stored type
property is invisible to the Objective-C runtime even under @objcMembers,
so the app's KVC value(forKeyPath: "shared") lookup returned nil and every
store?.setValue(...) write (startupTime, deviceToken, launchOptions)
silently no-opped on iOS. This left startupTime at 0, so getStartupTime()
returned 0 and iOS launch timing events were never reported (Android, which
sets the value via a real static method, was unaffected).
@huhuanming huhuanming merged commit 09b0444 into main May 29, 2026
3 checks passed
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