Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to UIApplicationMain casued bad_function_call exception #48865

Closed
Richard-HeadCoach opened this issue Jan 22, 2025 · 7 comments
Closed

Call to UIApplicationMain casued bad_function_call exception #48865

Richard-HeadCoach opened this issue Jan 22, 2025 · 7 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available Resolution: Answered When the issue is resolved with a simple answer

Comments

@Richard-HeadCoach
Copy link

Description

I have an RN app that I have upgraded to 0.76.5. It works successfully on Android but fails on iOS. The build fails after displaying the "Powered By React Native" screen. The failure is a bad_function_call exception on UIApplicationMain.

Image

I have tried static and dynamic linkage, and I got the same result in both cases. The Podfile is from the dynamic linked version

inhibit_all_warnings!  # turn off warnings from third-party pods
require_relative '../node_modules/react-native/scripts/react_native_pods'
platform :ios, '16.0'
prepare_react_native_project!
use_frameworks! :linkage => :dynamic
 
target 'HeadCoach' do
  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('RNReanimated')  
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end
 
  config = use_native_modules!
 
  $RNFirebaseAsStaticFramework = true
  pod 'Firebase'
  pod 'FirebaseCore'
  pod 'Firebase/Auth'
  pod 'GoogleUtilities'
  pod 'GoogleSignIn'
 
  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
 
  # Inherit test settings for 'HeadCoachTests'
  target 'HeadCoachTests' do
    inherit! :complete
  end
 
  # HeadCoachDev Target inherited from HeadCoach
  target 'HeadCoachDev' do
    inherit! :complete
  end
 
  # Post-install tasks, setting deployment target
  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    
    # ensure proper symlinks
    installer.pods_project.targets.each do |target|
      # Loop through targets and set build configurations
      target.build_configurations.each do |build_config|
        puts "Updating #{target.name} to with build configuration: #{build_config.name}"
 
        build_config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
        build_config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
 
        if target.name == 'react-native-skia'
          build_config.build_settings['OTHER_LDFLAGS'] ||= ['$(inherited)']
          build_config.build_settings['OTHER_LDFLAGS'] << '-framework AVFoundation'
          build_config.build_settings['OTHER_LDFLAGS'] << '-framework CoreMedia'
        end
      end
 
      # Disable code signing for produc bundles
      if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
        target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end
end

the package.json is

