0

I am posting a question after having a look at all similar questions and answers.

Here are the questions I studied.

uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance

"Unrecognized selector sent to instance" error

unrecognized selector sent to instance

...

Maybe, you might wonder that it's a duplicate question but in my case, it's not. Let's see how it is. First, here is the code snippet for AppDelegate.m - it is same as the file in what we get by running react-native init newproject --version 0.68.2 except for the name of project in the file:

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <React/RCTAppSetupUtils.h>

#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>

#import <react/config/ReactNativeConfig.h>

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
  facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTAppSetupPrepareApp(application);

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"RiteHaulerDriver", nil);

  if (@available(iOS 13.0, *)) {
    rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
    rootView.backgroundColor = [UIColor whiteColor];
  }

  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
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
                                                             delegate:self
                                                            jsInvoker:bridge.jsCallInvoker];
  return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)name
{
  return RCTCoreModulesClassProvider(name);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                      jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
  return nullptr;
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                     initParams:
                                                         (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
  return RCTAppSetupDefaultModuleFromClass(moduleClass);
}

#endif

@end

Now let me show you what error shows up. I can't get any clue from the error message.

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code null. To debug build logs further, consider building your app with Xcode.app, by opening MyProject.xcworkspace.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MyProject.xcworkspace -configuration Debug -scheme MyProject -destination id=8F88E1CC-20CE-44D4-B92F-B72C5B2D45BD

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES


2022-09-02 04:07:40.299 xcodebuild[30582:3206871] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-09-02 04:07:40.299 xcodebuild[30582:3206871] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-09-02 04:07:41.626 xcodebuild[30582:3206871] -[__NSCFBoolean mutableCopyWithZone:]: unrecognized selector sent to instance 0x7ff858714440
** INTERNAL ERROR: Uncaught exception while building **
Uncaught Exception: -[__NSCFBoolean mutableCopyWithZone:]: unrecognized selector sent to instance 0x7ff858714440
Stack:
  0   __exceptionPreprocess (in CoreFoundation)
  1   objc_exception_throw (in libobjc.A.dylib)
  2   -[NSObject(NSObject) __retain_OA] (in CoreFoundation)
  3   ___forwarding___ (in CoreFoundation)
  4   _CF_forwarding_prep_0 (in CoreFoundation)
  5   -[Xcode3AppTransportSecurityItemModel readValuesFromPlist] (in Xcode3Core)
  6   -[Xcode3AppTransportSecurityItemModel initWithCapabilitiesContext:item:] (in Xcode3Core)
  7   -[Xcode3TargetCapabilitiesContext capabilityItemModels] (in DevToolsCore)
  8   -[Xcode3TargetCapabilitiesContext _appIDFeatureStateForEntitlements:expansion:] (in DevToolsCore)
  9   -[Xcode3Target appIDFeaturesForBuildParameters:entitlements:withEntitlementsExpansion:] (in DevToolsCore)
 10   -[Xcode3Target _profileSupportForSDK:configuration:scope:] (in DevToolsCore)
 11   -[Xcode3Target provisioningCommandInputsForConfiguration:macroExpansionScope:runDestination:] (in DevToolsCore)
 12   -[XCTargetDGSnapshot initWithInformationFromTarget:withBuildParameters:] (in DevToolsCore)
 13   -[XCNativeTargetDGSnapshot initWithInformationFromTarget:withBuildParameters:] (in DevToolsCore)
 14   -[PBXTarget createDependencyGraphSnapshotWithTargetBuildParameters:] (in DevToolsCore)
 15   -[PBXTarget propagateTargetSnapshotIfNeededWithCompletionBlock:] (in DevToolsCore)
 16   -[PBXTarget(XCBuildables) prepareForBuildingWithBuildParameters:withBuildOperationContext:] (in DevToolsCore)
 17   -[Xcode3TargetBuildableSnapshot prepareForBuildingForBuilder:] (in DevToolsCore)
 18   -[IDEBuilder prepareForBuilding] (in IDEFoundation)
 19   -[IDEBuildOperation start] (in IDEFoundation)
 20   __NSThreadPerformPerform (in Foundation)
 21   __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (in CoreFoundation)
 22   __CFRunLoopDoSource0 (in CoreFoundation)
 23   __CFRunLoopDoSources0 (in CoreFoundation)
 24   __CFRunLoopRun (in CoreFoundation)
 25   CFRunLoopRunSpecific (in CoreFoundation)
 26   CFRunLoopRun (in CoreFoundation)
 27   -[Xcode3CommandLineBuildTool _buildWithTimingSection:] (in Xcode3Core)
 28   -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
 29   XcodeBuildMain (in libxcodebuildLoader.dylib)
 30   start (in dyld)

I had a look at all answers but I could not resolve the issue yet. This error shows up when I run react-native run-ios command after I upgrade React Native version from 0.63.2 to 0.68.2.

I could install node_modules and Pods but running command is not working. I changed the AppDelegate.m file with that of old version project but no difference. Maybe I should suspect somewhere else?

Additionally, I hope to hear about what instance 0x7ff858714440 means and what is missing or wrongly added in my AppDelegate.m file. And do I have to present more code snippets?

I am quite lost with the issue now so I appreciate any comment or answer regarding the solution or this post itself. Thank you!

VecopWall
  • 549
  • 1
  • 7
  • 23
  • This is not a crash in your app. Your app isn't even building. The first line of the error message tells you what to try next. – matt Sep 02 '22 at 12:48
  • Yes you are right, I can't build it. What should I try? – VecopWall Sep 02 '22 at 12:51
  • What did I just say? Try doing what the error message suggests. – matt Sep 02 '22 at 12:52
  • I guess you mean opening the project with Xcode but Xcode quits when trying to open the project in issue. – VecopWall Sep 02 '22 at 12:56
  • Well there's your problem. You've hosed the workspace / project somehow. – matt Sep 02 '22 at 13:01
  • It happens after I upgrade the React Native version from 0.63.2 to 0.68.2 and I can't open the Xcode 13.4.1 for the project. – VecopWall Sep 02 '22 at 13:05
  • React native gives you the steps to run on upgrade: https://reactnative.dev/docs/upgrading and it also gives you Upgrade Helper, which for upgrade 0.63.2 to 0.68.2 is quite elaborate: https://react-native-community.github.io/upgrade-helper/?from=0.63.2&to=0.68.2. Did you follow all the steps? – timbre timbre Sep 02 '22 at 13:26
  • Yes, I followed the steps and resolved diff as well. – VecopWall Sep 02 '22 at 13:36

0 Answers0