Firebase Module install on ios

2020-07-01 08:39发布

I followed all instructions for integrating the new firebase release on ios:

  1. I downloaded the file GoogleService-Info.plist and include it in the project.

  2. I installed the framework with cocoapods

The problem is with this line:

@import Firebase;

Xcode prints this error:

"Module Firebase not found"

What is the solution?

My code :

#import "AppDelegate.h"

@import Firebase

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [FIRApp configure];

    // Override point for customization after application launch.
    return YES;
}

标签: ios firebase
10条回答
看我几分像从前
2楼-- · 2020-07-01 09:02

Its work for me in this way.

using FirebaseCore/FirebaseCore.h

Try the below code.

#import "AppDelegate.h"
#import <FirebaseCore/FirebaseCore.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [FIRApp configure];
    return YES;
}
查看更多
Anthone
3楼-- · 2020-07-01 09:04

I had the same problem. 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

查看更多
▲ chillily
4楼-- · 2020-07-01 09:06

This is lame but i fixed integration problems by adding the sources to my project instead using pods. I had to manually fix few files too.

查看更多
在下西门庆
5楼-- · 2020-07-01 09:08

I have same issue and found solution in here: iOS - Firebase error: Use of unresolved identifier FIRApp running supplied code

Doing the following steps on the terminal command line:

  1. pod repo update
  2. Commented the pod 'Firebase' line from my Podfile
  3. pod install (this removed the old Firebase)
  4. Added the pod 'Firebase' line again.
  5. pod install (added the new Firebase)

2nd and 3rd steps were the key I think, otherwise CocoaPods didn't try to update it. As I said maybe this could've been solved by doing pod update but now I can't go back and try again.

查看更多
Animai°情兽
6楼-- · 2020-07-01 09:14

I ended up fixing it by using

#import <Firebase/Firebase.h>

instead of

@import Firebase

查看更多
叛逆
7楼-- · 2020-07-01 09:16

I tried the above but sadly, nothing worked. Clean the build folder, clearing Xcode cache helped me. Try this:

  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.

Pay extensive attention to the 6th step. Open this newly created xcworkspace, not xcodeproj.

Original answer: https://stackoverflow.com/a/44486792/913601

查看更多
登录 后发表回答