fix(device-utils): expose LaunchOptionsStore singleton to ObjC runtime#59
Merged
Merged
Conversation
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).
ByteZhang1024
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On iOS,
getStartupTime()always returned0because the app'sAppDelegatecould never write intoLaunchOptionsStore.shared.Root cause
The app reaches the singleton through an
NSClassFromString+ KVC bridge (value(forKeyPath: "shared")). A Swiftstatic letstored type property is not exposed to the Objective-C runtime even under@objcMembers, so the lookup returned nil and everysetValue(_:forKey:)(startupTime, deviceToken, launchOptions) silently no-opped.startupTimestayed at its default0, 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 toLaunchOptionsStore(static funcs are exposed to the ObjC runtime, unlike static-let stored properties), mirroring the workingBundleUpdateStorepattern. The app then resolves the singleton viaperform("sharedInstance").Published as
@onekeyfe/react-native-device-utils@3.0.38; consumed in app-monorepo via OneKeyHQ/app-monorepo#11833.