Unity 2019.4 LTS compatibility with xCode 12 (beta)

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:

extern "C" void PresentMTL(UnityDisplaySurfaceMTL* surface)
{
    if (surface->drawable)
    {
    #if PLATFORM_IOS || PLATFORM_TVOS
        if (@available(iOS 10.3, tvOS 10.3, *))
        {
            const int targetFPS = UnityGetTargetFPS(); assert(targetFPS > 0);
            [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS]; // Error is here
            return;
        }
    #endif

        // note that we end up here if presentDrawable: afterMinimumDuration: is not supported
        [UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable];
    }
}
4 Likes

we are aware about the issues when building/running on xcode beta simulator. No ETA for now for a complete fix

2 Likes

Is this fixed?

Any update on this?

This is relevant! 2019.4.10f1 version

Change error line

[UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS]; // Error is here

to

[UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable];

Hope it helps you.

12 Likes

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?

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:

no known instance method for selector
MetalHelper.mm```

This gets it building - thanks!

@AaronKB

Change this line:

[UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS];

to:

[UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable atTime: 1.0 / targetFPS];

Builds and works.

5 Likes

@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.

Unity 2019.4.10f1, Auto Graphics API (metal, opengles2), iOS 14 simulator works, but not stable (sometimes crashes with SIGTERM).

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

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.

Disabling Metal Editor Support and also changing the line

[UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable afterMinimumDuration: 1.0 / targetFPS];

to

[UnityCurrentMTLCommandBuffer() presentDrawable: surface->drawable];

Fixed my issue.

3 Likes

Hm, so it sounds like I need to update my Unity version to get around this?

Thanks, helped!

1 Like

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.

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
  1. 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
1 Like

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!

1 Like