2017-05-21 28 views
0

React Native應自動回退使用脫機捆綁軟件,如果它找不到正在運行的打包程序,它將在第一次運行時保存它。這在Running react-native app on iOS device using offline bundle中提及。React Native開發模式應用程序不會回退到物理設備上的脫機捆綁包(ios)

但是,在我的情況下,從WiFi斷開手機並啓動應用程序後,它只是掛在預先緩存的頁面(或頁面圖像)上,而且通常是最後一個加載的頁面(即最後一頁當應用程序連接到打包程序時加載的頁面)。這是違反直覺的,因爲你認爲關閉應用後,它不會持續任何本地狀態。

我不知道爲什麼會發生這種情況在我的情況。這是來自我的設備的相關日誌跟蹤,它在isPackagerRunning中崩潰,似乎正試圖對URL進行一些排序請求。它應該甚至試圖做到這一點?我可以嘗試記錄它試圖連接到的URL,我想。

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 libsystem_kernel.dylib   0x0000000186eaf260 semaphore_wait_trap + 8 
1 libdispatch.dylib    0x0000000186d9d5e8 _os_semaphore_wait + 24 
2 libdispatch.dylib    0x0000000186d9cca0 _dispatch_semaphore_wait_slow + 140 
3 CFNetwork      0x000000018858eb9c CFURLConnectionSendSynchronousRequest + 284 
4 CFNetwork      0x00000001885bb154 +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 120 
5 resiShare      0x00000001003d4334 -[RCTBundleURLProvider isPackagerRunning:] (RCTBundleURLProvider.m:76) 
6 resiShare      0x00000001003d45e4 -[RCTBundleURLProvider guessPackagerHost] (RCTBundleURLProvider.m:92) 
7 resiShare      0x00000001003d47f4 -[RCTBundleURLProvider packagerServerHost] (RCTBundleURLProvider.m:106) 
8 resiShare      0x00000001003d49b8 -[RCTBundleURLProvider jsBundleURLForBundleRoot:fallbackResource:] (RCTBundleURLProvider.m:123) 
9 resiShare      0x00000001000cad6c -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:23) 
10 UIKit       0x000000018e0732dc -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 380 
11 UIKit       0x000000018e27f800 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3452 
12 UIKit       0x000000018e2852a8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684 
13 UIKit       0x000000018e299de0 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3151 + 48 
14 UIKit       0x000000018e28253c -[UIApplication workspaceDidEndTransaction:] + 168 
15 FrontBoardServices    0x0000000189a7b884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 
16 FrontBoardServices    0x0000000189a7b6f0 -[FBSSerialQueue _performNext] + 176 
17 FrontBoardServices    0x0000000189a7baa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 
18 CoreFoundation     0x0000000187e81424 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 
19 CoreFoundation     0x0000000187e80d94 __CFRunLoopDoSources0 + 540 
20 CoreFoundation     0x0000000187e7e9a0 __CFRunLoopRun + 744 
21 CoreFoundation     0x0000000187daed94 CFRunLoopRunSpecific + 424 
22 UIKit       0x000000018e06c45c -[UIApplication _run] + 652 
23 UIKit       0x000000018e067130 UIApplicationMain + 208 
24 resiShare      0x00000001000cb1d0 main (main.m:16) 
25 libdyld.dylib     0x0000000186dbd59c start + 4 

回答

1

我已經張貼在這裏一個解決方法 - https://github.com/facebook/react-native/issues/10187在希望有人更好地與Objective-C和URL裝載人員將看看,並把在適當的修補程序。希望這可以幫助。謝謝。

問題是,在加載時從主線程發出同步請求,以確定是否可以訪問反應包裝程序(在同一網絡上運行的遠程服務器)。這可能需要一段時間,因爲我的知識之外的原因(如果有人可以對此進行闡述,我會很感激),但如果這需要超過19秒(約),蘋果會崩潰應用程序。

0

根據this文章,這是node_modules/react-native/scripts/react-build-xcode.sh腳本的問題。該腳本假定運行Xcode的Mac和運行該應用程序的iOS設備都在同一個(wi-fi?)網絡中。正因爲如此,同步請求到Mac的http://[mac IP].xip.io:8081/status做可能需要很長的時間來恢復,因爲它掛起超過10秒(見RCTBundleURLProvider.misPackagerRunning法)

因此,要解決這個問題,確保MAC和iPhone在同一個網絡上。

相關問題