12

I'm getting a error that 'FirebaseMessaging module not found'. Below is my pod file structure.

Pod file structure

Official documentation shows Firebase/Messaging is available. I've written in pod file and tried to install it. The stats in terminal doesn't shows FirebaseMessaging installation and same does that pods directory.

Below is terminal stats.

Terminal screenshot

Where I'm going wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177

8 Answers8

13

The culprit was Pods! I removed all CocoaPods from Project using this link.

Thereafter, I again added Pods to project using this link.

Screenshot for logs

It really worked later!

Community
  • 1
  • 1
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
5

This code is from Firebase example Podfile for Messaging.

I'll say, try and change your Podfile, close XCode and run pod install

use_frameworks!
platform :ios, '7.0'

pod 'Firebase/Messaging'

target 'FCM' do
end
target 'FCMSwift' do
end
target 'FCMTests' do
end

I'm not sure if the order does change something in the way the pods work.

Idan
  • 5,405
  • 7
  • 35
  • 52
2

Just for record as that was the situation I faced. If you created a new target after installing the pods, you will get "Module not found" error. The weird thing that the project will build successfully. However, autocompletion won't work and these silly errors (module not found) will appear here and there.

To solve the issue, you need to introduce the new targets in Podfile. A systematic way to do that will be:

$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile

Then remove the Xcode workspace, and proceed with a new fresh Pod install.

Abdalrahman Shatou
  • 4,550
  • 6
  • 50
  • 79
2

Use

#import "FirebaseMessaging.h"

instead of

@module FirebaseMessaging
Pretasoc
  • 1,116
  • 12
  • 22
Davender Verma
  • 503
  • 2
  • 12
1

Remove Podfile.lock in the root of the project and redo the pod install. This worked for me.

Gr8Warrior
  • 699
  • 7
  • 11
0

Adding missing frameworks in the linked frameworks and the library section of the target and quite the Xcode may solve the issue. Give it a try; it solved mine.

[Edit]
Search for .framework in the project and you will see all those missing framework in red.

Vikram Sinha
  • 581
  • 1
  • 10
  • 25
0

Import #import "FirebaseMessaging.h" instead of @import FirebaseMessaging;

If you are using this code to get token ID:[[FIRInstanceID instanceID] token]

You can get this warning message: 'token' is deprecated: Use instanceIDWithHandler: instead.

For this use this code to get token ID.

[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result, NSError * _Nullable error) {
    if (error != nil) {
        NSLog(@"Error fetching remote instance ID: %@", error);
    } else {
        NSLog(@"Remote instance ID token: %@", result.token);
        NSString* message = [NSString stringWithFormat:@"Remote InstanceID token: %@", result.token];
        self.instanceIDTokenMessage.text = message;
    }
}];

https://firebase.google.com/docs/cloud-messaging/ios/first-message

Naresh
  • 16,698
  • 6
  • 112
  • 113
0

I encountered the same issue, I just reinstall pods, by pod install

Ali A. Jalil
  • 873
  • 11
  • 25