Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase/Analytics - App crashing on startup after updating pods. #4711

Closed
DannyEspina opened this issue Jan 21, 2020 · 9 comments
Closed

Firebase/Analytics - App crashing on startup after updating pods. #4711

DannyEspina opened this issue Jan 21, 2020 · 9 comments
Assignees

Comments

@DannyEspina
Copy link

  • Xcode version: 11.3.1
  • Firebase SDK version: 6.15.0
  • Firebase Component: Analytics
  • Component version: FirebaseAnalytics (6.2.1)

After updating pods my app will crashing upon start up with this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FIRInstallationsItem registeredInstallationWithJSONData:date:error:]: unrecognized selector sent to instance 0x2825fed40'

FIRInstallationsItem is in Firebase. How can I resolve this issue?

my Podfile:

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

target 'LoanMaster' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for LoanMaster
  pod 'MPNumericTextField', '~> 1.4.0'
  pod 'Charts', '~> 3.2.1'
  pod 'LGButton'
  pod 'RealmSwift'
  pod 'SpreadsheetView'
  pod 'IQKeyboardManagerSwift'
  pod 'GoogleMobileAdsMediationMoPub'
  pod 'PersonalizedAdConsent'
  pod 'PopupDialog', '~> 1.1'
  pod 'NVActivityIndicatorView'
  pod 'FBAudienceNetwork'
  pod 'Firebase/Analytics'
  pod 'Firebase/AdMob'
  pod 'XlsxReaderWriter', '~> 1.0'
  pod 'M13Checkbox'
   
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if ['SpreadsheetView', 'IQKeyboardManagerSwift', 'NVActivityIndicatorView'].include? target.name
          target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '4.0'
          end
        target.build_configurations.each do |config|
          config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = 'NO'
        end
      end
    end
  end
end
@google-oss-bot

This comment has been minimized.

@maksymmalyhin
Copy link
Contributor

@DannyEspina I am sorry to hear you have the issue.

The method [FIRInstallationsItem registeredInstallationWithJSONData: date:error:] is defined in an Objective C category. The implementation of the method may be not loaded if you don't have a flag -ObjC in "Other Linker Settings" in your app target.

Could you please make sure the -ObjC flag is present in "Other Linker Settings" in the build settings of your app target and let us know if it fixes the issue for you.

@DannyEspina
Copy link
Author

Hey @maksymmalyhin

I believe I already have -ObjC flag in my build settings

Screen Shot 2020-01-21 at 10 54 48 AM

@maksymmalyhin
Copy link
Contributor

@DannyEspina I am not able to reproduce the issue on my end so far. Could you provide a sample project where the crash happens please?

Another option to try. FirebaseInstallations is used by Firebase/Analytics which is a static framework. When I use the provided podfile I cannot see the -ObjC flag in FirebaseAnalytics pod target. It works fine for me without it, but you may try to add it manually or add something like this to your podfile:

...

post_install do |installer|
      installer.pods_project.targets.each do |target|
        if ['SpreadsheetView', 'IQKeyboardManagerSwift', 'NVActivityIndicatorView'].include? target.name
       ...
      end

      if ['FirebaseAnalytics'].include? target.name
        target.build_configurations.each do |config|
          config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
        end
      end

    end
...

Please let us know the result.

@DannyEspina
Copy link
Author

DannyEspina commented Jan 21, 2020

@maksymmalyhin I'll see if I can somehow create a sample app. My app is currently published to the App Store and the last thing I want is to set the whole project public.

Another thing I noticed is that I can only import FirebaseCore and not simply Firebase as you can see in step 5 in the setup page: https://firebase.google.com/docs/ios/setup

Here's my AppDelegate

//
//  AppDelegate.swift
//  Loan Calculator
//
//  Created by Danny Espina on 1/22/18.
//  Copyright © 2018 Danny Espina. All rights reserved.
//

import UIKit
import GoogleMobileAds
import RealmSwift
import FirebaseCore
import IQKeyboardManagerSwift

