Anonymous
React Native IOS Simulator показывает пустой белый экран - отлично работает на Android
Сообщение
Anonymous » 14 авг 2025, 14:34
Описание проблемы < /h2>
У меня есть нативный проект React, который идеально работает на Android, но показывает только пустой белый экран при запуске на iOS -симуляторе. When building and running through XCode, I can see the app launches but only displays a white screen.
Environment Details
React Native Version : 0.74.5 (upgraded from 0.69.3)
iOS Development Target : 13.4
node.js версии : v18.20.8 (через NVM)
платформа : macos sonoma (x86_64)
xcode : строительство для ios simulator
Конфигурация проекта < /h2>
appdelegate.mm
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTAppSetupPrepareApp(application, false);
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"mobile_1969", nil, YES);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
< /code>
podfile (ключевые части) < /h3>
platform :ios, '13.4'
install! 'cocoapods', :deterministic_uuids => false
# Hermes enabled
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
< /code>
metro config < /h3>
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const config = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};
module.exports = mergeConfig(defaultConfig, config);
< /code>
index.js точка входа < /h3>
import React from 'react'
import 'react-native-gesture-handler'
import { AppRegistry } from 'react-native'
import App from './App'
import { name as appName } from './app.json'
import { Provider } from 'react-redux'
import { store, persistor } from './src/store'
import { PersistGate } from 'redux-persist/integration/react'
import ErrorBoundary from './src/components/error/ErrorBoundary'
const Application = () => (
)
AppRegistry.registerComponent(appName, () => Application)
< /code>
зависимости от ключей < /h3>
{
"react": "18.2.0",
"react-native": "0.74.5",
"react-native-gesture-handler": "^1.10.3",
"react-native-screens": "3.27.0",
"react-native-safe-area-context": "^1.0.0",
"@react-navigation/native": "^5.3.0",
"@react-navigation/stack": "^5.3.2",
"react-redux": "^7.2.0",
"redux-persist": "^5.10.0"
}
[/code]
Steps Tried
Android : App runs perfectly - all UI components and navigation work
iOS Simulator : Only shows white/blank screen
Clean builds : Deleted Pods, , ran pod install Podfile.lock
Metro cache reset : npx react-native start --reset-cache
Simulator reset : Erased all content and settings
Вопросы < /h2>
Почему мост React сразу же инвалидируется на iOS, но хорошо работает над Android? В частности? Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/797 ... on-android
1755171260
Anonymous
Описание проблемы < /h2> У меня есть нативный проект React, который идеально работает на Android, но показывает только пустой белый экран при запуске на iOS -симуляторе. When building and running through XCode, I can see the app launches but only displays a white screen. Environment Details [list] [*][b]React Native Version[/b]: 0.74.5 (upgraded from 0.69.3) [*][b]iOS Development Target[/b]: 13.4 [*][b] node.js версии [/b]: v18.20.8 (через NVM) [*] [b] платформа [/b]: macos sonoma (x86_64) [*] [b] xcode [/b]: строительство для ios simulator Конфигурация проекта < /h2> appdelegate.mm - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RCTAppSetupPrepareApp(application, false); RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"mobile_1969", nil, YES); if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; } self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } < /code> podfile (ключевые части) < /h3> platform :ios, '13.4' install! 'cocoapods', :deterministic_uuids => false # Hermes enabled use_react_native!( :path => config[:reactNativePath], :hermes_enabled => true, :fabric_enabled => flags[:fabric_enabled], :app_path => "#{Pod::Config.instance.installation_root}/.." ) < /code> metro config < /h3> const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); const defaultConfig = getDefaultConfig(__dirname); const config = { transformer: { getTransformOptions: async () => ({ transform: { experimentalImportSupport: false, inlineRequires: true, }, }), babelTransformerPath: require.resolve('react-native-svg-transformer'), }, resolver: { assetExts: assetExts.filter(ext => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], }, }; module.exports = mergeConfig(defaultConfig, config); < /code> index.js точка входа < /h3> import React from 'react' import 'react-native-gesture-handler' import { AppRegistry } from 'react-native' import App from './App' import { name as appName } from './app.json' import { Provider } from 'react-redux' import { store, persistor } from './src/store' import { PersistGate } from 'redux-persist/integration/react' import ErrorBoundary from './src/components/error/ErrorBoundary' const Application = () => ( ) AppRegistry.registerComponent(appName, () => Application) < /code> зависимости от ключей < /h3> { "react": "18.2.0", "react-native": "0.74.5", "react-native-gesture-handler": "^1.10.3", "react-native-screens": "3.27.0", "react-native-safe-area-context": "^1.0.0", "@react-navigation/native": "^5.3.0", "@react-navigation/stack": "^5.3.2", "react-redux": "^7.2.0", "redux-persist": "^5.10.0" } [/code] Steps Tried [list] [*]✅ [b]Android[/b]: App runs perfectly - all UI components and navigation work [*]❌ [b]iOS Simulator[/b]: Only shows white/blank screen [*][b]Clean builds[/b]: Deleted Pods, , ran pod install Podfile.lock [*][b]Metro cache reset[/b]: npx react-native start --reset-cache [*][b]Simulator reset[/b]: Erased all content and settings [/list] Вопросы < /h2> Почему мост React сразу же инвалидируется на iOS, но хорошо работает над Android? В частности? Заранее спасибо. Подробнее здесь: [url]https://stackoverflow.com/questions/79735340/react-native-ios-simulator-shows-blank-white-screen-works-fine-on-android[/url]