{
  "name": "headcoach",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "clean": "rimraf android/app/build ios/DerivedData node_modules && yarn cache clean",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "android:dev-debug": "react-native run-android --appId=com.headcoachproject.dev --mode devdebug",
    "android:dev": "react-native run-android --appId=com.headcoachproject.dev --mode devrelease",
    "android:prod-debug": "react-native run-android --appId=com.headcoachproject --mode proddebug",
    "android:prod": "react-native run-android --appId=com.headcoachproject --mode prodrelease",
    "codepush:release:dev": "npm run codepush:release -- --target=dev",
    "codepush:release:prod": "npm run codepush:release -- --target=prod",
    "codepush:release:ios-prod": "npm run codepush:release -- --target=ios-prod",
    "codepush:release": "node src/scripts/codepushRelease.js",
    "check-dependencies": "rnx-align-deps",
    "fix-dependencies": "rnx-align-deps --write"
  },
  "dependencies": {
    "@babel/plugin-transform-arrow-functions": "^7.25.9",
    "@babel/plugin-transform-class-properties": "^7.25.9",
    "@babel/plugin-transform-nullish-coalescing-operator": "^7.25.9",
    "@babel/plugin-transform-optional-chaining": "^7.25.9",
    "@babel/plugin-transform-shorthand-properties": "^7.25.9",
    "@babel/plugin-transform-template-literals": "^7.25.9",
    "@gorhom/bottom-sheet": "^5.0.6",
    "@hookform/resolvers": "^3.3.0",
    "@invertase/react-native-apple-authentication": "^2.4.0",
    "@perttu/react-native-country-picker-modal": "^2.0.6",
    "@react-native-async-storage/async-storage": "^2.0.0",
    "@react-native-clipboard/clipboard": "^1.14.0",
    "@react-native-community/netinfo": "^11.3.3",
    "@react-native-community/slider": "^4.4.3",
    "@react-native-firebase/app": "^21.6.1",
    "@react-native-firebase/auth": "^21.6.1",
    "@react-native-firebase/messaging": "^21.6.1",
    "@react-native-google-signin/google-signin": "^13.1.0",
    "@react-native-voice/voice": "^3.2.4",
    "@react-native/gradle-plugin": "^0.76.0",
    "@react-navigation/bottom-tabs": "^7.2.0",
    "@react-navigation/drawer": "^7.1.1",
    "@react-navigation/native": "^7.0.14",
    "@react-navigation/native-stack": "^7.2.0",
    "@react-navigation/stack": "^7.1.1",
    "@reduxjs/toolkit": "^2.5.0",
    "@rnx-kit/eslint-plugin": "^0.8.4",
    "@shopify/react-native-skia": "^1.7.6",
    "appcenter": "5.0.2",
    "appcenter-analytics": "5.0.2",
    "appcenter-crashes": "5.0.2",
    "axios": "^1.4.0",
    "babel-plugin-syntax-hermes-parser": "^0.26.0",
    "date-fns": "^4.1.0",
    "dotenv": "^16.3.1",
    "i18n-js": "^4.3.0",
    "lottie-ios": "^4.3.4",
    "lottie-react-native": "^7.1.0",
    "moment": "^2.29.4",
    "npm": "^11.0.0",
    "prop-types": "^15.8.1",
    "react": "18.3.1",
    "react-devtools": "^6.0.1",
    "react-hook-form": "^7.45.1",
    "react-native": "^0.76.0",
    "react-native-animatable": "^1.3.3",
    "react-native-animated-progress": "^1.0.2",
    "react-native-calendar-picker": "^8.0.5",
    "react-native-calendar-range-picker": "^1.6.0",
    "react-native-calendar-strip": "^2.2.6",
    "react-native-calendars": "^1.1300.0",
    "react-native-circular-progress-indicator": "^4.4.2",
    "react-native-code-push": "^9.0.0",
    "react-native-confetti-cannon": "^1.5.2",
    "react-native-config": "^1.5.3",
    "react-native-date-picker": "^5.0.8",
    "react-native-device-info": "^14.0.2",
    "react-native-document-picker": "^9.1.1",
    "react-native-draggable-flatlist": "^4.0.1",
    "react-native-dropdown-picker": "^5.4.6",
    "react-native-fast-image": "^8.6.3",
    "react-native-flash-message": "^0.4.2",
    "react-native-gesture-handler": "^2.21.2",
    "react-native-image-crop-picker": "0.41.6",
    "react-native-keyboard-avoiding-scroll-view": "^1.0.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.8.1",
    "react-native-mmkv": "^2.12.2",
    "react-native-mmkv-storage": "^0.11.2",
    "react-native-modal": "^13.0.0",
    "react-native-otp-inputs": "^7.4.0",
    "react-native-pager-view": "^6.2.2",
    "react-native-reanimated": "^3.16.6",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-safe-area-context": "^5.0.0",
    "react-native-screen": "^1.0.1",
    "react-native-screens": "^4.4.0",
    "react-native-share": "^12.0.3",
    "react-native-slider": "^0.11.0",
    "react-native-sortable-list": "^0.0.25",
    "react-native-status-bar-height": "^2.6.0",
    "react-native-svg": "^15.8.0",
    "react-native-svg-transformer": "^1.1.0",
    "react-native-tab-view": "^4.0.5",
    "react-native-tailwindcss": "^1.1.11",
    "react-native-vector-icons": "^10.2.0",
    "react-native-web": "^0.19.13",
    "react-native-webview": "^13.12.2",
    "react-native-youtube-iframe": "^2.3.0",
    "react-redux": "^9.2.0",
    "redux": "^5.0.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.2.3",
    "rn-fetch-blob": "^0.12.0",
    "victory-native": "^37.3.5",
    "yup": "^1.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.26.0",
    "@babel/eslint-parser": "^7.25.9",
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.26.0",
    "@commitlint/cli": "^19.6.1",
    "@commitlint/config-conventional": "^19.6.0",
    "@react-native-community/cli": "^15.0.1",
    "@react-native-community/cli-platform-android": "^15.0.1",
    "@react-native-community/cli-platform-ios": "^15.0.1",
    "@react-native/babel-preset": "^0.76.0",
    "@react-native/eslint-config": "^0.76.0",
    "@react-native/metro-config": "^0.76.0",
    "@react-native/typescript-config": "^0.76.0",
    "@rnx-kit/align-deps": "^3.0.2",
    "@tsconfig/react-native": "^3.0.5",
    "@types/jest": "^29.5.13",
    "@types/react": "^18.3.1",
    "@types/react-native-animated-progress": "^1.0.1",
    "@types/react-redux": "^7.1.34",
    "@types/react-test-renderer": "^18.0.0",
    "@types/redux-logger": "^3.0.9",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^29.7.0",
    "babel-plugin-module-resolver": "^5.0.0",
    "eslint": "^9.17.0",
    "eslint-config-airbnb": "19.0.4",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.28.0",
    "eslint-plugin-react-hooks": "^5.1.0",
    "eslint-plugin-react-native": "^4.0.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "^0.77.0",
    "prettier": "^3.4.2",
    "react-test-renderer": "18.3.1",
    "rimraf": "^6.0.1",
    "typescript": "5.7.2"
  },
  "jest": {
    "preset": "react-native"
  },
  "resolutions": {
    "react": "18.x",
    "react-dom": "18.x",
    "react-art": "18.x",
    "wrap-ansi": "6"
  },
  "rnx-kit": {
    "kitType": "app",
    "alignDeps": {
      "requirements": [
        "[email protected]"
      ],
      "capabilities": [
        "animation",
        "clipboard",
        "community/cli",
        "community/cli-android",
        "core",
        "core-android",
        "core-ios",
        "gestures",
        "jest",
        "modal",
        "navigation/native",
        "netinfo",
        "react",
        "react-test-renderer",
        "safe-area",
        "screens",
        "storage",
        "svg",
        "webview"
      ]
    }
  }
}

