facebook / facebook-sdk-for-unity

The facebook sdk for unity.
https://developers.facebook.com/docs/unity
Other
489 stars 256 forks source link

Unity 2019.3 - Missing RegisterMonoModule.h #359

Open sp-ivan-hernandez opened 4 years ago

sp-ivan-hernandez commented 4 years ago

Checklist

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
m-kul commented 4 years ago

Did you find a solution?

sp-ivan-hernandez commented 4 years ago

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

wagenheimer commented 4 years ago

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

m-kul commented 4 years ago

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

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

rosen-omnidrone commented 4 years ago

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

mahgo commented 4 years ago

Has anyone come up with a workaround for this yet?

h3902340 commented 4 years ago

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.

mahgo commented 4 years ago

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

h3902340 commented 4 years ago

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.

sp-ivan-hernandez commented 4 years ago

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
broersma commented 4 years ago

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_VERSIONDEF: 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...