facebook / facebook-sdk-for-unity

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

Game crash after start on iOS with fbsdk v16 #694

Open uchar opened 1 year ago

uchar commented 1 year ago

This is related to https://github.com/facebook/facebook-sdk-for-unity/issues/659 I'm creating this issue because it seems that no one cares about an issue that crashes all iOS builds!!! I don't understand how you guys didn't fix this issue from "Dec 12, 2022" !! We just wasted 3 days on this! I mean did you even build a project with facebook "once" before release !!!?

vg-swift commented 1 year ago

https://github.com/facebook/facebook-sdk-for-unity/issues/688

uchar commented 1 year ago

dead plugin

vg-swift commented 1 year ago

dead plugin

What do you mean? I describe the solution in the thread I posted

uchar commented 1 year ago

dead plugin

What do you mean? I describe the solution in the thread I posted

unchecking that doesn't work in our projects , Firebase and some of google plugins will throw build errors

vg-swift commented 1 year ago

unchecking that doesn't work in our projects , Firebase and some of google plugins will throw build errors

We also use Firebase and google plugins. What about all the other parts I mentioned, what's your cocoapods version and xcode version?

uchar commented 1 year ago

unchecking that doesn't work in our projects , Firebase and some of google plugins will throw build errors

We also use Firebase and google plugins. What about all the other parts I mentioned, what's your cocoapods version and xcode version?

cocoapods is 1.12.1 and xcode 14.3.1

uchar commented 1 year ago

unchecking that doesn't work in our projects , Firebase and some of google plugins will throw build errors

We also use Firebase and google plugins. What about all the other parts I mentioned, what's your cocoapods version and xcode version?

Error is :

Undefined symbols for architecture arm64:

  "_GADAdLoaderAdTypeNative", referenced from:

      ___73-[ALGoogleMediationAdapter loadAdViewAdForParameters:adFormat:andNotify:]_block_invoke in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

      ___64-[ALGoogleMediationAdapter loadNativeAdForParameters:andNotify:]_block_invoke in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_GADAdSizeBanner", referenced from:

      -[ALGoogleMediationAdapter adSizeFromAdFormat:isAdaptiveBanner:parameters:] in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_GADAdSizeLeaderboard", referenced from:

      -[ALGoogleMediationAdapter adSizeFromAdFormat:isAdaptiveBanner:parameters:] in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_GADAdSizeMediumRectangle", referenced from:

      -[ALGoogleMediationAdapter adSizeFromAdFormat:isAdaptiveBanner:parameters:] in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth", referenced from:

      ___75-[ALGoogleMediationAdapter adSizeFromAdFormat:isAdaptiveBanner:parameters:]_block_invoke in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

      +[ALGoogleMediationAdapter currentOrientationAchoredAdaptiveBannerSizeWithWidth:] in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_GADGetStringFromVersionNumber", referenced from:

      -[ALGoogleMediationAdapter SDKVersion] in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_OBJC_CLASS_$_GADAdLoader", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_OBJC_CLASS_$_GADAppOpenAd", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_OBJC_CLASS_$_GADBannerView", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_OBJC_CLASS_$_GADExtras", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

     (maybe you meant: _OBJC_CLASS_$_GADExtrasBridge)

  "_OBJC_CLASS_$_GADInterstitialAd", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

     (maybe you meant: _OBJC_CLASS_$_GADInterstitialAdBridgeV8)

  "_OBJC_CLASS_$_GADMediaView", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleNativeAdDelegate.o)

      objc-class-ref in libGoogleAdapter.a(ALGoogleNativeAd.o)

      objc-class-ref in libGoogleAdapter.a(ALGoogleNativeAdViewDelegate.o)

  "_OBJC_CLASS_$_GADMobileAds", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

     (maybe you meant: _OBJC_CLASS_$_GADMobileAdsBridge)

  "_OBJC_CLASS_$_GADNativeAdImageAdLoaderOptions", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_OBJC_CLASS_$_GADNativeAdView", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleNativeAd.o)

      objc-class-ref in libGoogleAdapter.a(ALGoogleNativeAdViewDelegate.o)

  "_OBJC_CLASS_$_GADNativeAdViewAdOptions", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

  "_OBJC_CLASS_$_GADQueryInfo", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

     (maybe you meant: _OBJC_CLASS_$_GADQueryInfoBridge)

  "_OBJC_CLASS_$_GADRequest", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

     (maybe you meant: _OBJC_CLASS_$_GADRequestBridge, _OBJC_CLASS_$_GADRequestBridgeV85 )

  "_OBJC_CLASS_$_GADRewardedAd", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

     (maybe you meant: _OBJC_CLASS_$_GADRewardedAdBridge, _OBJC_CLASS_$_GADRewardedAdBridgeV8 )

  "_OBJC_CLASS_$_GADRewardedInterstitialAd", referenced from:

      objc-class-ref in libGoogleAdapter.a(ALGoogleMediationAdapter.o)

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)
vg-swift commented 1 year ago

