Search Unity

Cannot display a custom UIVIew with React Native Unity 2018, works with 2017

Discussion in 'iOS and tvOS' started by yurykorzun, Nov 17, 2018.

  1. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    I have a Unity project where I show custom UIViews built with React Native. Everything works great with Unity 2017. After I updated to Unity 2018, React Native cannot calculate a correct size of components. After days of debugging I couldn't find a reason why it is happening.

    I build the same project with Unity 2017 and everything works. I switch to 2018 and it stops working. Based on what I see after debugging with XCode, React Native components cannot obtain the right bounds and and calculate wrong values for with and height. I compared all source files in Classes folder in the XCode project and I don't see any significant change that may lead to this.

    This is how try to display a custom UIView

    Code (CSharp):
    1. UIWindow* unityWindow = UnityGetMainWindow();
    2.  
    3. CGRect frame = unityWindow.frame;
    4. CGRect bounds = unityWindow.bounds;
    5. reactRootView.frame = frame;
    6. reactRootView.bounds = bounds;
    7.  
    8. [unityView removeFromSuperview];
    9. [unityWindow addSubview:reactRootView];
    10.  
    11.  
    If anyone has any clues or suggestions, I would really appreciate it.
     
  2. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    The issue still remains, there is a detailed description and a sample project that reproduces it https://github.com/yurykorzun/unity-react-native-demo

    It doesn't happen on Android or on iOS running on a Simulator

    What was changed in the XCode project after Unity 2017 that could break it?
     
  3. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    We solved this issue by adding React Native as a framework, not a static library.