Home > Blockchain >  "[AppDelegate window]: unrecognized selector sent to instance" error since version 0.69.6
"[AppDelegate window]: unrecognized selector sent to instance" error since version 0.69.6

Time:10-17

I'm working on side-project iOS application with App Clip version, I've managed to create App Clip successfully on React Native project with version 0.69.4, I've comeback to the project after 0.70 release - I wanted to create new project from scratch before updating mine, and I've found our that the same steps to create an App Clip on clean, new project cause and RunTime Error: Thread 1: "-[AppDelegate window]: unrecognized selector sent to instance 0x600000dbc060"

I've done some research testing on every patch/version from 0.69.4 till 0.70.1 and I've found out that patch 0.69.5 was working fine but next patch - 0.69.6 broke something and error is still present on newer versions. I've confirmed that by creating new project with App Clip(with steps described below) on version 0.69.6 and updating working project with App Clip target on version 0.69.5 to 0.69.6 - after updating I'm facing an issue.

I've also tried loading React Native on new App target added on 0.69.6 version project just like in: https://reactnative.dev/docs/integration-with-existing-apps And it basically returns the same error.

These are my steps to create an App Clip in React Native:

  1. I'm starting with clean React Native project, installing the pods etc
  2. I'm opening project in Xcode and I'm adding new target - App Clip - with "Clip" name - e.g. "ArticleTest5Clip" In my 0.69.6 version
  3. I'm adding new target to Podfile to inhrerit Pods in "Full" React Native App:
  target 'ArticleTest5Tests' do
    inherit! :complete
    # Pods for testing
  end
  
  target 'ArticleTest5Clip' do
    inherit! :complete
  end
  1. I'm running pod install again
  2. Then I'm adding this code to ViewController to load RN Javascript Code into the app:
#import "ViewController.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)loadView {
  #if DEBUG
  // For DEBUG configuration, javascript will be loaded from index file
  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings]
jsBundleURLForBundleRoot:@"index"];
  #else
  // For RELEASE configuration, js code is bundled and main.jsbundle file is created
  NSURL *jsCodeLocation = [[NSBundle mainBundle]
URLForResource:@"main" withExtension:@"jsbundle"];
  #endif

  // Value of moduleName should be equal to appName value set in index file
  RCTRootView *rootView = [[RCTRootView alloc]
initWithBundleURL:jsCodeLocation moduleName:@"ArticleTest5"
initialProperties:nil launchOptions:nil];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f
green:1.0f blue:1.0f alpha:1];
  self.view = rootView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
}

@end
  1. And this code to Info.plist to allow app to load:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSAppClip</key>
    <dict>
        <key>NSAppClipRequestEphemeralUserNotification</key>
        <false/>
        <key>NSAppClipRequestLocationConfirmation</key>
        <false/>
    </dict>
  <key>NSAppTransportSecurity</key>
  <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
      <key>localhost</key>
      <dict>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
      </dict>
    </dict>
  </dict>
  <key>UIViewControllerBasedStatusBarAppearance</key>
  <false/>
    <key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <false/>
        <key>UISceneConfigurations</key>
        <dict>
            <key>UIWindowSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>UISceneConfigurationName</key>
                    <string>Default Configuration</string>
                    <key>UISceneDelegateClassName</key>
                    <string>SceneDelegate</string>
                    <key>UISceneStoryboardFile</key>
                    <string>Main</string>
                </dict>
            </array>
        </dict>
    </dict>
</dict>
</plist>
  1. Then, I'm copying "Start Packager" and "Bundle React Native code and images" phases from Build Phases of "full" app into the App Clip target.

I'm doing the same steps for 0.69.5 & 0.69.6 version projects. First one is working fine - App Clip is loading index.js just like Full App but second one returns mentioned error, here's full error log:

