Crash when using Firebase with Swift Framework - firebase

I use Swift Frameworks (Cocoa Touch Framework) to segment code into fairly independent modules.I have imported several external libraries, with Cocoapods, into the main app and those modules without any issues so far.
Xcode 9.3
iOS 11.2
CocoaPods 1.5
GoogleToolboxForMac (2.1.3), Firebase (4.13.0), FirebaseAnalytics (4.2.0), FirebaseCore (4.0.20), FirebaseDatabase (4.1.5), FirebaseInstanceID (2.0.10)
However when I import Firebase in any of those modules, in addition to importing it in the main app, my application crashes.
I don't even need to use anything from Firebase in the modules ; simply adding the pod to the target (module Store in this case) in the Podfile will crash the app as soon as I leave the main window (fira_viewDidDisappear).
There is also a long list of issues during startup (that were also reported by others), all similar to :
objc[36264]: Class FIRAIdentifiers is implemented in both /{$userdir}/Library/Developer/Xcode/DerivedData/FrameWork101-aekmajbumgzabmayoanlcrwtzbcs/Build/Products/Debug-iphonesimulator/Store.framework/Store (0x105478318) and /{$userdir}/Library/Developer/CoreSimulator/Devices/31D920E9-CD46-47C4-9631-503B3471AAF7/data/Containers/Bundle/Application/57B8020D-E2AB-4A06-B654-5F26F8E00AF6/FrameWork101.app/FrameWork101 (0x103b1ef80). One of the two will be used. Which one is undefined.
Pretty ominous statement...
There are several threads somewhat related to this :
How do I Integrate the Firebase cocoaPods in my custom swift framework?
Building a swift Cocoa Touch framework with Firebase as a dependency
And even an issue (#6619) filed...
But they don't have a clear resolution / answer and the issue has even been closed without any resolution.
So is there a way to use Firebase in a modular approach (using frameworks) ? If so what's the best way to make this works ? Or is the Firebase SDK too invasive to do so ?
Thanks !
Podfile :
project 'FrameWork101.xcodeproj'
platform :ios, '11.2'
target 'Binding' do
use_frameworks!
pod 'ReactiveKit'
pod 'Bond'
end
target 'Model' do
use_frameworks!
target 'ModelTests' do
inherit! :search_paths
end
end
target 'Service' do
use_frameworks!
pod 'ReactiveKit'
pod 'Bond'
end
target 'View' do
use_frameworks!
pod 'ReactiveKit'
pod 'Bond'
end
target 'Store' do
use_frameworks!
pod 'ReactiveKit'
pod 'Bond'
pod 'Firebase/Database' <---- comment this out and it works fine.
end
target 'FrameWork101' do
use_frameworks!
pod 'Firebase/Core'
pod 'ReactiveKit'
pod 'Bond'
target 'FrameWork101Tests' do
inherit! :search_paths
end
end
And part of the crash report :

Related

FirebaseAuth Problem after Installing RevenueCat CocoaPod

I recently had put banner and interstitial ads on my application. After which, I decided to incorporate RevenueCat. Once the pod was installed, I had many errors that I could not fix. I decided to remove the CocoaPod. Once that was completed, I had been getting the following problems.
AVFoundation.h – AVFCore/AVFcore.h file not found
RPBroadCastExtension.h. – Could not build module AVFoundation
GameKit.h. – Could not build module ReplayKit
FIRGameCenterAuthProvider.m – Could not build module GameKit
I have been trying for 2-3 days to fix the problem. Here is what I have been doing.
I tried removing all pods and reinstall all the pods.
I try to clean the build. Same error came back.
I tried to add and remove RevenueCat.
I changed build setting to enable module c & Objective C. I added use_modular_headers! to Pod file.
my pod file
target 'FetalGrowthPercentile' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
use_modular_headers!
# Pods for FetalGrowthPercentile
pod 'Firebase/Firestore'
pod 'Google-Mobile-Ads-SDK'
pod 'Firebase/Auth'
end
None of which helps. I am lost. Please advise!!
Louis

How can you import a Pods Framework in WidgetKit?

I am using Amplify, which I installed through cocoapods and it works fine in my "regular" iOS application in Swift.
I have now created a Widget Extension, inside of which I would also like to use Amplify.
I have tried adding Widget.swift to the main app's target, but that didn't let me compile because now there were two #main structs. (For the app & for the widget)
Is there a way to import Amplify and use it in WidgetKit?
Edit your Podfile to apply Pod for all targets: application & widget. Ex:
def workspace_pods
pod 'YourPod'
end
target 'YourApplication' do
use_frameworks!
workspace_pods
end
target 'YourWidget' do
use_frameworks!
workspace_pods
end

Cocoapods error after installing "firebase_firestore" Flutter plugin [duplicate]

This question already has answers here:
Conflicts with FlutterFire and native GeoFire plugin on iOS
(2 answers)
Closed 5 years ago.
I've got my app working with the Firebase RTDB but want to experiment with Firestore so I have followed the instructions and installed the 'firebase_firestore' plugin.
When I run my app now I get the following error:
Resolving dependencies of `Podfile`
[!] Unable to satisfy the following requirements:
- `Firebase/Firestore` required by `firebase_firestore (0.0.1)`
Specs satisfying the `Firebase/Firestore` dependency were found, but they required a higher minimum deployment target.
I've tried specifying platform :ios, '9.0' and also 10.0in my Podfile but that didn't make any difference. All other pods install fine.
Here's the entire Cocoapods run log: https://pastebin.com/raw/SBz8Bqgf
My Podfile looks like this (standard Flutter Podfile):
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
if ENV['FLUTTER_FRAMEWORK_DIR'] == nil
abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework')
end
target 'Runner' do
# Pods for Runner
# Flutter Pods
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
if File.exists? '../.flutter-plugins'
flutter_root = File.expand_path('..')
File.foreach('../.flutter-plugins') { |line|
plugin = line.split(pattern='=')
if plugin.length == 2
name = plugin[0].strip()
path = plugin[1].strip()
resolved_path = File.expand_path("#{path}/ios", flutter_root)
pod name, :path => resolved_path
else
puts "Invalid plugin specification: #{line}"
end
}
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
Here's a link to the Podfile.lock, maybe that's more interesting. I see that it has not been updated with Firestore though, presumably because the run fails: https://pastebin.com/raw/hj2jHE76
In case anyone else stumbles across this issue I just wanted to expand on V. Roussel's answer (which I marked as the correct answer), since Flutter kind of abstracts away this Cocoapods process. Here's what I did to be able to run "pod repo / update":
Run pod repo update
Set the environment variable FLUTTER_FRAMEWORK_DIR to something that looks like /Users/youruser/bin/flutter/bin/cache/artifacts/engine/ios/. You can do a locate Flutter.podspec to find this directory
From YourFlutterProject/ios run pod update
After this you should be able to run your app again.
cloud_firestore has progressed to 0.03 by now, which should allow you to run the PODs.
in pubspec.yaml
cloud_firestore: "^0.0.3"
If that does not work from the start, add Firebase core to your podfile and run pod install.
Note: As far as I have seen, you cannot yet combine Firestore with other modules such as Firebase auth or Firebase analytics.

Pod Update of Firebase throwing errors

I am trying to install the Firebase Performance SDK and following their instructions on the site:
https://firebase.google.com/docs/perf-mon/get-started-ios
When I run the pod install step it gives me the following error:
firebase performance required by podfile
I run the pod update command and everything runs on the pod install but then when I open up my workspace I get errors in swift as such:
FIRDatabaseReference has been renamed to DatabaseReference
FIRDatabase has been renamed to Database
FIRFirebase.database().reference is now Database.database.reference
which then give the error
Database has no member reference
What gives!? Has anyone gotten these error after updating their podfile with Firebase!?
Pod file is as such:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'Pool' do
# Uncommnet this line if you're using Swift
use_frameworks!
#Pods for firebase pool
pod 'Firebase', '>=2.5.1' <--- This has been removed from the podfile as suggested
pod 'Firebase/Core'
pod 'Firebase/Performance'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
pod 'Firebase/Crash'
target 'PoolTests' do
# inherit! :search_paths
end
target 'PoolUITests' do
# inherit! :search_paths
end
end
Result of pod install
Error in xcode after pod install/update:
Here's a guide for upgrading Firebase iOS:
https://firebase.google.com/support/guides/firebase-ios
With 4.0 in particular, the Swift interfaces have been cleaned up to make it more "Swifty" which is why you're seeing those rename warning.
After the renaming, accessing the database reference should look like:
let ref:DatabaseReference = Database.database().reference()
For the updated docs of the new swift interface, see here:
https://firebase.google.com/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabase
The release of Firebase 4.0 on May 17 has the changed the naming convention and can be found in this naming migration guide:
https://firebase.google.com/docs/reference/ios/naming-migration-guide

Is it possible to include Firebase in watchOS 2 using Cocoapods?

I was previously using Firebase in a Watchkit Extension, but after upgrading to Xcode7/watchOS 2 it appears that a podspec for a repo now has to specifically include support for watchOS 2 as another available platform. (And then I will have to specify this in my Podfile as well). Will this be part of the Firebase Cocoapod soon, or is there a workaround in the mean time? Or am I just doing something wrong?
With my current Podfile:
platform :ios, '8.0'
use_frameworks!
pod 'Firebase', '>= 2.3.3'
link_with 'watch Extension'
I see this warning -
"Target 'Pods' of project 'Pods' was rejected as an implicit dependency for 'Pods.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'"

Resources