facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.7k stars 24.16k forks source link

Upgraded to Xcode 10 and now the app is stuck on splash screen #21362

Closed eyalella closed 5 years ago

eyalella commented 5 years ago

Environment

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
      Memory: 93.31 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
      npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
      Android SDK:
        Build Tools: 23.0.1, 25.0.0, 26.0.2, 27.0.3
        API Levels: 23, 25, 26, 27
    IDEs:
      Android Studio: 3.0 AI-171.4443003
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.3.1 => 16.5.0
      react-native: ^0.55.0 => 0.57.1
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Description

We have a working app in production. I upgraded Xcode locally (from 9.4.1 to 10) and the build broke.

Expected:

Everything to work as before

Result:

The app is stuck on the launch screen and I'm not getting any errors in the build log when I build using node. I have been trying to make it work for a few days now but nothing seems to fix it.

What I tried:

Didn't work.

This worked for a while but stopped working after I deleted the app from the simulator and run the build command again.

Still nothing

Every solution combination doesn't seem to work and i'm lost. I can't provide a reproducible demo since this is a private app but I can paste relevant snippets if needed.

General info

I'm using CocoaPods with the following Podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'Fundbox' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for Fundbox
  pod 'Fabric'
  pod 'Crashlytics'
  pod 'Mixpanel'
  pod 'Stripe', '~> 11.2.0'
  pod 'ReactNativeFabric', :path => '../node_modules/react-native-fabric'
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'react-native-appsflyer', :path => '../node_modules/react-native-appsflyer'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

When building the app from the command line using this line:

react-native run-ios --simulator="iPhone 8"

I get:

** BUILD SUCCEEDED **

When I build using Xcode I get the following output with errors:

