I want to integrate React Native into my existing iOS application. In this process, I am getting an error on the iOS side. When I click on the button I added to the screen, a “white” screen appears. Below is the Xcode error log:
2024-07-23 17:17:35.497108+0300 AppName[76388:4673739] [javascript] **Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.**
2024-07-23 17:17:35.503810+0300 AppName[76388:4673739] [javascript] Error: **Requiring module "node_modules/react-native/Libraries/Core/InitializeCore.js", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.**
2024-07-23 17:17:35.505193+0300 AppName[76388:4673670] [connection] nw_socket_handle_socket_event [C22:1] Socket SO_ERROR [61: Connection refused]
2024-07-23 17:17:35.505400+0300 AppName[76388:4673675] [connection] nw_connection_get_connected_socket [C22] Client called nw_connection_get_connected_socket on unconnected nw_connection
2024-07-23 17:17:35.505520+0300 AppName[76388:4673675] TCP Conn 0x6000036484d0 Failed : error 0:61 [61]
2024-07-23 17:17:35.505558+0300 AppName[76388:4673739] [javascript] **Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.**
*This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.*
TrustKit log: Proxy-ing NSURLSessionDelegate: fir_68A76C75-C381-4599-8E49-EDB57141B802_GULNetworkURLSession
TrustKit log: Checking includeSubdomains configuration for nnhayatemeklilik.com.tr
TrustKit log: Domain app-analytics-services.com is not pinned
2024-07-23 17:17:35.778295+0300 AppName[76388:4673675] [boringssl] boringssl_metrics_log_metric_block_invoke(153) Failed to log metrics
TrustKit log: Proxy-ing NSURLSessionDelegate: fir_98A27892-1E8B-4578-B4CD-3646C9B67338_GDTCCTUploadOperation
2024-07-23 17:17:35.872116+0300 AppName[76388:4673675] 10.25.0 - [FirebasePerformance][I-PRF100009] Logging network request trace - https://app-analytics-services.com/a, Response code: 204, 187.6080ms
TrustKit log: Checking includeSubdomains configuration for nnhayatemeklilik.com.tr
TrustKit log: Domain firebaselogging-pa.googleapis.com is not pinned
2024-07-23 17:17:35.981273+0300 AppName[76388:4673675] [boringssl] boringssl_metrics_log_metric_block_invoke(153) Failed to log metrics
I have attempted the following steps:
- Checked the PodFile to ensure all necessary dependencies are included.
- Verified the index.js file to make sure the React Native component is registered correctly.
- Examined the ViewController.swift file to ensure the React Native view is being presented correctly.
Here are the relevant files for context:
PodFile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip
# Uncomment the next line to define a global platform for your project
platform:ios, min_ios_version_supported
#prepare_react_native_project!
# ignore all warnings from all pods
#inhibit_all_warnings!
use_frameworks!
def core_dependencies
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'RxSwift'
pod 'RxCocoa'
pod 'SnapKit', '~> 4.0.0'
pod 'DropDown', '2.3.2'
...
end
target 'AppName' do
config = use_native_modules!
use_frameworks!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => false, # Hermes kullanıyorsanız, true yapın
)
core_dependencies
end
target 'AppName Sandbox' do
core_dependencies
end
post_install do |installer|
flipper_post_install(installer)
# Ekstra post_install ayarlarınız
installer.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
index.js
import React from 'react';
import {
AppRegistry,
Text,
View
} from 'react-native';
const HelloWorld = () => {
return (
<View>
<Text>Hello, World</Text>
</View>
);
};
AppRegistry.registerComponent(
'MyReactNativeApp',
() => HelloWorld
);
ViewController.swift:
import UIKit
import SnapKit
import SwiftEventBus
import RxSwift
import RevealingSplashView
import SVProgressHUD
import FirebaseCrashlytics
import FirebaseAnalytics
import React
class HomeViewController: BaseViewController {
private var loginButton2: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
loginButton2 = UIManager.pumpkinButton(with: .medium, title: R.string.localizable.goruntule(), horizontalPadding: nil)
view.addSubview(loginButton2)
loginButton2.addTarget(self, action: #selector(highScoreButtonTapped(sender:)), for: .touchUpInside)
}
@IBAction func highScoreButtonTapped(sender : UIButton) {
NSLog("Hello")
let jsCodeLocation = URL(string: "http://192.168.1.37:8081/index.bundle?platform=ios")
let mockData:NSDictionary = ["scores":
[
["name":"Alex", "value":"42"],
["name":"Joel", "value":"10"]
]
]
let rootView = RCTRootView(
bundleURL: jsCodeLocation!,
moduleName: "MyReactNativeApp",
initialProperties: mockData as [NSObject : AnyObject],
launchOptions: nil
)
let vc = UIViewController()
vc.view = rootView
customPresentViewController(presenter, viewController: vc, animated: true, completion: nil)
}
}
enter image description here
I was expecting the React Native view to display correctly when the button is clicked. Instead, I am encountering a white screen with multiple errors in the Xcode console. I have tried verifying the module registration and ensuring all dependencies are correctly installed in the PodFile, but the issue persists.
Expected Results:
The React Native view should display correctly without any errors.
The button click should navigate to the React Native view with the expected content.
Actual Results:
Clicking the button results in a white screen.
Multiple errors related to module registration and initialization are logged in the Xcode console.
Any guidance or suggestions on how to resolve this issue would be greatly appreciated
özcan sarı is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.