facebook / facebook-sdk-for-unity

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

Unable to build SDK. Examples a can't find types. #292

Open JimmyDeemo opened 5 years ago

JimmyDeemo commented 5 years ago

I am trying to develop a pull request to fix #291 but when I try to build the SDK I get the following error when running setup.sh;

FATAL: Failed to import /my/path/JimmyDeemo_facebook-sdk-for-unity/play-services-resolver.unitypackage

FATAL: Failed to build the android sdk plugin

This stems from the fact that the Examples scripts don't compile;

-----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll Compilation failed: 5 error(s), 0 warnings -----CompilerOutput:-stderr---------- Assets/FacebookSDK/Examples/Scripts/MenuBase.cs(29,24): error CS0246: The type or namespace name ShareDialogMode' could not be found. Are you missing an assembly reference? Assets/FacebookSDK/Examples/Scripts/MenuBase.cs(43,37): error CS0246: The type or namespace nameIResult' could not be found. Are you missing an assembly reference? Assets/FacebookSDK/Examples/Scripts/MenuBase.cs(167,42): error CS0246: The type or namespace name ShareDialogMode' could not be found. Are you missing an assembly reference? Assets/FacebookSDK/Examples/Scripts/SubMenus/AppRequests.cs(122,17): error CS0246: The type or namespace nameOGActionType' could not be found. Are you missing an assembly reference? Assets/FacebookSDK/Examples/Scripts/SubMenus/GraphRequest.cs(64,43): error CS0246: The type or namespace name `IGraphResult' could not be found. Are you missing an assembly reference? -----EndCompilerOutput---------------

Can anyone help me get up and runnign with building thie SDK? Also, could anyone explain what the setup script is doing opening a Unity project? I don't really understand the process.

JimmyDeemo commented 5 years ago

If I remove the Examples directory then I get further in the build process but it looks like the test fail with the following error;

UserAgent.cs(26,17): error CS0234: The type or namespace name 'Mocks' does not exist in the namespace 'NUnit' (are you missing an assembly reference?) [/Users/jamesdeeman/Dev/git/JimmyDeemo_facebook-sdk-for-unity/Facebook.Unity.Tests/Facebook.Unity.Tests.csproj]

michael-looply commented 5 years ago

Hey @JimmyDeemo, I've been spending some time trying to get this SDK working w/ 2019.2.0f1 and ran into this same issue myself; deleting the Examples directory and restoring it after your first complete run through of setup.sh should resolve the issue, as you noted.

What version of Unity are you using? You may be running into the namespace-not-found issue because all of the .csproj files refer to the non-modularized versions of Unity's engine DLLs; to get this working w/ 2019.2.0f1 I had to manually update the .csproj files with the relevant modules for the msbuild command to successfully build the C# code. If you're not running 2019.2 you may be having a different issue, but here's a relevant diff from my fork in case it's any use to you.

https://github.com/michael-looply/facebook-sdk-for-unity/compare/d2e361a067e9d45414649d2e875e86fdba84f63a...7d9f71f06e34d9fc248b2ecf055b253fdd5011ae

michael-looply commented 5 years ago

Quick follow-up: this issue may also be because of the HintPaths referenced in the .csproj files; they're all hard-coded to a particular non-Hub Unity instance, and may need to be modified so that msbuild can correctly locate the DLLs that Unity provides if you're using a Unity instance at a different path. You can see examples in the diff I posted above, such as:

-      <HintPath>\Applications\Unity\Unity.app\Contents\Managed\UnityEngine.dll</HintPath>
+      <HintPath>$(FB_SDK_UNITY_PATH)\..\..\Managed\UnityEngine\UnityEngine.dll</HintPath>
hlongvu commented 4 years ago

@michael-looply Hi, in your build I notice this

Find and replace any UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll references in .sln files with ../UnitySDK/Library/ScriptAssemblies/UnityEngine.UI.dll to support the new UI path with the 2019.2 UI package change.

But what is this path: ./UnitySDK/Library/ScriptAssemblies/UnityEngine.UI.dll, there is no dll file in this UnitySDK folder?