We also use AppLovin with GoogleMediation Adapter, did you try updating the adapter?

uchar commented 1 year ago

Yes it's latest version , We actually managed to fix the crash issue with this solution https://github.com/facebook/facebook-sdk-for-unity/issues/659#issuecomment-1644106923

but after that fix, we get this crash: Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/IASDKCore.framework/IASDKCore

It seems that multiple packages are failing in recent versions of the xcode

Everything was fine in xcode 13 and facebook 14

uchar commented 1 year ago

It also seems to be related to this one https://github.com/googleads/googleads-mobile-unity/issues/2736 Because some people have the same error ( https://github.com/googleads/googleads-mobile-unity/issues/2736#issuecomment-1579742957 ) it seems they fixed it 5days ago but for me still not working

vg-swift commented 1 year ago

Good to know, will avoid updating any ad adapters for now :)

uchar commented 1 year ago

Sadistic plugin, last week I tested all combinations of external dependency manager and all other settings possible and none worked! I finally fixed it by downgrading Facebook SDK from 16.0.1 to 14.1.1 !

abogarsukov-braingames commented 1 year ago

We've the same issue after upgrading Facebook from 14 to 16, but it our case it cannot load DTBiOSSDK.

santiagomartinJC commented 12 months ago

I could fix this by adding the addToAllTargets parameter in dependecies.xml ./Assets/FacebookSDK/Plugins/Editor/Dependencies.xml


    <iosPods>
        <iosPod name="FBSDKCoreKit_Basics" version="~> 15.1" addToAllTargets="true" />
        <iosPod name="FBSDKCoreKit" version="~> 15.1" addToAllTargets="true"/>
        <iosPod name="FBSDKLoginKit" version="~> 15.1" addToAllTargets="true"/>
        <iosPod name="FBSDKShareKit" version="~> 15.1" addToAllTargets="true"/>
        <iosPod name="FBSDKGamingServicesKit" version="~> 15.1" addToAllTargets="true"/>
    </iosPods>

https://github.com/facebook/facebook-sdk-for-unity/issues/659#issuecomment-1643864386

NudeNULL commented 11 months ago

In my case it was crashing because of the DisableBitcode script, since I deleted it the app started

NudeNULL commented 11 months ago

Actually no, it didn't help, no idea what happened then...But without Facebook SDK, even with 5-6 other SDKs everything works well, as always, gotta love the SDK team from facebook

Aare- commented 11 months ago

@uchar Feeling your pain m8! This is riddiculous that integrating simple stuff like an SDK takes days of work.

I think I got te working combination of setting to build iOS without crashing for FBSdk 16.0.1, Firebase 10.7.0 and AppLovinSDK 11.11.3:

Contrary to AppLovin docs, I checked all the toggles in the iOS Resolver Settings: 274545451-546dfc9b-2770-4f28-8839-7a1f7cb92b66

My Podfile looks like this (last part added during build callback):

