I have tried every possible answer on this site but none of them have worked. I have added a pod file but after I import Firebase, I keep getting the (No such module 'Firebase') error
Here is the code of my appDelegate
//
// AppDelegate.swift
// Firebase app
//
// Created by Karan Singh on 11/21/19.
// Copyright © 2019 Karan Singh. All rights reserved.
//
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
and here is what my pod file looks like
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Firebase app' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Firebase app
# add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods
pod 'Firebase/Auth'
end
I am still learning coding in Xcode - thank you for helping me out with this!
as Hurobaki commented,You have to add firebase/core in podfile like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'FirebaseApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/Auth'
end
Related
I am trying to add Google MLKit Translate into my SwiftUI Project. I am already using firebase via SPM and only after the initial launch get this error: -[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x600001afa700
Here is my code:
App Delegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
FirebaseApp.configure()
...
let spanishRemoteTranslator = TranslateRemoteModel.translateRemoteModel(language: .spanish)
if ModelManager.modelManager().isModelDownloaded(spanishRemoteTranslator) {
print("Spanish Translator Downloaded")
}else {
print("Downloading Spanish Translator")
ModelManager.modelManager().download(spanishRemoteTranslator, conditions: ModelDownloadConditions(allowsCellularAccess: true, allowsBackgroundDownloading: true))
}
return true
}
Then I call it like so:
if ModelManager.modelManager().isModelDownloaded(spanishModel) {
Translator.translator(options: englishSpanishTranslator).translate(buis.name!) { translatedText, error in
if error == nil {
if let translatedText = translatedText {
name = translatedText
}else {
print("error = \(error)")
}
}else {
print("error = \(error)")
}
}
}else {
print("error = Spanish not downloaded")
}
I have also tried using the built in FirebaseMLKitDownload and that doesn't have translator. What is going on?
Probably an author of this post found solution of this problem (judging by the comment) but I decided to write this post because few hours ago during taking my first steps with Firebase I had the same error. I hope my post may be helpful for each other.
I had no idea how to find solution but after few hours of debugging I noticed that the problem occurs when I had initialized project with Firebase using dependency manager built-in in the Xcode and then I tried to initialize Firestore using CocoaPods. To be more specific, first thing I do was Firebase installation using this one:
Then, I started using CocoaPods like:
$ pod init
$ vim Podfile // adding 'firebase/firestore' dependency or specific line from https://github.com/firebase/firebase-ios-sdk
$ pod install
$ open <ProjectName>.xcworkspace
In the next step, I tried to check basic Firestore operations like creating collection and documents with data and when I run the app - I got similar error. It was an exception during app run.
I think in my case the problematic thing was possible duplicates because of supplying the project with a Firebase (with all dependencies) twice.
So, I removed dependency installed from the Xcode manager. In my Info.plist there is no dependencies:
Then, from the terminal I removed Pods directory and just called an update.
$ rm -rf Pods
$ pod update
All dependencies were re-installed and workspace has been recreated.
Now, after these steps everything works fine.
Go easy on me please. I'm not familiar with Swift and AWS. I'm trying to use AWS Authentication for user login. Using AWSCognitoAuthPlugin, I get this error:
An error occurred setting up Amplify: PluginError: Unable to decode configuration
Recovery suggestion: Make sure the plugin configuration is JSONValue
What I have on my Swift file is very generic, following the AWS guide to get set up. I have no UI for the login as of now. I'm seeing the error via log.
Here's my code:
import SwiftUI
import Amplify
import AWSAPIPlugin
import AWSDataStorePlugin
import AWSCognitoAuthPlugin
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
do {
Amplify.Logging.logLevel = .verbose
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure()
print("Amplify configured with auth plugin")
} catch {
print("An error occurred setting up Amplify: \(error)")
}
return true
}
}
#main
struct MyAmplifyAppApp: App {
#UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
I'm not using cocoa pods because that causes the import statement for amplify to not work. I'm following this guide from AWS:
https://docs.amplify.aws/lib/auth/getting-started/q/platform/ios#install-amplify-libraries
Stuck at Initialize Amplify Auth section last step.
I was also facing same error for few days, you just have added basic files to the project and now you need to define user pools for Amplify to add more data to both config files. You need to run these commands it will fix this issue. Please make sure you are in directory of your project.
amplify init // It will make sure you have basic setup added
amplify add auth // It will add auth data and user pools to config files
amplify push // It will push all the setup to amplify cloud
Hope it will fix this issue :)
I got some warning message. Most of them disappeared after updating related Pods. But these 3 warnings are still there. I don't have the AppAuth pod but the Firebase/Auth and Firebase/Core. What should I do to get rid of them?
Thanks,
Below is the Podfile.
=========================
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
target ‘test’ do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# use_modular_headers!
# Pods for test
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'GoogleSignIn'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Performance'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
target ‘testTests' do
inherit! :search_paths
# Pods for testing
end
target ‘testUITests' do
inherit! :search_paths
# Pods for testing
end
end
AppAuth is a dependency of GoogleSignIn that is designed to work on iOS 7 and above.
Changing the version to 10 in the post_install script in the Podfile by deleting the minimum iOS version 7 causes the warning.
Instead of deleting it, you might be able to eliminate the warning and also the Xcode 12 warning because of no iOS 8 support by changing the minimum version to 9:
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
Thanks to https://stackoverflow.com/a/58367269/556617 for the post_install script.
As indicated Xcode, it was deprecated so use this new method instead of openUrl
open func open(_ url: URL, options: [String : Any] = [:],
completionHandler completion: (#escaping (Bool) -> Swift.Void)? = nil)
If you realize two new parameters has default values: an empty dictionary and optional closure which is nil. That is why you can easily use as openUrl
I'm trying to get my swift Xcode project to connect with Firebase, but I'm getting an error. I followed the exact steps provided in add Firebase to your iOS app step, and it's saying I have Thread 1: signal SIGABRT (terminating with uncaught exception of type NSException). I tried multiple times just to remove pods from the directory/project and start over but I feel like I'm removing the pods wrong. Is there a way I can completely remove all pods/configurations created to the projects?
podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'SimonGame' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for SimonGame
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Firestore'
end
app delegate:
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
Use pod deintegrate to completely remove pods from your project but if Firebase is causing the issue, it better that you remove Firebase from your pods and run pod install again. See if the issue still persists. It would be better if you could paste the crash backtrace here to find out the real cause of crash.
try this remove the # sign from platform :ios, '9.0'
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'SimonGame' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for SimonGame
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Firestore'
end
I am trying to get the Bluemix Cordova Hello World sample working with IBMPushNotifications Service. I have installed the cordova plugins and if I run cordova plugin list I see:
ibm-mfp-core 1.0.10 "MFPCore"
ibm-mfp-push 1.0.12 "MFPPush"
My index.js initialization code looks like this:
onDeviceReady: function() {
BMSClient.initialize(app.route, app.guid);
BMSClient.registerAuthenticationListener("MyRealm", customAuthenticationListener);
// alert("******** ABOUT TO CALL MFPPush.registerDevice **************");
// MFPPush.registerDevice(iosPushSettings, pushSuccess, pushFailure);
MFPPush.registerDevice({}, pushSuccess, pushFailure);
I do have the MAS customAuthentication service running and working.
I am running the code on an attached iPad via Xcode. I've added some debugPrint statements inside the plugin swift file and see the following messages in the Xcode Console:
"Inside Register Device!!!!!!!"
"Inside registerNotificationsCallback"
"Settings Parameter is not null"
"settings.count == 0"
"about to set notificationSettings"
"About to registerForRemoteNotifications"
"Called registerForRemoteNotifications"
I am not a swift or iOS developer, so I am pretty ignorant on debugging and working with iOS apps. I tried to set breakpoints in the AppDelegate.m file and appears that the code is hitting the breakpoint in didRegisterForRemoteNotificationsWithDeviceToken and I think a token value is getting set. However, I never see my debugPrint code getting triggered in the CDVMFPPush.swift file inside
func didRegisterForRemoteNotifications(deviceToken: NSData) {
debugPrint("Inside didRegisterForRemoteNotifications")
or inside
func didFailToRegisterForRemoteNotifications(error: NSError) {
debugPrint("Inside didFailToRegisterForRemoteNotifications")
As far as I can tell, I have set up the APNS Cert and provisioning profile and I have uploaded my sandboxAPNS.p12 file without any errors into my Bluemix Push service.
On the Bluemix Push Dashboard, if I try to send a push notification to all devices, I receive the following error:
Internal server error. No devices found
I also see PushNotifications enabled in the capabilities tab for my app in XCode.
I am trying to determine why I never see my debugPrint statements for the didRegister or didFailToRegister and why Bluemix does not see my device. Thanks for any suggestions on how to debug and again my apologies for my ignorance on swift and XCode.
JT
OK, I got Push notifications working. It turns out I needed to modify the AppDelegate.m file as per the docs and the Git readme:
// Register device token with Bluemix Push Notification Service
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
[[CDVMFPPush sharedInstance] didRegisterForRemoteNotifications:deviceToken];
}
// Handle error when failed to register device token with APNs
- (void)application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
[[CDVMFPPush sharedInstance] didFailToRegisterForRemoteNotifications:error];
}
// Handle receiving a remote notification
-(void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[[CDVMFPPush sharedInstance] didReceiveRemoteNotification:userInfo];
}