我正在開發帶有 App Clip 版本的輔助專案 iOS 應用程式,我已經成功地在版本 0.69.4 的 React Native 專案上創建了 App Clip,我在 0.70 版本之后又回到了該專案 - 我想創建新的在更新我之前從頭開始專案,我發現我們在干凈的新專案原因和運行時錯誤上創建應用剪輯的相同步驟:執行緒 1:“-[AppDelegate 視窗]:無法識別的選擇器發送到實體 0x600000dbc060”
我已經對從 0.69.4 到 0.70.1 的每個補丁/版本進行了一些研究測驗,我發現補丁 0.69.5 作業正常,但下一個補丁 - 0.69.6 破壞了一些東西,并且更新仍然存在錯誤版本。我已經確認,通過在版本 0.69.6 上使用 App Clip(步驟如下所述)創建新專案并在版本 0.69.5 到 0.69.6 上使用 App Clip 目標更新作業專案 - 更新后我遇到了問題。
我還嘗試在 0.69.6 版本專案上添加的新 App 目標上加載 React Native,就像在:https ://reactnative.dev/docs/integration-with-existing-apps 它基本上回傳相同的錯誤。
這些是我在 React Native 中創建 App Clip 的步驟:
- 我從干凈的 React Native 專案開始,安裝 pod 等
- 我在 Xcode 中打開專案并添加新目標 - App Clip - 帶有“Clip”名稱 - 例如“ArticleTest5Clip” 在我的 0.69.6 版本中
- 我正在向 Podfile 添加新目標以在“完整”React Native App 中繼承 Pod:
target 'ArticleTest5Tests' do
inherit! :complete
# Pods for testing
end
target 'ArticleTest5Clip' do
inherit! :complete
end
- 我再次運行 pod install
- 然后我將此代碼添加到 ViewController 以將 RN Javascript 代碼加載到應用程式中:
#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
- 并將此代碼添加到 Info.plist 以允許應用程式加載:
<?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>
- 然后,我將“完整”應用程式的構建階段中的“Start Packager”和“Bundle React Native 代碼和影像”階段復制到 App Clip 目標中。
我正在為 0.69.5 和 0.69.6 版本的專案執行相同的步驟。第一個作業正常 - App Clip 正在加載 index.js 就像 Full App 但第二個回傳提到的錯誤,這是完整的錯誤日志:
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
0.69.6 版的相同步驟導致錯誤可能是什么問題?我可以得到一些提示如何解決這個問題嗎?
這是我的輸出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
從損壞的回購中重現錯誤的步驟:
- 復制損壞的回購
- 紗線安裝
- 光碟
- 吊艙安裝
- 在 XCode 中打開 ios/ArticleTest5.xcworkspace
- 選擇 ArticleTest5Clip 目標并單擊運行
- 應該拋出錯誤。
存盤庫:
- 作業應用程式剪輯專案回購 - 0.69.5: https ://github.com/dawidzawada/ArticleTest4
- Broken App Clip 專案 repo = 0.69.6: https ://github.com/dawidzawada/ArticleTest5
我還在 react-native 的 github 上提出了一個問題,但反應團隊還沒有回應:https ://github.com/facebook/react-native/issues/34823
有人可以確認損壞的回購在其他環境中也失敗了嗎?我想知道是否有某種方法可以跟蹤錯誤/問題。Xcode 控制臺日志沒有指向任何東西。
錯誤截圖
uj5u.com熱心網友回復:
有人在 GitHub 問題上找到了解決方案!https://github.com/facebook/react-native/issues/34823#issuecomment-1279650588
需要做的就是將 App Clip 的 AppDelegate.h 更改為:
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/516263.html
