Failed to create IL2CPP build on OSX

I can’t build using IL2CPP on OSX. Mono is Working Fine.

Failed running /Volumes/Dados/XCode/Programas/Unity/Hub/Editor/2018.1.0f2/Unity.app/Contents/il2cpp/build/il2cppcore/il2cppcore.dll --convert-to-cpp --emit-null-checks --enable-array-bounds-check --compile-cpp --libil2cpp-static --platform="MacOSX" --architecture="x64" --configuration="Release" --outputpath="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Native/GameAssembly.dylib" --cachedirectory="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Assets/../Library/il2cpp_cache" --map-file-parser="/Volumes/Dados/XCode/Programas/Unity/Hub/Editor/2018.1.0f2/Unity.app/Contents/Tools/MapFileParser/MapFileParser" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/Assembly-CSharp-firstpass.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/Assembly-UnityScript-firstpass.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/Assembly-UnityScript.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/Unity.TextMeshPro.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/UnityEngine.UI.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/DOTween.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/UnityEngine.Analytics.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/UnityEngine.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/Stores.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/UnityEngine.Purchasing.dll" --assembly="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Managed/mscorlib.dll" --generatedcppdir="/Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/il2cppOutput" 

stdout:
Building GameAssembly.dylib with ClangToolChain.
    Output directory: /Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Temp/StagingArea/Data/Native
    Cache directory: /Volumes/Dados/Games/Unity/games/Match3/Seven Sails Games/Queens Garden 4 - Sakura Season/Library/il2cpp_cache
il2cpp.exe didn't catch exception: System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at Unity.IL2CPP.Building.ToolChains.ClangToolChain.<ToolChainIncludePaths>c__Iterator1.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Unity.IL2CPP.Building.Hashing.FileHashProvider.Initialize(IEnumerable`1 cppSourceCompileInstructions)
   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
stderr:

Unhandled Exception: System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at Unity.IL2CPP.Building.ToolChains.ClangToolChain.<ToolChainIncludePaths>c__Iterator1.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Unity.IL2CPP.Building.Hashing.FileHashProvider.Initialize(IEnumerable`1 cppSourceCompileInstructions)
   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
   at Program.Main(String[] args)

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunNetCoreProgram(String, String, String, CompilerOutputParserBase, Action`1) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:79)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:360)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String, Boolean) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:343)
UnityEditorInternal.IL2CPPBuilder:Run() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:162)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:42)
DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:192)
DesktopStandalonePostProcessor:PostProcess(BuildPostProcessArgs) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:20)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

I believe this is an issue that has been corrected. Which version of Unity are you using?

Unity 2018.1.0f2

Look for a fix coming in one of the first patch releases for 2018.1. The fix did not make the cut-off for the feature release, unfortunately.

The release notes for the fix will look like this:

IL2CPP: Prevent an error during code conversion related to a missing RGCTX entry for type T that can occur with an unbox opcode for a nullable type. (case 1019586)

1 Like

@JoshPeterson Any idea when the first patch might land?

Yes, I’ve merged the fix into 2018.1.2f1, which is scheduled to be published on May 25.

1 Like

@JoshPeterson : FYI we are seeing this issue in 2018.2.0b4 as well even though that case number is marked as being fixed.

Yes, this should have been corrected in 2018.2.0b1. There might be a subtly different issue occurring now though. Can you submit a bug report for this issue against 2018.2.0b4?

@JoshPeterson Ok I did some investigation by decompiling UnityEditor.IL2CPP.Building.dll and found that GetToolchainInfoForOutput calls the following method which assumes Xcode.app lives in /Applications/Xcode.app

    private NPath MacDevSDKPath()
    {
      if (this._useDependenciesToolChain)
      {
        Unity.IL2CPP.Common.ToolChains.OSX.AssertReadyToUse();
        return Unity.IL2CPP.Common.ToolChains.OSX.MacSDKDirectory;
      }
      NPath sdksParentFolder = new NPath("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs");
      return ((IEnumerable<string>) new string[5]
      {
        "MacOSX10.13.sdk",
        "MacOSX10.12.sdk",
        "MacOSX10.11.sdk",
        "MacOSX10.10.sdk",
        "MacOSX10.9.sdk"
      }).Select<string, NPath>((Func<string, NPath>) (sdk => sdksParentFolder.Combine(new string[1]
      {
        sdk
      }))).First<NPath>((Func<NPath, bool>) (sdk => sdk.DirectoryExists("")));
    }

At least on our build machine we have multiple versions of Xcode installed, namely 9.01 and 9.2 so I simply created a symbolic link from 9.2 like so from the terminal:

cd /Applications
ln -s Xcode\ 9.2.app Xcode.app

After applying this fix I was able to successfully make a build using IL2CPP on OSX. It would be nice to be able to specify the path to Xcode in the build settings.

Cheers,
Tom.

Hey can we get a bug report on this? We’d like to address it.

Ok sent:

(Case 1041910) Failed to create IL2CPP build on OSX

FYI, this is still happening on Unity 2018.1.7f:

From the comment above, it seems that XCode must be installed. Is that true? Where is it documented?

Xocde does need to be installed. I don’t see this in the Unity documentation anywhere. We will add it to the docs.

1 Like

I’m getting this issue.

I’m on MacOS building for Android. I’m using Unity 2018.2.0b3 (and I’m nervous about upgrading, as newer versions of Vuphoria don’t work with my project - it’s been an ongoing battle or I’d be using 2019)

I have Xcode installed in the default location. I also have the required version of the NDK.

Can you provide the specific error message you see? The original issue here occurred when building a macOS standalone player, not an Android player. So I suspect the issue you see might be slightly different.