Error: Could not build Objective-C module 'Firebase'
Asked Answered
F

30

133

When I compile the application I get an error equal to this:

Could not build Objective-C module 'Firebase'

This error appear in import Firebase of my file swift.

Fabri answered 18/1, 2017 at 1:22 Comment(0)
O
267

There is only one way to solve this issue.

  1. Quit Xcode.
  2. Delete project's temp files located at ~/Library/Developer/Xcode/DerivedData
  3. Delete ProjectName.xcworkspace
  4. Delete Podfile.lock file and Pods folder
  5. Run pod install.
  6. Open the newly created ProjectName.xcworkspace file and build.
Obeisance answered 11/6, 2017 at 17:39 Comment(15)
If I delete ProjectName.xcworkspace, does it delete the previous code there?Adaliah
@ConsBulaquena Actually, you have to delete the xcworkspace, it doesn't include the code you wrote but is automatically generated by Pod, don't worry about it.Obeisance
I don't have a Xcode folder I ~/Library/DeveloperPulse
@Pulse weird, open Xcode, go to Preferences->Locations and share what you see. Check mine: ibb.co/dUvgk8Obeisance
@DimitrisBouzikas thanks a lot! It was under ~/User/ME/Library/... and there the Library folder was hidden. (Made it visible with Shift+cmd+(dot))Pulse
solved my problem. Note that this will delete your existing build schemes.Translate
the first two steps worked for me. I didn't have to delete the workspace file, I just had to open it instead of the project file after quitting xcode and deleting derived dataTrig
for future readers, there is a library folder of the computer and one of the user, most of the time it is in the users onePettus
for those who don't know how to run pod install: stackoverflow.com/questions/30418062/…Pettus
I only needed step 4 and 5Linstock
Thanks a lot, you saved my time! xCode v12Retail
https://mcmap.net/q/17076/-how-can-i-safely-delete-in-my-library-developer-xcode-deriveddata-directory if you cannot find DerivedData folderCrepuscular
Where are ProjectName.xcworkspace, Podfile.lock and Pods?Shopworn
@Philippe-AndréLorin in the main folder of the project. Those files are created only if you create a project and add Pods to it, if you are using SPM or don't have any library yet, then you won't have them.Obeisance
You can reach /DerivedData folder by this : - Open a terminal and than run this command! open ~/Library/Developer/Xcode/DerivedDataStratosphere
O
53

Build ( + B) worked for me. (It's important to build the framework target, then build the project)

Oriel answered 24/5, 2018 at 15:4 Comment(5)
worked for me after I applied the first answer. Also had to change the FIRApp.configure() to FirebaseApp.configure()Jarrettjarrid
worked for me without having to apply Dimitris Bouzikas answer, and i was adding firebase to an existing project for those doing the sameWoodsy
I tried Dimitri's solution but it didnt work, ended up missing necessary files, this solution did fix the problemSlumberland
@MarioRojas Can you determine what are the necessary files? Study a bit how Pod works.Obeisance
I'd like to vote this as one of the funniest answers.Ammonate
M
45

I am using Swift 4 and Xcode 9. All I have to do is selecting FirebaseCore Scheme.

On Xcode:

Product->Scheme->FirebaseCore.

If you don't have FirebaseCore go to Manage Schemes and select it. Then try again.

Mammilla answered 17/5, 2018 at 16:30 Comment(3)
Fantastic my friend you helped me, Thank You. Was searching for this from past 4 days. Thank You. Guys its works!!!Complected
This worked for me too! (I also restarted Xcode using 'open myproject.xcworkspace after installing Pods in case that matters)Stentor
When I switch my scheme back to my app scheme, this no longer works. Could someone please explain?Sino
F
33

This may fix your problem:

  1. Quit the Xcode. (Don't just close the Xcode window, right click and Quit it explicitly).

  2. Go to ~/Library/Developer/Xcode/DerivedData and delete the project folder. (Simply delete all the folders).

  3. Clean and Build the project.

If still error exist:

Do steps 1 and 2 and follow this steps:

  1. Change scheme to Firebase and Build (Command + B).

  2. Change back to your app scheme and Run again.

Fitch answered 18/1, 2017 at 7:27 Comment(2)
The above steps didnt solve my issue, please help me.Inessive
Please try other answers. Your case can be different.Fitch
K
20

I opened the project with .xcodeproj and I installed Firebase with cocoapods. I got the same error. But I just close the project and open it with .xcworkspace.

The alert has gone. Firebase was the first library on my project. So I kept using .xcodeproj file.

Keller answered 1/6, 2019 at 12:18 Comment(0)
R
14

Install FireBase properly via CocoaPods. Try the following steps

Step 1 - Close Xcode

Step 2 - Clear your derived data. You can find your derived data in here

~/Library/Developer/Xcode/DerivedData

Step 3 - Open your .xcworkspace

Step 4 - Clean your project (⌘+Shift+K)

Step 5 - Build your project (⌘+B)

Make sure your are opened .xcworkspace file

Radiator answered 20/7, 2018 at 6:47 Comment(1)
This was the only answer that worked for me using Xcode 9.4 on Ionic 3 app.Vulture
A
8

For me the issue was simple. I have a new m1 mac and it has trouble loading cocoa pods sometimes. Simply:

  • Click your pods project(blue pods)->
  • Click all & build settings ->
  • Excluded architectures ->
  • add "arm64" to both debug and release ->
  • set any SDK on left side ->
  • do this on your main project folder too ->
  • build it your good to go

enter image description here

Arm answered 19/2, 2021 at 2:41 Comment(5)
This is the only solution that worked for me. Thanks!Mckeever
Worked for me on my M1 Pro device. Thank you.Aeolic
Hello @Zach Gonzalez. I have this exact same problem and I'm getting nuts. I have an M1 Mac and every time I build I see different compile error, and many of them are related to CocoaPods. I've done exactly what you say but the problem persists. To give an example: AWSDynamoDBModel > Could not build module 'AWSCore'. I tried Clean & Rebuild many times, I've also tried pod install + pod update to no avail. Any suggestions?Sylviesylvite
This should be the right answer for Xcode 13 M1 alsoSupersonic
Working solution for XCode 14.1 on M1 Pro Mac. It's essential to add "arm64" to "Excluded Architectures" on both the Main project and the Pods project, otherwise it won't work. Many thanks!Countrybred
H
7

'pod deintegrate' and then 'pod install' worked for me.

Heavyfooted answered 29/10, 2018 at 20:18 Comment(1)
tried many other solutions. But this one worked. Really helped.Namesake
Y
5

I recently had this problem when using Xcode 12. I found that removing the Valid Architectures build setting (VALID_ARCHS) fixed it.

From the Xcode 12 release notes:

The Build Settings editor no longer includes the Valid Architectures build setting (VALID_ARCHS), and its use is discouraged. Instead, there is a new Excluded Architectures build setting (EXCLUDED_ARCHS). If a project includes VALID_ARCHS, the setting is displayed in the User-Defined section of the Build Settings editor. (15145028)

Yesima answered 19/9, 2020 at 8:6 Comment(0)
K
4

I am using Swift 4 and Xcode 9.4. This helped solve the same issue for me.

I selected the following frameworks in XCode -> Manage Schemes besides my target project

In Xcode:

Product-> Scheme-> FirebaseCore
Product -> Scheme -> nanopb
Product -> Scheme -> GoogleToolBoxforMac 
Kendall answered 27/6, 2018 at 1:29 Comment(0)
U
4

Tried the above suggestions, but they didn't work for me. What worked for me was to build to Generic iOS Device first and then run it on my physical device iPhone6.

I still couldn't run it on a simulator, however. What worked here was to change Build Active Architecture Only - Debug to NO, in the Pod Project Build Settings.

Hope this helps someone.

Urba answered 12/2, 2019 at 14:14 Comment(1)
Thank YOU @marceh , this helped me. After trying the steps above it didn't work.Gautious
Z
4

This worked for me:

  1. Close Xcode
  2. pod deintegrate
  3. delete xcworkspace
  4. pod install
  5. In project Navigator > project name > Configurations
  6. Set all to none
  7. Clean
  8. Build
Zagreus answered 20/8, 2019 at 4:50 Comment(0)
J
4

I had disabled Find Implicit Dependencies for faster build process under Edit Scheme... > Build.

Enabling it back resolved the issue. enter image description here

Jonniejonny answered 18/10, 2019 at 2:15 Comment(2)
Product => Edit Scheme... Short cut is command + <Rebeckarebeka
this worked for me too. I disabled "Find implicit Dependencies" and build was working fine too, I recently got this issue after updating the xcode. Error gone by enabling this option again on the new updated xCode.Baird
U
4

It happened to me because I installed the Firebase CocoaPods but I didn't reopen it through the <projectName>.xcworkspace file. So what I did to work was:

  • I quit Xcode
  • opened it by clicking the <projectName>.xcworkspace file of the project
  • then I could use "import Firebase" on my project.
Underline answered 17/1, 2020 at 22:39 Comment(0)
R
3

Can you please try to take a look at my answer here

TL;DR make sure you are running cocoapods version 1.4.0 minimum. It fixes static framework imports.

You can do this by running sudo gem install cocoapods on your terminal and verify your version by typing pod --version

Rhapsody answered 7/6, 2017 at 12:44 Comment(0)
K
3

I tried this (quitting Xcode, deleting all temp files, reinstalling pods, etc.) and it didn't work. What did work was just building my project (command + b) after pod install. Whatever works!

Keri answered 11/5, 2018 at 21:34 Comment(0)
C
2

Make sure you are working with the workspace file created in the same directory as the pod file.

Caracalla answered 30/8, 2019 at 19:4 Comment(0)
C
2

It worked for me, when I opened the white workspace instead of the blue one. You press on the file on your desktop and then press the white file.

Image of what the file looks like: Image of what the file looks like

Celesta answered 1/10, 2020 at 12:30 Comment(0)
T
1

Just go to Pod target and set arm64 in Excluded Architectures

enter image description here

Tswana answered 15/6, 2021 at 4:25 Comment(0)
P
1

I had a same issue with a Flutter project.

You should exclude arm64 for simulator architecture both from project and every pod target

Exclude arm64 from the project

Excluded Architectures

Add this code to Pofile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    # exclude arm64 for simulator architecture the pod target
    target.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end
Polycarp answered 1/7, 2021 at 22:0 Comment(0)
B
0

just restart your xcode and run your project.

Bula answered 30/10, 2018 at 16:51 Comment(0)
B
0

Nothing here worked for me, but then I figured out something that did work.

When I clicked on my project in Project Navigator in Xcode, and then selected Info I looked at the Configurations section and saw that there was only a Release configuration and no Debug configuration for my app.

In order to get Firebase to work, I went to Pods within the Project Navigator, and under the Configurations section I deleted the Debug configuration. Now it builds fine. Hopefully this will help someone else.

Bubo answered 12/11, 2018 at 23:30 Comment(0)
C
0

After 2 days of searching and trying every single step proposed in this post, eventually i could solve the problem. None of the above approaches solved my problem but this one:

  1. There is a package of Firebase frameworks available to download from this link: https://firebase.google.com/download/ios?authuser=0
  2. There is a Firebase.h header file in this package. I added this header file to my project resources.
  3. Finally i added a line of code at the top of this file: ' #import "Firebase.h" '

Simply and Easily the error is gone!

Ceraceous answered 12/9, 2019 at 16:47 Comment(1)
where do you add the Firebase.h file and where do you add the import statement? I've been struggling with this for days. everything builds and works fine but when I add the Firebase iOS SDK (FirebaseAnalytics) the project fails to build. this seems to be the answer but I'm confused as to how you managed to solve it.Bigener
E
0

For and Solution was as simple as I didn't open the project from the .xcworkspace after I did pod install :D and I got the same error you got. I mistakenly opened it from the old .xcodeproj file. that was it for me, LOL

Engineering answered 29/2, 2020 at 13:6 Comment(0)
V
0

None of above solutions worked for me. I found that the problem was I have three targets in Cocoapods file. And only my main one target has Firebase added. So that when I want to import Firebase to a file that is used in other targets, Xcode gives error and says Module 'Firebase' not found. This is my pods project file. One solution for me is adding Firebase pod to all targets. Or another solution is removing the file from other targets.

def common_pods
  pod 'XXX'
end

target 'myMainProject' do
  common_pods()
  pod 'Firebase/Core'
  pod 'Firebase/AdMob'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Analytics'
end

target 'myExtention1' do
  common_pods()
end

target 'myextension2' do
  common_pods()
end
Vaulting answered 27/3, 2020 at 16:10 Comment(0)
Q
0

This solution worked for me.

  1. Delete project's temp files located at ~/Library/Developer/Xcode/DerivedData
  2. Delete ProjectName.xcworkspace
  3. Delete Podfile.lock file and Pods folder Run pod install.
  4. Open the newly created ProjectName.xcworkspace file and build.
Qr answered 26/1, 2022 at 17:39 Comment(0)
E
-1

This happened to me today, I just couldn't figure out why, because when I closed the file that night, everything was perfect. I opened my file using the recent projects menu and got this issue. Then I decided to check something, Xcode opened the wrong file. Instead of opening the workspace file with the pods, it opened the Xcode project.

Once I opened the workspace it was error free and all the pods were behaving. Im sure you guys are all more experienced than me, but I just wanted to throw that in there.

Enlargement answered 13/8, 2018 at 13:22 Comment(0)
M
-1

When you build, make sure you are at the root directory in the project navigator.

Mesic answered 26/6, 2020 at 5:25 Comment(0)
A
-1

This worked for me:

  • rm -rf project.xcworkspace
  • rm -rf ~/Library/Developer/Xcode/DerivedData
  • rm -rf Podfile.lock
  • pod install

/!\ Open project.xcworkspace instead of your old file

Ascites answered 12/8, 2021 at 14:8 Comment(0)
S
-2

I had the exact same issue

You could be reinstalling pods with your Xcode open Or your pods file won't allow and overwrite

With your workspace open, delete the "Pods" folder. Quit X-Code Open terminal in "Utilities" You'll find this in "Applications" Using cd ... go to your project folder reinstall pods using "pod install".

That should fix it.

Spencerianism answered 19/1, 2017 at 9:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.