let appDelegate = UIApplication.shared.delegate as! AppDelegate

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var deviceOrientation = UIInterfaceOrientationMask.portrait
    
    
    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        return deviceOrientation
    }
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // Use Firebase library to configure APIs.
        FirebaseApp.configure()
        
        // Initialize the Google Mobile Ads SDK.
        GADMobileAds.sharedInstance().start(completionHandler: nil)
        
        // Migrate Realm
        let config = Realm.Configuration(
            // Set the new schema version. This must be greater than the previously used
            // version (if you've never set a schema version before, the version is 0).
            schemaVersion: 8,
            
            // Set the block which will be called automatically when opening a Realm with
            // a schema version lower than the one set above
            migrationBlock: { migration, oldSchemaVersion in
                // We haven’t migrated anything yet, so oldSchemaVersion == 0
                if (oldSchemaVersion < 1) {
                    // Nothing to do!
                    // Realm will automatically detect new properties and removed properties
                    // And will update the schema on disk automatically
                }
        })
        
        // Tell Realm to use this new configuration object for the default Realm
        Realm.Configuration.defaultConfiguration = config
        
        // Now that we've told Realm how to handle the schema change, opening the file
        // will automatically perform the migration
        _ = try! Realm()
        
        print("SDK Version: " +  GADRequest.sdkVersion())
        
        IQKeyboardManager.shared.enable = true
        IQKeyboardManager.shared.toolbarTintColor = .mainThemeOrange
        
        return true
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
        
        var bgTask: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier(rawValue: 0);
        bgTask = application.beginBackgroundTask(withName:"MyBackgroundTask", expirationHandler: {() -> Void in
            application.endBackgroundTask(convertToUIBackgroundTaskIdentifier(bgTask.rawValue))
            bgTask = UIBackgroundTaskIdentifier.invalid
        })
    }
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIBackgroundTaskIdentifier(_ input: Int) -> UIBackgroundTaskIdentifier {
	return UIBackgroundTaskIdentifier(rawValue: input)
}

I also had pod 'Firebase/Core before in my podfile. (It was mention Firebase/Core is no longer used) So I replace it with pod 'Firebase/Analytics but that doesn't seem to fix the issue and I still can only import FirebaseCore

Can any of this be an issue?

If not, I'll post a question on stack overflow still the issue might derive from my app. If I revert the pod update then my app works fine which is why I thought it could be a issue with the framework

@maksymmalyhin
Copy link
Contributor

@DannyEspina There must be some detail I am missing in your project configuration. When I use Cocoapods 1.8.4, Xcode 11.3 and Swift 5 with a simple app with your Podfile I can use import Firebase.

Could you share:

  • Coccoapods version
  • Xcode version
  • Swift version
  • any uncommon project configuration you can think may affect Cocoapods integration

Also, just another guess: may you have your Pods in a broken state for some reason? You may try pod deintegrate to cleanup pods in your project and pod cache clean --all to clean Cocopoads cache on your machine before running pod update.

As for the sample project. You may try to remove all unrelated files, API keys, GoogleServices-Info.plist, etc. from a copy of your project and send it to us. If it still has some info you don't want to share with everyone, you may send it to me directly.

@DannyEspina
Copy link
Author

Hey @maksymmalyhin, I finally fixed the issue. I had to compare the build settings from a sample project and mines and fixed some issues with my build settings.

Thanks for the help

@maksymmalyhin
Copy link
Contributor

@DannyEspina Happy to hear the issue was fixed for you! It will be great if you could post the settings you had to change. Then other people with similar problem will be able to find a solution faster.

@DannyEspina
Copy link
Author

DannyEspina commented Jan 25, 2020

@maksymmalyhin Not much of a change as more of setting it back where it was. Over the course of me developing my first app I believe I mess around with some of the build settings (Advice from stack overflow answers for Linker Command failed with exit code 1 errors).

I reseted Other linker flags, Framework Search Paths and Header Search paths. After that I did pod deintegrate -> pod cache clean --all -> pod clean -> pod update

After this it worked finally

@firebase firebase locked and limited conversation to collaborators Feb 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants