UnityからSimulator SDKで書き出したアプリをXcodeのシミュレータで実行しようとしたら、エラーが出て実行できない時の解決方法のメモ。
Uncaught exception: NSInternalInconsistencyException: [UnityAppController renderingAPI] called before [UnityAppController selectRenderingApi]
解決方法
UnityのPlayer Settings > Other SettingsのAuto Graphics APIを無効にして、Graphics APIsにOpenGLES3を追加する。
XcodeのシミュレータはMetalサポートしてないので、Metalだけではビルドが通らないみたい。
We are experiencing the same issue running Unity 2017.2.0p3 on a MacBook Pro (15-inch, 2016) with a Radeon Pro 450 2 GB. The iPhone X simulator crashes as soon as the app starts if Metal is selected as the rendering API, works fine under OpenGL or Auto.
answers.unity.com
OpenGLかAutoで動作するよって書いてあったけど、画像の通りAutoかつその設定で入っていたOpenGLES2があっても変わらずエラーが出る。
手動でOpenGLES3を追加して再度ビルド。その後Xcodeで実行したら問題なくシミュレータで実行できた。