2

I'm trying to build our Unity game with Facebook plugin for Android IL2CPP in Unity 5.4 (Android IL2CPP is now officially supported).

Build fails, a sample link error:

Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Facebook.Unity_0.cpp:16129: error: undefined reference to 'IOSInit'

Has anyone else tried this yet? Advice?

I don't know if the Facebook folks have tried Android Il2CPP yet :) but if not please consider this a vote for supporting it. We definitely plan to switch to IL2CPP for improved Android/iOS runtime compatibility and performance/obfuscation.

mwk
  • 1,959
  • 1
  • 14
  • 22

1 Answers1

0

Obvious and short answer: you are trying to link iOS code with Android :) Try excluding iOS plugins from the build, for example, by setting platform checkboxes in the Unity plugin inspector.

More details:

Most likely, the plugin has some code that invokes iOS specific functions using PInvoke. The call is probably surrounded by

if (Application.platform == RuntimePlatform.iPhonePlayer) 

so it is not actually called on other platforms.

This works well on Mono. But when building for IL2CPP, Unity converts all the managed code to C++ source, compiles and links it. When linking, it needs to have the called iOS function defined - this fails when building Android IL2CPP.

The solution is to exclude this code from the build. If you have the source code, surround the iOS calls with

#if UNITY_IOS

If you don't have the source code, try excluding the unneeded assemblies from the build.

In the meanwhile I'll contact Facebook guys and ask to fix it.

Over17
  • 961
  • 7
  • 8