firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
199 stars 32 forks source link

[Bug] iOS Build failure: Umbrella header 'FirebaseCoreInternal-umbrella.h' not found #952

Closed NawarRajab closed 2 months ago

NawarRajab commented 4 months ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Firebase adds couple of pods to podfile. Here is our podfile:

use_frameworks! :linkage => :static

target 'Unity-iPhone' do
platform :ios, '12.0'
  pod 'InternalLibUnity', '0.0.1'
  pod 'InternalLibObjC', '0.0.1'
  pod 'InternalLibObjC2', '0.0.1'
  pod 'AppsFlyerFramework', '6.12.2'
end

target 'UnityFramework' do
platform :ios, '12.0'
    pod 'Firebase/Analytics', '10.20.0'
    pod 'Firebase/Core', '10.20.0'  
end

target 'NotificationService' do
platform :ios, '12.0'
  pod 'BrazeNotificationService', '~> 6.0.0'
end

post_install do |lib|
    lib.pods_project.targets.each do |target|
        if target.name.include? "UnityFramework"
            next
        end
        target.build_configurations.each do |config|
            config.build_settings['ARCHS'] = '$(ARCHS_STANDARD_64_BIT)'
            config.build_settings['BUILD_DIR'] = '../build/$(CONFIGURATION)'
            config.build_settings['PROJECT_TEMP_DIR'] = '$(BUILD_DIR)'
            config.build_settings['PODS_CONFIGURATION_BUILD_DIR'] = '$(BUILD_DIR)'
            config.build_settings['CONFIGURATION_BUILD_DIR'] = '$(BUILD_DIR)'
            config.build_settings['CONFIGURATION_TEMP_DIR'] = '$(BUILD_DIR)'
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
            config.build_settings['ENABLE_BITCODE'] = 'NO'
        end
    end
end

Firebase recommends using static linking for pods by adding use_frameworks! :linkage => :static. When we do so, we get the following build (xcode) errors: Umbrella header 'FirebaseCoreInternal-umbrella.h' not found and 'google/protobuf/Any.pbobjc.h' file not found

Removinguse_frameworks! :linkage => :static results in an error in pod install:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

a workaround would be to add pod 'GoogleUtilities', :modular_headers => true. However, this results in the following build error: 'FirebaseCoreInternal.modulemap' not found

I did a comparison between our xcode project with and without Firebase integration and nothing jumped out as different. I also did that with a fresh Unity project + Fire SDK.. same result. Firebase SDK for Unity has an iOSResolver component that does some operations on Unity post build. I replicated that for our build system. One thing that I don't know the purpose of is that Firebase adds a dummy swift file to UnityFramework target. I just replicated it.

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? Yes What's the issue repro rate? (eg 100%, 1/5 etc) 100%

What happened? How can we make the problem occur? It's hard to reproduce. It's related to Firebase requirements and our project configuration. I can't give build logs at this point. I'll try to, if needed.

Relevant Code:

paulinon commented 4 months ago

Hi @NawarRajab,

It would be helpful if you provide any additional information related to your issue such as build logs, a minimal, reproducible example of your implementation, as well as the steps you've taken to reproduce the issue. This way, we can identify what's causing this to happen.

Could you also elaborate the part where you mentioned the comparison between your Xcode project with and without Firebase? Are you facing a similar issue without any additional SDKs in your Unity project?

NawarRajab commented 4 months ago

Hi, (obfuscated)Build Unity-iPhone_2024-02-22T11-16-11.txt

I've attached the build log. What I meant by the comparison is that I compared xcode project settings of:

I can't produce a sample project as the issue is specifically with how our project is configured and it's conflict with Firebase requirements. We have a bunch of ObjC libraries and they don't work well with the way Firebase configures its dependencies. For example, we tried to build our project without Firebase integration but with use_frameworks! :linkage => :static and it still produced build errors related to missing header files.

NawarRajab commented 2 months ago

For anyone facing the same issue, the solution is to bypass Firebase Unity SDK all together and use Firebase SwiftPM package. It's very simple process and is much cleaner solution: