I'll provide a basic React Native CLI app structure that works on both iOS and Android. This will be a simple app with a welcome screen that you can expand upon.
<project-root>
├── android/ (Android specific files)
├── ios/ (iOS specific files)
├── src/
│ ├── components/
│ │ └── Welcome.js
│ ├── App.js
│ └── index.js
├── package.json
└── babel.config.js
<project-root>
├── android/ (Android specific files)
├── ios/ (iOS specific files)
├── src/
│ ├── components/
│ │ └── Welcome.js
│ ├── App.js
│ └── index.js
├── package.json
└── babel.config.js
Here's the code for each file:
<project-root>/src/App.js:
import React from 'react';
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
import Welcome from './components/Welcome';
const App = () => {
return (
<SafeAreaView style={styles.container}>
<Welcome />
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
export default App;
import React from 'react';
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
import Welcome from './components/Welcome';
const App = () => {
return (
<SafeAreaView style={styles.container}>
<Welcome />
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
export default App;
<project-root>/src/components/Welcome.js:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
const Welcome = () => {
return (
<View style={styles.container}>
<Text style={styles.title}>Welcome to React Native!</Text>
<Text style={styles.subtitle}>This app works on both iOS and Android</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
alignItems: 'center',
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 16,
},
subtitle: {
fontSize: 16,
color: '#666',
},
});
export default Welcome;
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
const Welcome = () => {
return (
<View style={styles.container}>
<Text style={styles.title}>Welcome to React Native!</Text>
<Text style={styles.subtitle}>This app works on both iOS and Android</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
alignItems: 'center',
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 16,
},
subtitle: {
fontSize: 16,
color: '#666',
},
});
export default Welcome;
<project-root>/src/index.js:
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from '../app.json';
AppRegistry.registerComponent(appName, () => App);
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from '../app.json';
AppRegistry.registerComponent(appName, () => App);
<project-root>/babel.config.js:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
npm install -g react-native-cli
npm install -g react-native-cli
npx react-native init MyApp --version 0.72.0
npx react-native init MyApp --version 0.72.0
Replace the contents of the generated files with the code above.
Install dependencies:
cd MyApp
npm install
cd MyApp
npm install
cd ios && pod install && cd ..
npx react-native run-ios
cd ios && pod install && cd ..
npx react-native run-ios
npx react-native run-android
npx react-native run-android
This is a basic starting point that you can expand with additional screens, navigation, and features as needed. The app will run on both iOS 15.8.3 and Android devices.
The issue you're experiencing is because you created a React Native project with the new architecture (which doesn't automatically generate these folders) or there was an error during project creation.
npx react-native init MyApp --version 0.72.0
npx react-native init MyApp --version 0.72.0
npx react-native eject
npx react-native eject
npx react-native run-ios
npx react-native run-ios
(Just running the iOS command will generate the iOS folder)
If you want to ensure you get the full project structure, you can:
npx react-native init MyApp --version 0.72.0 --template react-native-template-typescript
npx react-native init MyApp --version 0.72.0 --template react-native-template-typescript
android and ios folders are presentandroid and ios folders should appear immediately after project creation if everything is set up correctlyWould you like me to provide more specific troubleshooting steps for your environment?