2022-09-30 12:19:59.421480 0200 ArticleTest5Clip[33519:262543] [native] Running application ArticleTest5 ({
    initialProps =     {
    };
    rootTag = 1;
})
2022-09-30 12:19:59.634352 0200 ArticleTest5Clip[33519:262543] -[AppDelegate window]: unrecognized selector sent to instance 0x600003b78100
2022-09-30 12:19:59.671473 0200 ArticleTest5Clip[33519:262543] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate window]: unrecognized selector sent to instance 0x600003b78100'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000112f8b604 __exceptionPreprocess   242
    1   libobjc.A.dylib                     0x0000000110466a45 objc_exception_throw   48
    2   CoreFoundation                      0x0000000112f9a5ba  [NSObject(NSObject) instanceMethodSignatureForSelector:]   0
    3   UIKitCore                           0x00000001268b22d5 -[UIResponder doesNotRecognizeSelector:]   264
    4   CoreFoundation                      0x0000000112f8f93e ___forwarding___   830
    5   CoreFoundation                      0x0000000112f91d48 _CF_forwarding_prep_0   120
    6   ArticleTest5Clip                    0x000000010525e442 -[RCTDeviceInfo _interfaceOrientationDidChange]   146
    7   ArticleTest5Clip                    0x000000010525e373 __46-[RCTDeviceInfo interfaceOrientationDidChange]_block_invoke   51
    8   ArticleTest5Clip                    0x000000010521c768 RCTExecuteOnMainQueue   56
    9   ArticleTest5Clip                    0x000000010525e2fa -[RCTDeviceInfo interfaceOrientationDidChange]   106
    10  CoreFoundation                      0x0000000112eca09d __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__   12
    11  CoreFoundation                      0x0000000112eca063 ___CFXRegistrationPost_block_invoke   49
    12  CoreFoundation                      0x0000000112ec95b0 _CFXRegistrationPost   496
    13  CoreFoundation                      0x0000000112ec8ee6 _CFXNotificationPost   822
    14  Foundation                          0x000000011101ef4c -[NSNotificationCenter postNotificationName:object:userInfo:]   82
    15  UIKitCore                           0x000000012687542a -[UIApplication _stopDeactivatingForReason:]   1456
    16  UIKitCore                           0x0000000125dee9f2 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]   333
    17  UIKitCore                           0x0000000125deed9a -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]   831
    18  UIKitCore                           0x0000000125dee647 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]   354
    19  UIKitCore                           0x0000000125df8a8f __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke   178
    20  UIKitCore                           0x00000001262c5b01  [BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]   859
    21  UIKitCore                           0x00000001263ffa19 _UISceneSettingsDiffActionPerformChangesWithTransitionContext   246
    22  UIKitCore                           0x0000000125df8713 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]   346
    23  UIKitCore                           0x0000000125bf5af5 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.578   796
    24  UIKitCore                           0x0000000125bf44c7 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]   253
    25  UIKitCore                           0x0000000125bf56b5 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]   255
    26  UIKitCore                           0x00000001262f6f5b -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:]   478
    27  FrontBoardServices                  0x0000000114c3e683 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:]   521
    28  FrontBoardServices                  0x0000000114c6c1a1 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2   133
    29  FrontBoardServices                  0x0000000114c4c0ef -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]   209
    30  FrontBoardServices                  0x0000000114c6c0e9 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke   372
    31  libdispatch.dylib                   0x0000000110515a5b _dispatch_client_callout   8
    32  libdispatch.dylib                   0x000000011051893b _dispatch_block_invoke_direct   295
    33  FrontBoardServices                  0x0000000114c90da3 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__   30
    34  FrontBoardServices                  0x0000000114c90c99 -[FBSSerialQueue _targetQueue_performNextIfPossible]   174
    35  FrontBoardServices                  0x0000000114c90dcb -[FBSSerialQueue _performNextFromRunLoopSource]   19
    36  CoreFoundation                      0x0000000112ef84a7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__   17
    37  CoreFoundation                      0x0000000112ef839f __CFRunLoopDoSource0   180
    38  CoreFoundation                      0x0000000112ef786c __CFRunLoopDoSources0   242
    39  CoreFoundation                      0x0000000112ef1f68 __CFRunLoopRun   871
    40  CoreFoundation                      0x0000000112ef1704 CFRunLoopRunSpecific   562
    41  GraphicsServices                    0x0000000114212c8e GSEventRunModal   139
    42  UIKitCore                           0x000000012687a65a -[UIApplication _run]   928
    43  UIKitCore                           0x000000012687f2b5 UIApplicationMain   101
    44  ArticleTest5Clip                    0x0000000104c24fbe main   110
    45  dyld                                0x000000010fce0f21 start_sim   10
    46  ???                                 0x000000020796b51e 0x0   8717251870
    47  ???                                 0x0000000207966000 0x0   8717230080
)
libc  abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/dawidzawada/Library/Developer/Xcode/DerivedData/ArticleTest5-gtoxgttlbehhsucnekylisnihcuv/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/dawidzawada/Library/Developer/Xcode/DerivedData/ArticleTest5-gtoxgttlbehhsucnekylisnihcuv/Build/Products/Debug-iphonesimulator
terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate window]: unrecognized selector sent to instance 0x600003b78100'
CoreSimulator 802.6.1 - Device: iPhone 12 (43970D63-5D9E-41AA-A999-37726BA8A7F1) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 12

What might be the issue that same steps from version 0.69.6 cause an error? Can I get some tip how to fix that?

Here's my output of npx react-native info:

System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1
    Memory: 116.86 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - /opt/homebrew/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 8.15.0 - /opt/homebrew/bin/npm
    Watchman: 2022.08.22.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8815526
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.14.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce error from broken repo:

  • Copy broken repo
  • yarn install
  • cd ios
  • pod install
  • Open ios/ArticleTest5.xcworkspace in XCode
  • Choose ArticleTest5Clip target and click Run
  • Error should be thrown.

Repositories:

I've also raised an issue at github of react-native, but no response yet from react team: https://github.com/facebook/react-native/issues/34823

Can someone confirm that broken repo is also failing in other environment? I'm wondering if there's some way to trace the bug/issue. Xcode console logs are not pointing to anything.

Error Screenshot

CodePudding user response:

Someone found a solution on GitHub issue! https://github.com/facebook/react-native/issues/34823#issuecomment-1279650588

All what's needs to be done is to change App Clip's AppDelegate.h to:

#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>

@property (nonatomic, strong) UIWindow *window;

@end
  • Related