Search code examples
iosswiftfirebasecocoaapple-m1

Why am I getting the error ''FirebaseCore/FirebaseCore.h' file not found' when trying to run my iOS app


I recently started using a MacBook pro with the M1 chip from an older MacBook Pro which had no issues running this app. Now when I try to build and run my app I get the following issues:

'FirebaseCore/FirebaseCore.h' file not found

and

Could not build Objective-C module 'Firebase'

What I have tried:

  • cleaning my build folder
  • deleting derived data
  • restarting my computer
  • running pod install --repo-update
  • The error does go away when I change my Scheme to FirebaseCore, but then I am unable to run the app on a simulator.

Here is my pod file:

# Uncomment the next line to define a global platform for your project
 platform :ios, '14.0'

post_install do |pi|
    pi.pods_project.targets.each do |t|
      t.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
      end
    end
end

target 'Pikit' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Firebase
  pod 'Firebase'
  pod 'Firebase/Storage'
  pod 'Firebase/Auth'
  pod 'Firebase/Firestore'
  pod 'Firebase/Functions'
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  pod 'Firebase/DynamicLinks'
  pod 'FirebaseUI/Auth'
  pod 'FirebaseUI/Email'
  pod 'FirebaseUI/Google'
  pod 'FirebaseUI/Facebook'
  pod 'FirebaseUI/OAuth' # Used for Sign in with Apple, Twitter, etc
  pod 'FirebaseUI/Phone'

  
  # Other Podfiles
  pod 'OnboardKit'
  pod 'SDWebImage'
  pod 'PureLayout'
  pod 'IQKeyboardManagerSwift'
  pod 'Google-Mobile-Ads-SDK'


  
end

Solution

  • If someone is still facing the problem, If you already cleaned the build folder, remove derived data, remove pod.lock and the pods folder what I suggest is to open the terminal and

    insert : pod deintegrate && pod install

    The difference is caused by the deintegrate call which will remove build phases as well as the framework folder.

    To consider also : Using a M1 chip MacBook, what happened to me as well was getting the said error when building the project for a simulator and not a real device / macbook.

    UPDATE:

    All the firebase dependencies are supposed to run on M1 simulators.

    For general knowledge though:

    If some dependency is failing you on a M1 Macbook, arm64 simulator, find the 'libName'.xcframework of the wanted dependency, and make sure it contains a 'ios-arm64_x86_64-simulator' folder, then drag and drop it at the your project root (copy or reference as you prefer).

    If the dependency fails to be found whilst building:

    open you Project in the project navigator => Find your Target in the Targets column => General dongle => scroll to Framework, Libraries and Embbeded Content and embed your libary which was in a "Do not Embed" status.

    The best way to do so is through Carthage.

    Nice to know : If the wanted dependency doesn't contain the required folder, it's still possible to ask the devs directly on Github.