Skip to content

[Bug] iOS Build failure: '(any StorageProvider)?' must be unwrapped to refer #962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shniqq opened this issue Mar 6, 2024 · 15 comments
Closed

Comments

@shniqq
Copy link

shniqq commented Mar 6, 2024

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.3.19f1
  • Firebase Unity SDK version: 11.6.0
  • Source you installed the SDK: UPM (.unitypackage or Unity Package Manager)
  • Problematic Firebase Component: FirebaseStorage (Auth, Database, etc.)
  • Other Firebase Components in use: Core, Auth, CloudMessaging, Crashlytics, FIS, RealtimeDatabase, RemoteConfig (Auth, Database, etc.)
  • Additional SDKs you are using: Applovin Max + Ad Providers, Facebook, Google Play, ... (Facebook, AdMob, etc.)
  • Platform you are using the Unity editor on: Mac, Windows (Mac, Windows, or Linux)
  • Platform you are targeting: Android, iOS (iOS, Android, and/or desktop)
  • Scripting Runtime: IL2CPP (Mono, and/or IL2CPP)
  • Pre-built SDK from the website or open-source from this repo: Prebuilt

[REQUIRED] Please describe the issue here:

Without changes from our side, we are now getting this build error for iOS:

❌  /Users/builder/clone/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Storage.swift:73:12: value of optional type '(any StorageProvider)?' must be unwrapped to refer to member 'storage' of wrapped base type 'any StorageProvider'

    return provider.storage(for: Storage.bucket(for: app))
           ^

There seems to be other Firebase SDK affected, so seems like this needs to be fixed within this SDK too.

Steps to reproduce:

Reproduces 100% of the time, we started noticing yesterday. We're using Mac Mini M2 to build. Xcode 15.2.

Relevant Code:

Our podfile:

source 'https://cdn.cocoapods.org/'
source 'https://github.com/CocoaPods/Specs'

platform :ios, '15.2'

target 'UnityFramework' do
  pod 'AppLovinMediationByteDanceAdapter', '5.7.0.7.0'
  pod 'AppLovinMediationFacebookAdapter', '6.14.0.1'
  pod 'AppLovinMediationFyberAdapter', '8.2.5.2'
  pod 'AppLovinMediationGoogleAdapter', '10.14.0.1'
  pod 'AppLovinMediationGoogleAdManagerAdapter', '10.14.0.0'
  pod 'AppLovinMediationHyprMXAdapter', '6.3.0.0'
  pod 'AppLovinMediationIronSourceAdapter', '7.7.0.0.0'
  pod 'AppLovinMediationMintegralAdapter', '7.5.5.0.0'
  pod 'AppLovinMediationUnityAdsAdapter', '4.9.2.1'
  pod 'AppLovinMediationVungleAdapter', '7.2.1.0'
  pod 'AppLovinSDK', '12.1.0'
  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.15.0'
  pod 'Firebase/Auth', '10.15.0'
  pod 'Firebase/Core', '10.15.0'
  pod 'Firebase/Crashlytics', '10.15.0'
  pod 'Firebase/Database', '10.15.0'
  pod 'Firebase/Firestore', '10.15.0'
  pod 'Firebase/Functions', '10.15.0'
  pod 'Firebase/Messaging', '10.15.0'
  pod 'Firebase/RemoteConfig', '10.15.0'
  pod 'Firebase/Storage', '10.15.0'
  pod 'FirebaseAnalyticsOnDeviceConversion', '10.10.0'
  pod 'FirebaseInstallations'
  pod 'Google-Mobile-Ads-SDK', '~> 10.5'
  pod 'MolocoCustomAdapterAppLovin', '1.4.0.0'
end
target 'Unity-iPhone' do
end
use_frameworks!



post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if ['MolocoSDKiOS-MolocoSDK', 'MolocoCustomAdapter-MolocoCustomAdapter', 'MolocoCustomAdapterAppLovin-MolocoCustomAdapterAppLovin', 'MolocoCustomAdapterIronSource-MolocoCustomAdapterIronSource'].include? target.name
        config.build_settings['CODE_SIGN_STYLE'] = 'Manual'
        config.build_settings['DEVELOPMENT_TEAM'] = ''
        config.build_settings['PROVISIONING_PROFILE_APP'] = ''
      end
    end
  end
end

@paulinon paulinon removed the new New issue. label Mar 6, 2024
@najjarcm
Copy link

najjarcm commented Mar 7, 2024

I am facing the same issue in our project. I tried updating to SDK version 11.7.0 but still faced the same issue.
In the end I changed all the Dependencies.xml files for all my components to use iosPod version 10.22.0 and the build worked.

Example of one of the dependencies.xml file in screenshot below.
image

I am still unsure if that has any effects in the app, but initial testing shows that the build is working fine. Can probably use this as a quick fix until a correct fix is pushed from the SDK.

=EDIT=
Please note that this solution was suggested in the other SDK (flutterfire) issues, and I just tried to mimic that in our project as well. Changing it for StorageDependencies.xml still gave me issues whiles trying to build so instead I increased them all to 10.22.0 and it worked afterwards.

@nick-morhun
Copy link

