Coder Social home page Coder Social logo

Comments (14)

InfiniteCode avatar InfiniteCode commented on April 19, 2024

The issue seems to be coming from Facebook.Unity.dll:

$ grep -r IOSInit .
Binary file ./Plugins/Facebook.Unity.dll matches
Binary file ./Plugins/iOS/Facebook.Unity.IOS.dll matches
./SDK/Editor/iOS/FBUnityInterface.mm:  void IOSInit(const char *_appId, bool _frictionlessRequests, const char *_urlSuffix, const char *_userAgentSuffix)

from facebook-sdk-for-unity.

actislav avatar actislav commented on April 19, 2024

yes ioswrapper with full dll import exists in Facebook.Unity.dll, it must be removed or marked with "#if UNITY_IOS || UNITY_IPHONE"

from facebook-sdk-for-unity.

kaiyumcg avatar kaiyumcg commented on April 19, 2024

I can't believe they have not updated it yet! The error is still here with il2cpp. Please fix this error.

from facebook-sdk-for-unity.

bosaku avatar bosaku commented on April 19, 2024

actislav, can you elaborate? Because we cannot edit the dll, I wonder if you mean we should edit FacebookPostProcess.cs ?

from facebook-sdk-for-unity.

bblpny avatar bblpny commented on April 19, 2024

bosaku, the problem is that when you build for NDK with IL2CPP facebook dlls contain p/invoke to methods which are not linkable to.

Any p/invoke method declaration when compiling to NDK/IL2CPP on android needs to be linkable. So the fix would be either you remove all P/Invoke from Facebook.Unity.dll, move them to the ios dll and have the unitypackage specify the ios dll is not for android or include some sort of stub .so for android so they are linkable.

Update: I am attempting a build right now with all P/Invoke calls stubbed in a .SO for ndk. I'm hesitant to say that it will work, because the module in the dll is __Internal but will let you know.

from facebook-sdk-for-unity.

bblpny avatar bblpny commented on April 19, 2024

I attempted to make a .so containing stubbed c functions and it does not work, likely because the p invoke functions use "__Internal" as the module name.
Build failure is here: http://pastebin.com/Wfxc5CAJ

bosaku i think the easiest approach to solve this problem is to first ensure that there are no p/invoke calls in Facebook.Unity.dll, then get rid of Facebook.Unity.IOS.dll entirely in preference to moving the single class in the dll to a .cs in a plugins dir that ifdefs out the pinvoke calls. You'd have to look up the class via Assembly-CSharp first pass, but could alternately use initialize on load from the script into the api. As it is right now, it seems the only way to get it to compile (even if you set Facebook.Unity.IOS.dll as not included on android) is to manipulate the dll to remove the p/invoke (or use a earlier version).

All in all with the current facebook sdk i've been pretty upset. First my iOS builds did not work because the facebook frameworks packaged with unity sdk are incompatible with xcode 7.2 so I had to manually replace the frameworks with ones from january 2016 just to get it to build, and now i cannot get android to work without significant effort. Does facebook even test all the platforms?

I'm retrying the so fix after renaming the .so to lib__Internal.so heres the source but again am not positive it will work http://pastebin.com/GArDhXvq . if this doesn't work i'll be required to either manipulate the dll to use a different module name

Update: the lib__Internal.so fix did not work. And while running reflexil i noticed that Facebook.Unity.IOSWrapper is the main offender (as said by actislav) of this issue (as its located in Facebook.Unity.dll not Facebook.Unity.IOS.dll ). Of course it should be noted that the unity package should have also set Facebook.Unity.IOS.dll as iOS / tvOS only. Either way, the reason everyone is running into this beyond those who took the extra step to mark Facebook.Unity.IOS.dll as iOS only is because these are not linkable. I've used reflexil to neutralize IOSWrapper and am building now, Im' assuming it will finish building but if it does not I will let you know.

While awaiting the long process that is Android IL2CPP NDK builds, I made a pull request here #35

Once it does build, it does fatal crash when ran. I've put a new issue up detailing the issue.

from facebook-sdk-for-unity.

nhatnd avatar nhatnd commented on April 19, 2024

@bblpny: Does your pull request resolve this issue ?

from facebook-sdk-for-unity.