source 'https://cdn.cocoapods.org/'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'AppLovinMediationFacebookAdapter', '6.14.0.0'
  pod 'AppLovinSDK', '11.11.3'
  pod 'FBSDKCoreKit', '~> 16.0.1'
  pod 'FBSDKCoreKit_Basics', '~> 16.0.1'
  pod 'FBSDKGamingServicesKit', '~> 16.0.1'
  pod 'FBSDKLoginKit', '~> 16.0.1'
  pod 'FBSDKShareKit', '~> 16.0.1'
  pod 'Firebase/Analytics', '10.7.0'
  pod 'Firebase/Core', '10.7.0'
  pod 'Firebase/Crashlytics', '10.7.0'
  pod 'Firebase/Messaging', '10.7.0'
  pod 'Protobuf'
  pod 'UnityMediationSdk', '~> 1.0', :source => 'https://github.com/Unity-Technologies/unity-mediation-cocoapods-prod.git'
  pod 'UnityMediationUnityAdapter', :source => 'https://github.com/Unity-Technologies/unity-mediation-cocoapods-prod.git'
end
target 'Unity-iPhone' do
  pod 'FBSDKCoreKit', '~> 16.0.1'
  pod 'FBSDKCoreKit_Basics', '~> 16.0.1'
  pod 'FBSDKGamingServicesKit', '~> 16.0.1'
  pod 'FBSDKLoginKit', '~> 16.0.1'
  pod 'FBSDKShareKit', '~> 16.0.1'
end
use_frameworks! :linkage => :static

post_install do |installer|
    installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
            end
        end
    end
end

Build Postprocess callback looks like this:

class DisableBytecodeSupport : IPostprocessBuildWithReport {
        public int callbackOrder => 0;

        public void OnPostprocessBuild(BuildReport report) {
        if (report.summary.platform != BuildTarget.iOS) 
            return;

        string projectPath = report.summary.outputPath + "/Unity-iPhone.xcodeproj/project.pbxproj";
        var pbxProject = new PBXProject();
        pbxProject.ReadFromFile(projectPath);

        var mainTarget = pbxProject.GetUnityMainTargetGuid();
        var testTarget = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());
        var unityFrameworkTarget = pbxProject.GetUnityFrameworkTargetGuid();       

        pbxProject.AddShellScriptBuildPhase(
            mainTarget,
            "Run Script",
            "/bin/sh",
            @"cd ""${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Frameworks/UnityFramework.framework/""
        if [[ -d ""Frameworks"" ]]; then
        rm -fr Frameworks
            fi
        "
        );

        #region Disabling Bitcode on all targets
        pbxProject.SetBuildProperty(mainTarget, "ENABLE_BITCODE", "NO");

        //Unity Tests
        pbxProject.SetBuildProperty(testTarget, "ENABLE_BITCODE", "NO");

        //Unity Framework
        pbxProject.SetBuildProperty(unityFrameworkTarget, "ENABLE_BITCODE", "NO");
        pbxProject.SetBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
        #endregion

        // add Google Plist
        pbxProject.AddFileToBuild (pbxProject.GetUnityMainTargetGuid(), pbxProject.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));        
        pbxProject.WriteToFile(projectPath);
        }
    }

I also have Dependencies.xml set up like in the comment above: https://github.com/facebook/facebook-sdk-for-unity/issues/694#issuecomment-1728280614

Hope this helps!

NudeNULL commented 11 months ago

On my side I get NULL Ref inside unitys methods at this line string mainTarget = pbxProject.GetUnityMainTargetGuid();

Trying to find out another method of getting the target name...

Aare- commented 11 months ago

On my side I get NULL Ref inside unitys methods at this line string mainTarget = pbxProject.GetUnityMainTargetGuid();

Trying to find out another method of getting the target name...

Sorry, mistake on my part - you should call pbxProject.ReadFromFile(projectPath); before trying to resolve targets. Updated the original code

NudeNULL commented 11 months ago

Thanks for the update @Aare- , but I can't get the resulting podfile to look like yours, the bottom part is missing, no errors in logs, will try to investigate that for now.

NudeNULL commented 11 months ago

this is my podfile with the latest script changes used

source 'https://cdn.cocoapods.org/'

platform :ios, '13.0'