2018-09-27 11:52:27.153996+0300 Fundbox[11467:771327] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2018-09-27 11:52:27.299419+0300 Fundbox[11467:771327] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/eyal/Library/Developer/CoreSimulator/Devices/12F81E70-8ADD-41F2-A446-C0EFAD482BDA/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-09-27 11:52:27.299813+0300 Fundbox[11467:771327] [MC] Reading from private effective user settings.
2018-09-27 11:52:27.308946+0300 Fundbox[11467:771327] [Crashlytics] Version 3.10.7 (130)
2018-09-27 11:52:27.322410+0300 Fundbox[11467:771327] 
[CodePush] Loading JS bundle from file:///Users/eyal/Library/Developer/CoreSimulator/Devices/12F81E70-8ADD-41F2-A446-C0EFAD482BDA/data/Containers/Bundle/Application/7210970C-3C48-486C-A826-B2A373C148E9/Fundbox.app/main.jsbundle
2018-09-27 11:52:27.324833+0300 Fundbox[11467:771327] Initializing <RCTCxxBridge: 0x60000107c3c0> (parent: <RCTBridge: 0x6000004764c0>, executor: (null))
2018-09-27 11:52:27.328684+0300 Fundbox[11467:771327] Module RCTImageLoader requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-09-27 11:52:27.332745+0300 Fundbox[11467:771327] Running application Fundbox ({
    initialProps =     {
    };
    rootTag = 1;
})
2018-09-27 11:52:27.499833+0300 Fundbox[11467:771424] Failed to create remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.499980+0300 Fundbox[11467:771411] Failed to ping server after delegate was set
2018-09-27 11:52:27.500087+0300 Fundbox[11467:771327] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.500229+0300 Fundbox[11467:771327] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.500609+0300 Fundbox[11467:771327] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.500723+0300 Fundbox[11467:771327] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.501063+0300 Fundbox[11467:771327] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.501152+0300 Fundbox[11467:771327] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-27 11:52:27.962589+0300 Fundbox[11467:771418] undefined is not a function (near '...window.addEventListener...')
2018-09-27 11:52:27.964839+0300 Fundbox[11467:771413] Unhandled JS Exception: undefined is not a function (near '...window.addEventListener...')
2018-09-27 11:52:27.965640+0300 Fundbox[11467:771418] Module AppRegistry is not a registered callable module (calling runApplication)
2018-09-27 11:52:27.972938+0300 Fundbox[11467:771413] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: undefined is not a function (near '...window.addEventListener...')', reason: 'Unhandled JS Exception: undefined is not a function (near '...window.addEve..., stack:
<unknown>@1101:1959
d@2:755
<unknown>@1100:49
d@2:755
<unknown>@1099:65
d@2:755
<unknown>@1098:256
d@2:755
<unknown>@1097:93
<unknown>@1097:233
d@2:755
<unknown>@1096:154
d@2:755
<unknown>@1095:109
d@2:755
<unknown>@1094:81
d@2:755
<unknown>@1093:167
d@2:755
<unknown>@319:314
d@2:755
<unknown>@12:152
d@2:755
n@2:326
global code@1644:8
'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000011516329b __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x00000001133d8735 objc_exception_throw + 48
    2   Fundbox                             0x000000010f3575a9 RCTFormatError + 0
    3   Fundbox                             0x000000010f354303 -[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 507
    4   CoreFoundation                      0x000000011516a11c __invoking___ + 140
    5   CoreFoundation                      0x00000001151675b5 -[NSInvocation invoke] + 325
    6   CoreFoundation                      0x0000000115167a06 -[NSInvocation invokeWithTarget:] + 54
    7   Fundbox                             0x000000010f36aaee -[RCTModuleMethod invokeWithBridge:module:arguments:] + 612
    8   Fundbox                             0x000000010f3b073f _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 255
    9   Fundbox                             0x000000010f3b04bd ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 78
    10  libdispatch.dylib                   0x00000001163135d1 _dispatch_call_block_and_release + 12
    11  libdispatch.dylib                   0x000000011631463e _dispatch_client_callout + 8
    12  libdispatch.dylib                   0x000000011631bb47 _dispatch_lane_serial_drain + 791
    13  libdispatch.dylib                   0x000000011631c7c0 _dispatch_lane_invoke + 428
    14  libdispatch.dylib                   0x00000001163268b8 _dispatch_workloop_worker_thread + 733
    15  libsystem_pthread.dylib             0x00000001166f1fd2 _pthread_wqthread + 980
    16  libsystem_pthread.dylib             0x00000001166f1be9 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Reproducible Demo

None

Any help will be much appreciated! Thanks

react-native-bot commented 5 years ago

It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists.

The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

eyalella commented 5 years ago

The build is really unstable and I can't even document the problem since I'm getting different issues on each build. I'll try to come to a stable env and reopen a ticket with correct data

jdschwartz87 commented 5 years ago

Hi @eyalella My app also crashes on Launch Screen with the same errors/output. Any luck on a solution?! Thanks!

eyalella commented 5 years ago

Well after many attempts I was finally able to make it work by doing this:

  1. Delete Xcode 10 and download 9.4.1
  2. Restart the mac
  3. Install old Xcode version
  4. Delete project folder and clone a fresh copy from github

This get me to a point where I'm still stuck on splash screen but if I build using Xcode I see this error:

undefined is not a function (near '...window.addEventListener...')

I found the culprit is /node_modules/schedule which is trying top access the window...

# schedule.development.js
window.addEventListener('message', idleTick, false);

I added

window.addEventListener && window.addEventListener('message', idleTick, false);

And it works!!

The only problem now is that it's a ugly hack 👎 So I'm trying to understand why schedule even there. I found it's required by react-dom which is required by mobx-react.

I have no idea why all this s**t started when I upgraded Xcode but this is where I'm now. Just need to find a way to not use react-dom

jdschwartz87 commented 5 years ago

Thanks for the quick reply. I'm getting these errors in Visual Studio, using Xamarin.iOS. Stuck & going nowhere for a few days because of these errors / upgrades. Downloaded Xcode 9.4.1, will see what I can figure out!

eyalella commented 5 years ago

FYI, for me changing

import { observer, inject } from "mobx-react";

to

import { observer, inject } from "mobx-react/native";

Solved the react-dom issue