Facebook-sdk-for-unity: Unity 2019.3 - Missing RegisterMonoModule.h

Created on 26 Nov 2019  ·  11Comments  ·  Source: facebook/facebook-sdk-for-unity

## Checklist

## Environment
Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

  • Unity Editor Version: 2019.3.12b
  • Unity SDK Version: 7.18.0, 7.17.2
  • Installation Platform & Version: [iOS] version 10.0+

    Goals

    Build for iOS using Unity 2019.3

    Expected Results

    Successful build

    Actual Results

Compilation fails because RegisterMonoModule.h is no longer provided in Unity 2019.3 by design: https://issuetracker.unity3d.com/issues/filenotfoundexception-when-building-a-project-with-facebook-sdk-for-ios

Since the minimum Unity supported version is already 5.4 you could just simply remove the FixUp part related with RegisterMonoModules.cpp and RegisterMonoModules.h i guess and remove the lines 21-27 from the FBUnityInterface.h.

## Steps to Reproduce
What are the steps necessary to reproduce this issue?

  1. Create an empty project on 2019.3+
  2. Add FB SDK 7.18.0 or 7.17.2
  3. Try to build for an IOS
bug

Most helpful comment

Local builds were built despite the error, but builds in batchmode failed because of the missing file.

Aside from removing the #include "RegisterMonoModules.h" from the Facebook/FacebookSDK/SDK/Editor/iOS/FBUnityInterface.h and always including the UnityTrampolineConfigure.h.

We are using this workaround to have a fake file:

#if UNITY_2019_3_OR_NEWER

using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;

namespace BuildTools.Editor
{
    public static class TemporaryFacebookFix20193
    {
        [PostProcessBuild(99)]
        static void BeforeFacebookOnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
        {
            if(target != BuildTarget.iOS)
            {
                return;
            }

            var fullPath = Path.Combine(pathToBuiltProject, Path.Combine("Libraries", "RegisterMonoModules.h"));
            if(!File.Exists(fullPath))
            {
                File.Create(fullPath).Close();
            }
        }
    }
}
#endif

All 11 comments

Did you find a solution?

Did you find a solution?

Just removing the #include "RegisterMonoModules.h" from the Facebook/FacebookSDK/SDK/Editor/iOS/FBUnityInterface.h and always including the UnityTrampolineConfigure.h worked for us.


The RegisterModules.h it was a file with only a method: void RegisterMonoModules();
In unity 2019.3 the have wisely removed it.

But Facebook SDK is asking for this file just to add a HAS_UNITY_VERSION_DEF if unity is newer than 4.3 xD
https://github.com/facebook/facebook-sdk-for-unity/blob/f76fd1cec1f08a36d90b21c8ab74cba1168f0d84/Facebook.Unity.Editor/iOS/FixupFiles.cs

So, i have also changed the FBUnityInterface.h to always include the UnityTrampolineConfigure.h (to keep the same behaviour that we had).

I also have this problem!
I removed #include "RegisterMonoModules.h"

But it still fails with /Pods/Headers/Public/FBSDKShareKit/FBSDKShareKit/FBSDKHashtag.h:24:9: Module 'FBSDKCoreKit' not found

Until Facebook issues an update, the best solution is below amongst the ones I tried:

  • Create an empty RegisterMonoModules.h file
  • Copy this inside 'Unity/..../Trampoline/..' next to FBUnityInterface.h
  • After you successfully build your project, copy it to library in XCode also

That file is useless now but FB SDK is still dependant on it.

This file is also referenced from the post process script which breaks the post process.

Has anyone come up with a workaround for this yet?

I have commented up the "#include RegisterModules.h" line, but when I rebuilt the game, it still said that the RegisterModules.h couldn't be found.

@h3902340 This is because one of the dlls has a reference to RegisterModules.h as well.

Hi, I have just upgrade my Facebook SDK for Unity to 7.18.1, it removed the "#include RegisterModules.h" line, but this line of code is still referencing RegisterMonoModules.h, so the console is stilling complaining about not finding the RegisterMonoModules.h file. Because this line of code is in a dll file, there is no easy workaround to this issue, please fix it as soon as possible.

Local builds were built despite the error, but builds in batchmode failed because of the missing file.

Aside from removing the #include "RegisterMonoModules.h" from the Facebook/FacebookSDK/SDK/Editor/iOS/FBUnityInterface.h and always including the UnityTrampolineConfigure.h.

We are using this workaround to have a fake file:

#if UNITY_2019_3_OR_NEWER

using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;

namespace BuildTools.Editor
{
    public static class TemporaryFacebookFix20193
    {
        [PostProcessBuild(99)]
        static void BeforeFacebookOnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
        {
            if(target != BuildTarget.iOS)
            {
                return;
            }

            var fullPath = Path.Combine(pathToBuiltProject, Path.Combine("Libraries", "RegisterMonoModules.h"));
            if(!File.Exists(fullPath))
            {
                File.Create(fullPath).Close();
            }
        }
    }
}
#endif

Repeating @h3902340

It seems 177ff89235716c0f9c4225cf9c11355115da2282 removed the #include "RegisterMonoModules.h". However the code that depends on RegisterMonoModules.h is still in master:

It also means HAS_UNITY_VERSION_DEF won't ever be defined in FBUnityInterface.h (that define came from the modified RegisterMonoModules.h) so the preprocessor strips this include:

#if HAS_UNITY_VERSION_DEF
#include "UnityTrampolineConfigure.h"
#endif

This file would be included in previous versions of the Facebook SDK for Unity when building for Unity 4.3+. I am not quite sure if this was an intended side effect of 177ff89235716c0f9c4225cf9c11355115da2282 (the commit I mentioned above).

_Update re HAS_UNITY_VERSION_DEF:_
UnityTrampolineConfigure.h is basically a file auto-generated by Unity containing:

#define UNITY_VERSION 201930

// known unity versions
#define UNITY_4_2_0 420
#define UNITY_4_2_1 421
#define UNITY_4_2_2 422
// ---8<---
#define UNITY_2019_1_0 201910
#define UNITY_2019_2_0 201920
#define UNITY_2019_3_0 201930

So it seems #include "UnityTrampolineConfigure.h" and the #ifdef surrounding it can be removed without problems, since UNITY_VERSION is used nowhere in the SDK...

Was this page helpful?
0 / 5 - 0 ratings