Fix new architecture build issues in React Native
When enabling React Native’s new architecture(opens in a new tab) with Nutrient React Native SDK 4.x, you may encounter build errors related to codegen headers or Swift bridging. This guide covers the most common issues and their solutions.
Missing Props.h file (iOS)
Error message
'react/renderer/components/nutrient_sdk_react_native_codegen/Props.h' file not foundCause — Codegen headers weren’t generated during pod install. This happens when the new architecture environment variable isn’t set or when pods need to be reinstalled.
Solution
Ensure your
Podfilehas the new architecture enabled at the beginning:ENV['RCT_NEW_ARCH_ENABLED'] = '1'Ensure your
Podfileincludesuse_native_modules!:use_native_modules!Reinstall pods to regenerate codegen headers:
Terminal window cd iosrm -rf Pods Podfile.lockpod install --repo-updateClean the Xcode build folder and rebuild your project.
Missing codegen header (Android)
Error message
'nutrient_sdk_react_native_codegen/nutrient_sdk_react_native_codegen.h' file not foundCause — Android CMake cannot find the generated JNI headers. This typically occurs when the new architecture isn’t properly enabled or when the build cache is stale.
Solution
Ensure
newArchEnabled=trueis set inandroid/gradle.properties:newArchEnabled=trueClean and rebuild:
Terminal window cd android./gradlew cleancd ..npx react-native run-androidIf the issue persists, delete
node_modulesand reinstall:Terminal window rm -rf node_modulesyarn installcd android./gradlew cleancd ..npx react-native run-android
Missing Swift bridging header (iOS)
Error message
'PSPDFKitReactNativeiOS-Swift.h' file not foundCause — This issue was fixed in version 2.8.0. If you encounter it, you may be using an older version or have a stale build cache.
Solution
Ensure you’re using
@nutrient-sdk/react-nativeversion 2.8.0 or later:Terminal window yarn upgrade @nutrient-sdk/react-nativeClean your iOS build:
Terminal window cd iosrm -rf Pods Podfile.lockpod install --repo-updateClean Xcode derived data:
Terminal window rm -rf ~/Library/Developer/Xcode/DerivedDataRebuild your project.
General troubleshooting steps
If you’re encountering other build issues with the new architecture, try these steps:
Update to the latest SDK version.
Terminal window yarn upgrade @nutrient-sdk/react-nativeDelete your build folders inside your application’s
iosandandroidfolders.Terminal window rm -rf ios/buildrm -rf android/buildFull clean rebuild.
Terminal window # Remove node_modulesrm -rf node_modulesyarn install# iOScd iosrm -rf Pods Podfile.lockpod install --repo-updatecd ..# Androidcd android./gradlew cleancd ..Verify architecture settings.
- iOS — Check that
ENV['RCT_NEW_ARCH_ENABLED'] = '1'is at the beginning of yourPodfile. - Android — Check that
newArchEnabled=trueis inandroid/gradle.properties.
- iOS — Check that
Check React Native version compatibility. Nutrient React Native SDK 4.x requires React Native 0.77 or later for new architecture support.
For more information about enabling the new architecture, refer to the React Native 4 migration guide.