Search Unity

Unity 2019.4 LTS compatibility with xCode 12 (beta)

Discussion in 'iOS and tvOS' started by marcin-huuuge, Aug 12, 2020.

  1. marcin-huuuge

    marcin-huuuge

    Joined:
    Sep 5, 2018
    Posts:
    15
    Hi!
    When can we expect an ability to build an working iOS app with xCode 12?

    Currently we have a sample, empty project and so far it:
    - builds and runs when built using xCode 11.5 on iOS 13.5
    - xCode project fails to build when using xCode 12 (beta 4)
    An error is thrown for MetalHelper.mm : 300 saying that "No known instance method for selector 'presentDrawable:afterMinimumDuration`". See code below the post.
    - After removal of the problematic line (so that presentDrawable is called without a parameter which is a fallback solution for iOS < 10.3) the project builds fine but once the app is started it crashes with SIGABRT on
    UnityInitApplicationGraphics();
    , line 130 of UnityAppController.mm

    The problematic code:

    Code (JavaScript):
    1. extern "C" void PresentMTL(UnityDisplaySurfaceMTL* surface)
    2. {
    3.     if (surface->drawable)
    4.     {
    5.     #if PLATFORM_IOS || PLATFORM_TVOS
    6.         if (@available(iOS 10.3, tvOS 10.3, *))
    7.         {
    8.             const int targetFPS = UnityGetTargetFPS(); assert(targetFPS > 0);
    9.             [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS]; // Error is here
    10.             return;
    11.         }
    12.     #endif
    13.  
    14.         // note that we end up here if presentDrawable: afterMinimumDuration: is not supported
    15.         [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable];
    16.     }
    17. }
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    we are aware about the issues when building/running on xcode beta simulator. No ETA for now for a complete fix
     
    krisventure and marcin-huuuge like this.
  3. lintoantony

    lintoantony

    Joined:
    Mar 7, 2017
    Posts:
    2
    Is this fixed?
     
  4. lintoantony

    lintoantony

    Joined:
    Mar 7, 2017
    Posts:
    2
    Any update on this?
     
  5. WowDed

    WowDed

    Joined:
    Aug 6, 2020
    Posts:
    1
    This is relevant! 2019.4.10f1 version
     
  6. PuzzlElite

    PuzzlElite

    Joined:
    Jul 1, 2019
    Posts:
    1
    Change error line
    Code (CSharp):
    1. [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS]; // Error is here
    to
    Code (CSharp):
    1. [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable];
    Hope it helps you.
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    When I try this solution, the game builds fine but after launching the game, it gets stuck at black screen for a few seconds and then crashes (the same problem @marcin-matczak is having). Did it not happen to you @PuzzlElite ? On which Unity version did it run without any issues? Which Graphics APIs were included in Player Settings?
     
  8. krisventure

    krisventure

    Joined:
    Mar 24, 2016
    Posts:
    118
    Why not? Even in Unity 2020.1 you can't run iOS apps in Simulator when using XCode 12.
    XCode 12 is required now to build apps for iOS 14 so I guess everyone will have updated within a few weeks.


    Error in XCode:
    ARC semantic issue
    no known instance method for selector
    MetalHelper.mm
     
    Last edited: Sep 20, 2020
  9. AaronKB

    AaronKB

    Joined:
    Aug 16, 2019
    Posts:
    27
    This gets it building - thanks!
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @AaronKB
     
  11. Magistr_AVSH

    Magistr_AVSH

    Joined:
    Jun 6, 2017
    Posts:
    6
    Change this line:
    Code (CSharp):
    1. [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS];
    to:
    Code (CSharp):
    1. [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable atTime: 1.0 / targetFPS];
    Builds and works.
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @Magistr_AVSH On which Unity version did it run without any issues? Which Graphics APIs were included in Player Settings? Did you test it on an iOS 14 simulator or iOS 13 simulator? Because it works on iOS 13 simulator but I can't get it to work on iOS 14 simulator.
     
  13. Magistr_AVSH

    Magistr_AVSH

    Joined:
    Jun 6, 2017
    Posts:
    6
    Unity 2019.4.10f1, Auto Graphics API (metal, opengles2), iOS 14 simulator works, but not stable (sometimes crashes with SIGTERM).
     
  14. nicloay

    nicloay

    Joined:
    Jul 11, 2012
    Posts:
    540
    Looks like xcode not in beta already (12.0.1) but I still have this issue, has it been fixed? maybe need to update unity as i'm on 2019.4.4?

    After applying the fix from the comment above I have subsequent error
    Code (CSharp):
    1. Exception    NSException *    "[UnityAppController renderingAPI] called before [UnityAppController selectRenderingApi]"    0x00006000036831e0
    unfortunately I'm not able to use opengles2 or 3, so metal is mandatory in the project.
     
  15. akkuzugames

    akkuzugames

    Joined:
    Aug 15, 2020
    Posts:
    1
    Disabling Metal Editor Support and also changing the line
    Code (CSharp):
    1. [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS];
    to
    Code (CSharp):
    1. [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable];
    Fixed my issue.

    Screen Shot 2020-11-05 at 15.48.36.png
     
    Last edited: Nov 6, 2020
    cameo_js, simgamer_h and blacktemple like this.
  16. felixmann

    felixmann

    Joined:
    Feb 16, 2017
    Posts:
    11
    Hm, so it sounds like I need to update my Unity version to get around this?
     
  17. Propagant

    Propagant

    Joined:
    Nov 18, 2013
    Posts:
    38
    Thanks, helped!
     
    info_unity709 likes this.
  18. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm trying to port my game to iOS now. I've changed the presentDrawable call as suggested above, and I have Metal Editor Support turned off. But the app immediately quits upon launch. The log in Xcode says:

    I'm using Unity 2019.3.9f1 and XCode 12.0.1 (under macOS 10.15.7). I'm willing to upgrade if necessary, though I would prefer to keep the final game compatible with older devices as much as possible.

    Any idea how to make this work?

    EDIT: I found the additional project settings to change (uncheck Auto Graphics API, and drag OpenGLES2 up above Metal). But now the build just fails in a different way:

    Happens with both the iPhone 11 and iPhone 8 simulators. A frustrating experience, to be sure. Any advice appreciated.
     
    Last edited: Jan 2, 2021
  19. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    let's start with easy things:
    1. the fix for presentDrawable: should be in the latest 2019.4 (well, i am too lazy to check exact version)
    2. 2019.4 does not support metal on simulator (we have added support in 2020)
    this explains
    3. ios gles is deprecated (and was removed in 2020), but i guess we want to be sure apps can be run on simulator, can we have a bug report with small repro case about
     
    marcin-huuuge likes this.
  20. SoyElPadre

    SoyElPadre

    Joined:
    Aug 19, 2019
    Posts:
    2
    Hello! Don't know if you still have that issue but after reading the issue and trying different stuff, what worked for me was to
    First. Change the presentDrawable like mentioned above (... atTime: 1.0 / targetFPS ) and then go to: Targets > UnityFramework > Build Phases > Link Binary With Libraries and add: GameKit.framework. (just click on the + button and write gamekit, you should find it automatically) . do the same for your project target ( Targets > *Your Project* > Build Phases etc.

    Hope this helps anyone!
     
    JoeStrout likes this.
  21. overdose1

    overdose1

    Joined:
    Feb 14, 2018
    Posts:
    1
    @JoeStrout I could kiss you. Well done sir. Well done
     
    Last edited: Jan 7, 2021
  22. carloscoding

    carloscoding

    Joined:
    Jul 4, 2018
    Posts:
    1
    This works for me thanks!
     
    Propagant likes this.