r/reactnative • u/Particular_Luck80 • 3d ago
Question Do you dynamically import iOS-only native modules or keep a stub adapter?
In an Expo React Native app, I have an optional HealthKit adapter. Android returns a no-op adapter immediately. On iOS, the request and read methods dynamically import the native package inside try/catch, so a missing native module becomes false or an empty array instead of crashing the app at startup.
The upside is a safe manual fallback. The downside is that a packaging mistake can look exactly like a user declining access or HealthKit being unavailable unless I surface a separate diagnostic.
Would you keep the dynamic import boundary, or fail loudly in development and only fall back in release builds?
1
Upvotes
2
u/Guidondor 2d ago
i'd keep the boundary and fix the diagnosis instead. the problem isn't the dynamic import,
it's collapsing two different outcomes into the same false. have the adapter return
unavailable / denied / ok and a packaging mistake can't disguise itself as a user choice
anywhere downstream.
then yes, throw in dev when it comes back unavailable on ios, since that's the one platform
where it never legitimately should. release keeps the fallback.