'RCTAppDelegate.h' file not found
Asked Answered
M

7

5

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

Martinet answered 23/3, 2023 at 10:56 Comment(0)
A
10

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 {
Amoebocyte answered 6/5, 2023 at 20:49 Comment(0)
E
15

Make sure you opened "projectName".xcworkspace and not "projectName".xcodeproj in XCode.

Ellington answered 7/8, 2023 at 0:9 Comment(0)
A
10

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 {
Amoebocyte answered 6/5, 2023 at 20:49 Comment(0)
D
4

Issue:

I had started building the app on Windows and testing on Android. I wanted to test on iOS as well, so I moved the code to my Intel Mac running Monterey.

After following the React Native Environment setup guide, I stumbled upon this error when trying to build my app:

fatal error: 'RCTAppDelegate.h' file not found
#import <RCTAppDelegate.h>

After hours of troubleshooting, I found that my Podfile in the project\ios folder was always generated empty.

> pod init
> pod install
Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed.

I tried creating a new ReactNative project with:

> npx react-native init TestProject

And it worked and built the app without any errors.

Steps I ended up doing:

  1. Downgrading Ruby:

    > brew install rbenv ruby-build
    > rbenv install 2.7.6
    > eval "$(rbenv init - zsh)"
    
  2. Creating a new ReactNative project to test if everything is working smoothly

    > npx react-native init TestProject
    
  3. I noticed the pod --version command showed 1.8.3, even though I had a newer version installed. After uninstalling it using sudo gem uninstall cocoapods, it still showed the same version. I had to uninstall all traces of Pod with this command:

    > which pod
    > sudo rm -rf <path>
    
  4. Copied the Podfile contents of the TestProject to my main project and ran:

    > pod install
    

App built without any errors.

Derr answered 2/9, 2023 at 0:26 Comment(0)
S
0

Delete the node_modules folder, along with package-lock.json

then run npm cache clean --force

and the reinstall using npm install

if you are using yard, basicly the same thing, rm yarn.lock, yarn cache clean and then yarn install

Squamulose answered 23/3, 2023 at 11:5 Comment(1)
i did not help. Again giving same errorMartinet
C
0

Try to remove Pods and build folders and Podfile.lock file, then re-install pods.

Celiaceliac answered 24/3, 2023 at 13:44 Comment(0)
A
0

I was able to fix this by deleting ios/build folder and reinstalling the dependencies. But I am not sure what caused this.

Ambulant answered 4/10, 2023 at 8:58 Comment(0)
O
0

My issue was that I didn't have the arm architectures specifically listed in my build settings.

More specifically, in Xcode, navigate to Targets>"Your app">Build Settings>Architectures

Here, $(ARCHS_STANDARD) will already be listed by default. Add armv7, arm64, and x84_64 (this one may not be necessary) to the list.

Then clean the build folder (CMD+SHFT+K) and run pod deintegrate followed by pod install to clean install your pods.

Good luck

Overijssel answered 17/6, 2024 at 18:42 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.