Search code examples
iosunity-game-enginefacebook-unity-sdk

RegisterMonoModules.cpp needs editing to fix error: #endif without #if #endif


When using Unity 5 (B18) and building for iOS the following error occurs:

.../RegisterMonoModules.cpp:87:2: error: #endif without #if #endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)

Easy to fix - just remove the #endif on the line above the one generating the error

But then you need to add -fno-objc-arc to Build Phases to file FbUnityInterface.mm

What I find irritating is that every time the project is built the RegisterMonoModules.cpp needs to be edited again. Is there a way to get the change to "stick"?

Same problem in both Facebook-unity-sdk 6.0 and 6.1


Solution

  • Adapting @bjornrun's comment into an answer: in unity 4.6.9 with facebook plugin 6.2.2, I had to change both the data = lines in the code block starting on line 40 of Facebook/Editor/iOS/FixupFiles.cs to just this:

    data = Regex.Replace(data, @"mono_aot_register_module(mono_aot_module_mscorlib_info);", "mono_aot_register_module(mono_aot_module_mscorlib_info);");
    

    After that, mono compiled fine.

    I'm also using Heyzap's plugin, and I had to change their PostProcessBuild attribute in HeyzapPostBuild from 102 to 99, which puts it just before Facebook's 100.