-
Notifications
You must be signed in to change notification settings - Fork 326
Description
新创建的一个空项目,报错信息:
package.json内容:
{
"name": "RNOfficeApp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native/new-app-screen": "0.83.1",
"react": "19.2.0",
"react-native": "^0.83.1",
"react-native-safe-area-context": "^5.5.2"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/plugin-proposal-decorators": "^7.28.6",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native-community/cli": "20.0.0",
"@react-native-community/cli-platform-android": "20.0.0",
"@react-native-community/cli-platform-ios": "20.0.0",
"@react-native/babel-preset": "0.83.1",
"@react-native/eslint-config": "0.83.1",
"@react-native/metro-config": "0.83.1",
"@react-native/typescript-config": "0.83.1",
"@types/jest": "^29.5.13",
"@types/react": "^19.2.0",
"@types/react-test-renderer": "^19.1.0",
"eslint": "^9.39.2",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "19.2.0",
"typescript": "^5.8.3"
},
"engines": {
"node": ">=20"
},
"overrides": {
"react-devtools-core": "~4.25.0"
}
}
App.tsx 文件内容:
import { NewAppScreen } from '@react-native/new-app-screen';
import { StatusBar, StyleSheet, useColorScheme, View } from 'react-native';
import HelloWorldApp from './screens/helloword';
import {
SafeAreaProvider,
useSafeAreaInsets,
} from 'react-native-safe-area-context';
function App() {
const isDarkMode = useColorScheme() === 'dark';
return (
<SafeAreaProvider>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<AppContent />
</SafeAreaProvider>
);
}
function AppContent() {
const safeAreaInsets = useSafeAreaInsets();
return (
<View style={styles.container}>
<NewAppScreen
templateFileName="App.tsx"
safeAreaInsets={safeAreaInsets}
/>
<HelloWorldApp />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default App;
xcode26.2 podfile内容:
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', dir]).strip
platform :ios, '16.0'
prepare_react_native_project!
🔑 New Arch + Swift 必须静态
use_frameworks! :linkage => :static
target 'RNOfficeApp' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:app_path => "#{Pod::Config.instance.installation_root}/..",
# 🚀 New Architecture 核心
:new_arch_enabled => true,
:fabric_enabled => true,
:hermes_enabled => true
)
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
# ✅ Codegen / C++ / Fabric 必需
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++20'
config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++'
end
end
end
end