target 'UnityFramework' do
  pod 'AppLovinMediationAdColonyAdapter', '4.9.0.0.4'
  pod 'AppLovinMediationByteDanceAdapter', '5.4.1.1.0'
  pod 'AppLovinMediationFacebookAdapter', '6.14.0.0'
  pod 'AppLovinMediationFyberAdapter', '8.2.4.0'
  pod 'AppLovinMediationGoogleAdapter', '10.10.0.0'
  pod 'AppLovinMediationGoogleAdManagerAdapter', '10.10.0.0'
  pod 'AppLovinMediationInMobiAdapter', '10.5.8.1'
  pod 'AppLovinMediationIronSourceAdapter', '7.5.0.0.0'
  pod 'AppLovinMediationMintegralAdapter', '7.4.6.0.0'
  pod 'AppLovinMediationMyTargetAdapter', '5.19.0.0'
  pod 'AppLovinMediationSmaatoAdapter', '22.4.0.0'
  pod 'AppLovinMediationUnityAdsAdapter', '4.9.0.0'
  pod 'AppLovinMediationVungleAdapter', '7.1.0.0'
  pod 'AppLovinMediationYandexAdapter', '6.0.0.0'
  pod 'AppLovinSDK', '11.11.3'
  pod 'AppsFlyer-AdRevenue', '6.9.1'
  pod 'AppsFlyerFramework', '6.12.1'
  pod 'FBAudienceNetwork', '6.14.0.0'
  pod 'FBSDKCoreKit', '~> 15.1'
  pod 'FBSDKCoreKit_Basics', '~> 15.1'
  pod 'FBSDKGamingServicesKit', '~> 15.1'
  pod 'FBSDKLoginKit', '~> 15.1'
  pod 'FBSDKShareKit', '~> 15.1'
  pod 'Firebase/Analytics', '10.7.0'
  pod 'Firebase/Core', '10.7.0'
  pod 'YandexMobileMetrica', '4.2.0'
end
target 'Unity-iPhone' do
  pod 'FBSDKCoreKit', '~> 15.1'
  pod 'FBSDKCoreKit_Basics', '~> 15.1'
  pod 'FBSDKGamingServicesKit', '~> 15.1'
  pod 'FBSDKLoginKit', '~> 15.1'
  pod 'FBSDKShareKit', '~> 15.1'
end
use_frameworks! :linkage => :static
NudeNULL commented 11 months ago

Also I saw Facebook just released a newer version of SDK, even though the dependencies are still the same -> 16.0.1, I will try it anyway.

NudeNULL commented 11 months ago

No, it didn't help, will look into crash logs tomorrow

NudeNULL commented 11 months ago

Hey @Aare- , what version of Unity do you use?

Aare- commented 11 months ago

@NudeNULL I'm on 2021.3.23f

I'm not sure if the last part of the podfile is required, but you can always add it manually to the generated xcode project. It should be added by the build post process script but depending on your other plugins it might get overwritten.

I also see you have a lot of other plugins added, it might be a good idea to add them one by one and check which one exactly is causing the problems.

NudeNULL commented 11 months ago

I am seeing a pattern where already two developers have their projects on 2021.3.xx and they dont have the crash, where mine project is on 2020 version, will try the update and write here the result

uchar commented 11 months ago

@NudeNULL Just use version 14 of facebook SDK, why do you want to update it ? this version is broken and no one from the facebook team cares About the Unity version, I had a crash on unity 2021.3 , it's not caused by unity

NudeNULL commented 11 months ago

@NudeNULL Just use version 14 of facebook SDK, why do you want to update it ? this version is broken and no one from the facebook team cares About the Unity version, I had a crash on unity 2021.3 , it's not caused by unity

I am not sure what was the reason for the update, I tried so many things that I forgot about trying the downgrade for facebook SDK, will see what happens with newer version of unity and then will try.

Because after upgrading unity we now have an issue with certificates, have no idea what unity upgrade have to do with triggering an error that says that xcode can't find the certificate with private key for the team id, I am losing my mind and becoming an insane person, day by day, need some psychotherapy... Thank you facebook sdk team for making me want to kill someone ....

Aare- commented 11 months ago

@NudeNULL Unrelated to this issue, but check out: https://docs.fastlane.tools/actions/match/ This solved my issues with certificates for good

NudeNULL commented 11 months ago

Finally got a working build. The certificates issue was solved by removing the build step in our Jenkins job made by using Xcode plugin, and wrote a custom shell script (after a day of fighting with chatgpt), that builds ad hoc ipa file.

The Facebook crash was fixed by downgrading to 14.1 version.