Steps to reproduce

1: delete DerivedData, Pods, Podfile.loc, node_models
2: yarn install
3: cd ios; pod install
4: build in Xcode
5: run in Xcode on the simulator
6: "Powered by React Native" is displayed and then the exception is thrown

React Native Version

0.76.5

Affected Platforms

Runtime - iOS

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1
  Memory: 62.78 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.9.0
    path: ~/.nvm/versions/node/v22.9.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.0.0
    path: ~/headcoach/headCoach-mobile/node_modules/.bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/richard/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 3.3.5
    path: /Users/richard/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.3
    wanted: ^15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.5
    wanted: ^0.76.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true


info React Native v0.77.0 is now available (your project is running on v0.76.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.77.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.76.5&to=0.77.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Stacktrace or Logs

Thread 1 Queue: com.apple.main-thread (serial) *
0 __pthread_kill
17 UIApplicationMain
18 main
19 start_sim
20 start

Enqueued from com.apple.root.default-qos.overcommit (Thread 10)
0 dispatch_async
1 _53-[RCTCxxBridge executeSourceCode:withSourceURL:sync:]..
2 facebook::react::tryAndReturnError [inlined]
3 facebook::react::tryAndReturnError [inlined]
4 facebook::react::tryAndReturnError
5 facebook::react::RCTMessageThread::tryFunc
6 invocation function for block in facebook::react::RCTMessageThr..
7 invocation function for block in facebook::react::RCTMessageThr..
8 invocation function for block in facebook::react::RCTMessageThr..
9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
12 CFRunLoopRunSpecific
13 +[RCTCxxBridge runRunLoop]
14 _NSThread_start__
16 thread_start

Thread 2 Queue: RPAC issue generation workloop (serial)

Thread 3 Queue: com.apple.CFNetwork.Connection (serial)

Thread 4

Thread 6 Queue: com.google.fira.worker (serial)
com.apple.uikit.eventfetch-thread (6)
Thread 7
Thread 8
Thread 9

Reproducer

Can not create reproducer

Screenshots and Videos

No response

@react-native-bot react-native-bot added Needs: Author Feedback Newer Patch Available Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jan 22, 2025
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@Richard-HeadCoach
Copy link
Author

I have failed to create a reproducer as the app created from the template is crashing. My steps are

1: clone the repo
2: yarn install
3: cd iod
4: pod install
5: in Xcode - build
6: in Xcode - run

The error is in the screen snip attached

Image

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jan 23, 2025
@Richard-HeadCoach
Copy link
Author

My AppDelegate.mm for my project is

#import "AppDelegate.h"
 
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import <CodePush/CodePush.h>
 
@implementation AppDelegate
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  
  NSURL *jsCodeLocation;
  
#if DEBUG
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  jsCodeLocation = [CodePush bundleURL];
#endif
  
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"HeadCoach"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  return YES;
}
 
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  return [self bundleURL];
}
 
- (NSURL *)bundleURL
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [CodePush bundleURL];
#endif
}
 
- (BOOL)concurrentRootEnabled
{
  return true;
}
 
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
 
  // Add any custom logic here.
  return NO;
}
 
@end

@JustJoostNL
Copy link

I have failed to create a reproducer as the app created from the template is crashing. My steps are

1: clone the repo 2: yarn install 3: cd iod 4: pod install 5: in Xcode - build 6: in Xcode - run

The error is in the screen snip attached

Image

I got that exact error too, but I did use a RN 0.77 build and tried to load a RN 0.76 bundle. That obviously wouldn't work. I've tried to load a RN 0.77 bundle in the RN 0.77 build and I got the following error:

-[RCTView setColor:]: unrecognized selector sent to instance 0x110e69c00.
In the error log it also seems to be related to UIApplicationMain, so this may be related to this issue too.

@Richard-HeadCoach
Copy link
Author

I have upgraded to 0.77.0:

1: Upgraded the package.json to 0.77.0
2: Deleted AppDelegate.mm/h and main.mm
3: Added AppDelegate.swift and added the Firebase initialisation
4: Corrected the compile targets in the build stage in

This now starts correctly. As a result I am closing this report

@cortinico cortinico added the Resolution: Answered When the issue is resolved with a simple answer label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available Resolution: Answered When the issue is resolved with a simple answer
Projects
None yet
Development

No branches or pull requests

4 participants