What could cause build failing without any changes in the source code?

@najjarcm
Copy link

najjarcm commented Mar 7, 2024

Seems to be a native iOS library that got updated. That's what I understood from the comments on the other SDK issue thread.

@Moomo
Copy link

Moomo commented Mar 7, 2024

If you're encountering build issues in your Unity project due to a specific version in *Dependencies.xml files within the Library/PackageCache/com.google.firebase* directory, follow these simple steps to fix it:

  1. Open your terminal.
  2. Navigate to your Unity project's root directory.
  3. Run the following command:
cd Library/PackageCache && find . -type f -name "*Dependencies.xml" -path "*com.google.firebase*" | xargs sed -i '' -e 's/10.15.0/10.22.0/g'

This command finds *Dependencies.xml files containing the version 10.15.0 and replaces it with 10.22.0. Replace 10.15.0 with the version causing the build issues in your project.

@paulinon
Copy link
Contributor

paulinon commented Mar 7, 2024

Thanks for bringing this to our attention, folks. I was able to reproduce the issue using the latest version of the Unity SDK. Another workaround you can do is manually update the iOS SDK version to 10.22.0 in the generated Podfile and run pod update.

That said, I'll be bringing this up with the team. You may refer to this thread for updates.

@shniqq
Copy link
Author

shniqq commented Mar 7, 2024

Are all versions of the SDK affected by this?

@marekmrva-ss
Copy link

I can confirm SDK 11.3.0 is also affected

@shniqq
Copy link
Author

shniqq commented Mar 8, 2024

What worked for us:
Upgrade Firebase SDKs to 11.7.0

Add this script to set the iOS SDK to 10.22.0 as suggested:

public class FirebaseFixIosBuildPostProcessor : IPostprocessBuildWithReport
    {
        public int callbackOrder => int.MaxValue;
        
        public void OnPostprocessBuild(BuildReport report)
        {
            if (report.summary.platform != BuildTarget.iOS) return;
            
            string podfilePath = Path.Combine(report.summary.outputPath, "Podfile");

            if (File.Exists(podfilePath))
            {
                var podfileContent = File.ReadAllText(podfilePath);
                podfileContent = podfileContent.Replace("10.20.0", "10.22.0");
                File.WriteAllText(podfilePath, podfileContent);
            }
            else
            {
                Debug.LogWarning("Podfile not found in the Xcode project.");
            }
        }
    }

In our case, we also use Applovin Max for Ad mediation, we also needed to manually bump the Google Ads SDKs to 11.1.0.0, so we changed Dependencies.xml lines for MaxSdk/Mediation/Google/Editor/Dependencies.xml and MaxSdk/Mediation/GoogleAdManager/Editor/Dependencies.xml to

    <iosPods>
        <iosPod name="AppLovinMediationGoogleAdManagerAdapter" version="11.1.0.0" />
    </iosPods>
    <iosPods>
        <iosPod name="AppLovinMediationGoogleAdapter" version="11.1.0.0" />
    </iosPods>

respectively.

@marekmrva-ss
Copy link

Thank you for the great script @shniqq !

In case anybody is using UCB (or any other automatic building scripts) together with iOS Resolver, I suggest changing public int callbackOrder => int.MaxValue; to public int callbackOrder => 45; so that the iOS Resolver will use the patched pods

Source:
https://github.com/googlesamples/unity-jar-resolver/blob/7a81c644a9f4e72db6cd0872aa138b4a667682c8/source/IOSResolver/src/IOSResolver.cs#L412

@a-maurice
Copy link
Collaborator

So, not sure what changed that caused this issue to start popping up, I imagine it was a change within XCode. But the latest release, 11.8.0, updates the iOS dependencies to 10.22.0, which will fix this issue.

Thanks for offering the scripts in the meantime as a workaround.

@nick-morhun
Copy link

We didn't change Xcode version recently.

@shniqq
Copy link
Author

shniqq commented Mar 14, 2024

Us neither

@Boronko
Copy link

Boronko commented Mar 14, 2024

Instead of fixing the actual issue, you make us update the Firebase version? Please fix the old cocoa pods.

@Whyser
Copy link

Whyser commented Mar 22, 2024

Is there any fix to this other than upgrading the Firebase SDK? I'm having issues with the new version and would need to stay on old version for now. @paulinon

@georgemarkosian
Copy link

georgemarkosian commented Mar 22, 2024

After some back and forth we figured out the only 2 ways to make our app compile:

  1. Leave 11.6.0 and remove the Cloud Storage component from the project
  2. Update to 11.8.0 and remove Firestore

None of those are livable as our app relies on both. While discovering it we tried different versions of xCode (15.0.1, 15.1, 15.2, 15.3) and Unity (2022.3.20, 2022.3.22). We also tried removing other plugins with native components (FacebookSDK, AppsFlyer, GoogleSignIn) - no difference. We also tested another app we have that works without Firebase, it's ok.

We believe the issue lies in Firebase and hope it will be resolved soon. It affects our business as we can't produce builds and test the upcoming app update.

Update 1: tried updating cocoaPods version to 10.23 => results in Undefined symbols errors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests