Installation
Requirements
Section titled “Requirements”Before installing, ensure your project meets these requirements:
- React Native 0.76 or later (New Architecture with Fabric renderer)
- iOS 15.1 or later
- Node.js 18 or later
Installation
Section titled “Installation”Install the package using your preferred package manager:
# npmnpm install @mgcrea/react-native-swiftui
# pnpmpnpm add @mgcrea/react-native-swiftui
# yarnyarn add @mgcrea/react-native-swiftuiiOS Setup
Section titled “iOS Setup”After installing the package, install the iOS dependencies:
cd ios && pod install && cd ..Or using the library’s helper script:
npm run install:iosEnabling New Architecture
Section titled “Enabling New Architecture”If you haven’t already enabled the New Architecture in your React Native project, you’ll need to do so.
For React Native 0.76+
Section titled “For React Native 0.76+”The New Architecture is enabled by default in React Native 0.76+. No additional configuration is needed.
For React Native 0.73-0.75
Section titled “For React Native 0.73-0.75”Add the following to your ios/Podfile:
ENV['RCT_NEW_ARCH_ENABLED'] = '1'Then reinstall pods:
cd ios && pod install && cd ..Verify Installation
Section titled “Verify Installation”Create a simple test component to verify the installation:
import { SwiftUI } from '@mgcrea/react-native-swiftui';import { View } from 'react-native';
export function TestSwiftUI() { return ( <View style={{ flex: 1 }}> <SwiftUI style={{ flex: 1 }}> <SwiftUI.Text text="Hello from SwiftUI!" /> </SwiftUI> </View> );}If you see “Hello from SwiftUI!” rendered with native iOS styling, the installation was successful.
Next Steps
Section titled “Next Steps”- Learn the basics in the Quick Start guide
- Explore available Components
- Check out the Examples for real-world usage