iosxcodereact-nativeapple-m1

'RCTAppDelegate.h' file not found


After updating the RN version from 0.70.6 to 0.71.4 ios pod install working, but the app doesn't build and gives an error. 'RCTAppDelegate.h' file not found any ideas??

I have tried all steps in react-native-update-helper(android works)

Updated

I don't have AppDelegate.mm so i did all changes in AppDelegate.m


Solution

  • If you're using use_frameworks! :linkage => :static it has to come before use_react_native.

    
    require_relative '../node_modules/react-native/scripts/react_native_pods'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    $RNFirebaseAsStaticFramework = true # if you're using firebase
    
    platform :ios, min_ios_version_supported
    deployment_target = '13.0'
    prepare_react_native_project!
    # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
    # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
    #
    # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
    # ```js
    # module.exports = {
    #   dependencies: {
    #     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
    # ```
    flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
    linkage = ENV['USE_FRAMEWORKS']
    if linkage != nil
      Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
      use_frameworks! :linkage => linkage.to_sym
    end
    
    target 'AppName' do
      config = use_native_modules!
    
      # Flags change depending on the env values.
      flags = get_default_flags()
    
      # This has to come before use_react_native or you get AppDelegate or RCTEventEmitter not found
      use_frameworks! :linkage => :static
      
      use_react_native!(
        :path => config[:reactNativePath],
        :hermes_enabled => flags[:hermes_enabled],
        :fabric_enabled => flags[:fabric_enabled],
        # An absolute path to your application root.
        :app_path => "#{Pod::Config.instance.installation_root}/.."
      )
    
    end
    

    Also I am on Mac M1, and I am not excluding arm64. In my Project -> Target -> Exclude Architectures, I am only excluding i386 for both Debug and Release. Excluding arm64 caused issues with finding certain files as well. I hope something works!

    Another well known issue is if you're also using react-native-splash-screens it will cause your iOS entrypoint to hang for 0.71.0 and greater. Update your AppDelegate.mm like so

    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      [FIRApp configure]; // If you're using react-native firebase
    
      self.moduleName = @"main";
      // You can add your custom initial props in the dictionary below.
      // They will be passed down to the ViewController used by React Native.
      self.initialProps = @{};
    
      bool didFinish = [super application:application didFinishLaunchingWithOptions:launchOptions];
       
       [RNSplashScreen show];  // this needs to be called after [super application:application didFinishLaunchingWithOptions:launchOptions];
       
       return didFinish;
    }
    

    for android the builds were fine, but if you still want to open the splash screen follow the installation instructions and add import org.devio.rn.splashscreen.SplashScreen; to the import statements, then add this to the bottom of MainActivity.java

      @Override
      protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(null); // to ensure android is compatible with react-native-screens
      }
    
    } // This is the final closing bracket of public class MainActivity extends ReactActivity {