Skip to content

Installation

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

Install the package using your preferred package manager:

Terminal window
# npm
npm install @mgcrea/react-native-swiftui
# pnpm
pnpm add @mgcrea/react-native-swiftui
# yarn
yarn add @mgcrea/react-native-swiftui

After installing the package, install the iOS dependencies:

Terminal window
cd ios && pod install && cd ..

Or using the library’s helper script:

Terminal window
npm run install:ios

If you haven’t already enabled the New Architecture in your React Native project, you’ll need to do so.

The New Architecture is enabled by default in React Native 0.76+. No additional configuration is needed.

Add the following to your ios/Podfile:

ENV['RCT_NEW_ARCH_ENABLED'] = '1'

Then reinstall pods:

Terminal window
cd ios && pod install && cd ..

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.