2

I am getting this error for import Firebase:

Could not build Objective-C module 'Firebase'

Xcode also complains about FirebaseAnalytics saying

'FirebaseAnalytics/FirebaseAnalytics.h' file not found.

My project used to build just fine until I updated to swift 4.

I am using the latest version of Firebase via Cocoapods version 1.4.0 beta 2.

Cœur
  • 37,241
  • 25
  • 195
  • 267
swiftydev
  • 57
  • 1
  • 1
  • 7
  • which version you are using for firebase ? – CodeChanger Dec 12 '17 at 07:01
  • @CodeChanger I'm using Firebase 4.7.0 – swiftydev Dec 15 '17 at 01:59
  • 3
    Possible duplicate of [Error: Could not build Objective-C module 'Firebase'](https://stackoverflow.com/questions/41709912/error-could-not-build-objective-c-module-firebase) – Cœur Dec 15 '17 at 05:34
  • 1
    @Cœur i already mentioned in my original post that I tried every answer from that link and none of them worked. Why are you labeling this a duplicate? – swiftydev Dec 16 '17 at 13:18
  • @swiftydev also, there are 87 other questions with the same premise of "could not build objective-c module", so your solution is probably among those: https://stackoverflow.com/search?q=%22Could+not+build+Objective-C+module%22+is%3Aq – Cœur Dec 16 '17 at 13:25
  • 1
    @Cœur that was from a year ago and the author was using swift 3. Something about swift 4 might be causing this problem, if so it may require a totally different set of solutions. – swiftydev Dec 16 '17 at 13:26
  • @Cœur made the update you suggested. Are you saying I should copy my entire Podfile? – swiftydev Dec 16 '17 at 19:22
  • @OP what you're asking here is a debugging question, so start from a clean installation and detail all steps to reproduce the issue. –  Dec 18 '17 at 17:38
  • @swiftydev Have you resolved this issue? I'm having similar problem. Im trying to include `Firebase/Core` and `Firebase/Messaging` and since then, I can't build our project. It could not recognize `FirebaseApp`. I could also not import Firebase. Updating the Header Search Path to `${PODS_ROOT}/Firebase/CoreOnly/Sources` helped to finally see the Firebase module. However, when trying to build, I get the error `Could not build Objective-C module 'Firebase'`. – Psylocke Nov 07 '18 at 09:19

4 Answers4

16

I just had the same issue. What I had to do was:

  • Close Xcode
  • Restart Xcode and made sure I opened the .xcworkspace project file.
  • Ran a Build on the project.

After that I had no more Firebase error messages.

Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
4

In Xcode, Go to Product -> Scheme -> Select New Scheme. Then choose FirebaseCore as Target and Name. Now build the project and then change back to your app target. It works for me in Xcode 9.1

Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
  • Adding Firebase-core did it for me, and then I had to build each one separately. – Adam Ware Nov 26 '18 at 06:04
  • 1
    This did the trick for me as well after spending an hour trying to figure it out... You can also actually select the target "Firebase" and build it which will build all your Firebase* targets. (Xcode 12.3) – Dennis Stücken Jan 20 '21 at 00:30
1

Link Binary with Libraries

Build Phases - under Link Binary With Libraries - this is where the magic happens:

enter image description here

It is very likely, your binary is not linked with the Firebase library - hence the header file cannot be found.

Mick
  • 30,759
  • 16
  • 111
  • 130
1

After updating to XCode 9.4 the problem resolved itself.

swiftydev
  • 57
  • 1
  • 1
  • 7