bblpny avatar bblpny commented on April 19, 2024

nhatnd, yes but I haven't tested iOS yet. Facebook doesn't have Facebook.Unity.IOS and Facebook.Unity.Android projects on github for some reason. And you'll need at least Facebook.Unity.IOS.dll, but its possible IL2CPP may strip the dll when building for iOS.

Note: you'll also need to set Facebook.Unity.IOS.dll to not be included in android builds.

from facebook-sdk-for-unity.

nhatnd avatar nhatnd commented on April 19, 2024

@bblpny: But could you please let me know how to modify the Facebook.Unity.dll ? Or could you give me the dll with your modification ?
Thank you very much.

from facebook-sdk-for-unity.

nhatnd avatar nhatnd commented on April 19, 2024

I tried to download the facebook source and apply bblpny's fix then rebuild it. It can be built now. Hope facebook will make the official fix for this soon.

from facebook-sdk-for-unity.

bblpny avatar bblpny commented on April 19, 2024

@nhatnd , glad you got it working. Josh has just told me that the fix should be in upcoming 5.4.2p2

from facebook-sdk-for-unity.

bosaku avatar bosaku commented on April 19, 2024

I'm pretty confused by this conversation.

What would I do with the code snippet on pastebin? I don't see a file to replace with a similiar structure.

I tried downloading, and compiling your source in git which fixes the IL2CPP errors, but I receive errors when running ./setup.sh -> FATAL: Failed to copy '/Users/StreamfallMobile/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar'

Any other guidance?
Thank you!

from facebook-sdk-for-unity.

PimDeWitte avatar PimDeWitte commented on April 19, 2024

+1 on a fix for this, experiencing the same issue and it will force us to remove Facebook from our Android game.

from facebook-sdk-for-unity.

bblpny avatar bblpny commented on April 19, 2024

Just as a follow-up, the 5.4.2p3 patch only fixes the issue after you remove the references to the IOS pinvoke functions.

So,for those that just want to get android to work i've attached the patched dll that excludes the unlinkable ios pinvoke calls that prevent android il2cpp builds from completing.
To admistrators: If i am breaking any rules by posting this dll please remove the attachment.

Please follow the steps below
Ensure the following:

  • You are running the patch release of unity version 5.4.3p (perhaps 5.3.2p will work as well)
  • You are using 7.8.0 facebook sdk for unity.
  • You either have unity closed before preceeding or will not focus to it while doing the following steps.

Make a backup:

  • Copy the file Facebook.Unity.dll located in Assets/FacebookSDK/Plugins to any folder outside (not within) the Assets folder. (Important if you support iOS and Android)

Extract and replace:

  • Extract Facebook.Unity.Patched.Patched.dll from the attached zip file to the same directory inside of Assets that you made a backup of Facebook.Unity.dll
  • Delete only Facebook.Unity.dll, Do not delete Facebook.Unity.dll.meta if it exists!
  • Rename Facebook.Unity.Patched.Patched.dll to Facebook.Unity.dll

Open or focus to unity:

  • Unity will import the dll, but as long as you did not focus to unity between these steps all asset bindings to monobehaviours or scriptable objects within the facebook dll will retain their references.
  • Build the Android IL2CPP project.

Because this requires that you replace the dll, it breaks iOS support. So in order to build for iOS after this, you need to do the following, under the same restrictions of not focusing or having unity open:

  • Delete the Facebook.Unity.dll that you previously renamed from Facebook.Unity.dll
  • Restore the original Facebook.Unity.dll that you backed up previously.
  • Open unity and build.

Notes about the patch: Reflexil and ILSpy were used to do the following:

  • Within the internal problematic class Facebook.Unity.IOSWrapper all static pinvoke methods had the following attributes removed so that they were no longer checked:
    Method Impl: IsPreserveSig
    IsPInvokeImpl
    Then saved as Facebook.Unity.Patched.dll
  • Secondly, to the first patched version, each of the void returning methods were given opcodes to just return:
    0(offset) ret
    and the one string returning method IOSFBSdkVersion given following opcode to return null:
    0(offset) Idnull
    1(offset) ret

then this was saved off to Facebook.Unity.Patched.Patched.dll

Facebook.Unity.Patched.Patched.zip

from facebook-sdk-for-unity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.