Before submitting a new issue
Bug summary
Hi and first thank you for making this port of react-native-otp-verify 🙏
I'm getting this error at runtime:
[runtime not ready]: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'ReactNativeOtpVerify' could not be found. Verify that a module by this name is registered in the native binary.
I added the dependency exclusion rule for iOS in react-native.config.js as prescribed.
Maybe my understanding of TurboModules is wrong but I think the issue here is that RN tries to load the module at runtime, and of course it's not present on iOS.
What worked for me is to move the iOSProxy logic into NativeReactNativeOtpVerify.ts itself rather than in the index.tsx, so TurboModuleRegistry.getEnforcing('ReactNativeOtpVerify') is never even called on iOS at all:
NativeReactNativeOtpVerify.ts
-export default TurboModuleRegistry.getEnforcing<Spec>('ReactNativeOtpVerify');
+
+// iOS is not supported - throw error on iOS
+const throwIOSError = (): never => {
+ throw new Error(
+ 'react-native-otp-verify is only available on Android. iOS is not supported.'
+ );
+};
+
+// Create proxy for iOS that throws errors
+const iOSProxy = new Proxy(
+ {},
+ {
+ get() {
+ return throwIOSError;
+ },
+ }
+) as Spec;
+
+
+export default Platform.OS === 'ios'
+? iOSProxy
+: TurboModuleRegistry.getEnforcing<Spec>('ReactNativeOtpVerify');
index.tsx
-// iOS is not supported - throw error on iOS
-const throwIOSError = (): never => {
- throw new Error(
- 'react-native-otp-verify is only available on Android. iOS is not supported.'
- );
-};
-
-// Create proxy for iOS that throws errors
-const iOSProxy = new Proxy(
- {},
- {
- get() {
- return throwIOSError;
- },
- }
-) as Spec;
-
const OtpVerify: Spec =
- Platform.OS === 'ios'
- ? iOSProxy
- : ReactNativeOtpVerify
+ ReactNativeOtpVerify
Library version
1.0.0
Environment info
System:
OS: macOS 15.6.1
CPU: (16) arm64 Apple M3 Max
Memory: 335.72 MB / 48.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.9.0
path: /Users/melvynhills/.nvm/versions/node/v24.9.0/bin/node
Yarn: Not Found
npm:
version: 11.6.0
path: /Users/melvynhills/.nvm/versions/node/v24.9.0/bin/npm
Watchman:
version: 2024.08.26.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.1
- iOS 18.1
- macOS 15.1
- tvOS 18.1
- visionOS 2.1
- watchOS 11.1
Android SDK: Not Found
IDEs:
Android Studio: 2024.2 AI-242.23339.11.2421.12550806
Xcode:
version: 16.1/16B40
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 19.1.0
wanted: 19.1.0
react-native:
installed: 0.81.4
wanted: 0.81.4
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Expo: 54.0.12
Steps to reproduce
- Import anything from the library in your code
- Build and run for iOS
- npm i
- npx expo prebuild --clean
- npx expo run:ios
Reproducible example repository
https://github.com/melvynhills/otp-verify-bug
Before submitting a new issue
Bug summary
Hi and first thank you for making this port of react-native-otp-verify 🙏
I'm getting this error at runtime:
[runtime not ready]: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'ReactNativeOtpVerify' could not be found. Verify that a module by this name is registered in the native binary.I added the dependency exclusion rule for iOS in
react-native.config.jsas prescribed.Maybe my understanding of TurboModules is wrong but I think the issue here is that RN tries to load the module at runtime, and of course it's not present on iOS.
What worked for me is to move the iOSProxy logic into
NativeReactNativeOtpVerify.tsitself rather than in theindex.tsx, soTurboModuleRegistry.getEnforcing('ReactNativeOtpVerify')is never even called on iOS at all:NativeReactNativeOtpVerify.ts
index.tsx
Library version
1.0.0
Environment info
System: OS: macOS 15.6.1 CPU: (16) arm64 Apple M3 Max Memory: 335.72 MB / 48.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 24.9.0 path: /Users/melvynhills/.nvm/versions/node/v24.9.0/bin/node Yarn: Not Found npm: version: 11.6.0 path: /Users/melvynhills/.nvm/versions/node/v24.9.0/bin/npm Watchman: version: 2024.08.26.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.16.2 path: /usr/local/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 24.1 - iOS 18.1 - macOS 15.1 - tvOS 18.1 - visionOS 2.1 - watchOS 11.1 Android SDK: Not Found IDEs: Android Studio: 2024.2 AI-242.23339.11.2421.12550806 Xcode: version: 16.1/16B40 path: /usr/bin/xcodebuild Languages: Java: version: 17.0.10 path: /usr/bin/javac Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 19.1.0 wanted: 19.1.0 react-native: installed: 0.81.4 wanted: 0.81.4 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: Not found newArchEnabled: Not found iOS: hermesEnabled: Not found newArchEnabled: Not found Expo: 54.0.12Steps to reproduce
Reproducible example repository
https://github.com/melvynhills/otp-verify-bug