Cannot resolve symbol 'FirebaseApp', 'FirebaseOptions', and 'GoogleCredentials'
This scope:
<scope>runtime</scope>
is documented as:
This scope indicates that the dependency is not required for compilation, but is for execution. Maven includes a dependency with this scope in the runtime and test classpaths, but not the compile classpath.
So it's not surprising the compiler can't find it. Remove the scope and that should fix the FirebaseApp
and FirebaseOptions
failures. For GoogleCredential
, you need to import com.google.api.client.googleapis.auth.oauth2.GoogleCredential
.
Firebase doesn't build on M1 simulator (Cannot find 'Analytics' in scope)
Go to Project (NOT TARGET)
- Build Settings
- Excluded Architectures
- Debug -
Add a new setting called
Any iOS Simulator SDK - arm64
If you are using Pods, you should repeat above for your Pods PROJECT as well.
Some pod targets (like pod KeychainAccess in your case) might not be respecting what you had set at Pods PROJECT level, you might want to fix this exact same thing for offending Pod targets as well.
Or instead of checking all of the pod targets one by one, you could add this at the end of your podfile -
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
After doing this, do a pod install
and a clean build, you should be good to go.
Cannot import Firebase in Swift app
You shouldn't need to use a Bridging Header.
The Firebase SDK uses Swift module mapping, so you'll have to let CocoaPods know.
Use this podfile:
use_frameworks! # this allows you to use import Firebase
pod 'Firebase', '>= 2.5.0'
Then you should be able to use import Firebase
in any Swift file.
Sometimes after opening from CocoaPods install, XCode can get confused. Do a Cmd+K
to clean and a Cmd+Shift+R
to rebuild. If that still is giving you errors, then restart Xcode and try the clean and build again.
Error: `call FirebaseApp.configure() before using Firestore`
Firstly, I would like to thank @DionzB for suggesting using singletons (which I did). I will reference his/her post in this answer.
Ok, so after some research and playing with breakpoints, I found that my custom class actually executes before the AppDelegate. Knowing such, I created a variable before the following line:
static let shared = FirebaseService()
the name does not matter, because I/you will not call it, and assign it to FirebaseApp.configure()
The FirebaseService class becomes:
class FirebaseService: NSObject {
let constantToNeverTouch = FirebaseApp.configure()
static let shared = FirebaseService()
init() {
}
}
Next, you must make sure that FirebaseApp.configure() is no where else in your code. It should not be in the AppDelegate either. Having multiple FirebaseApp.configure()'s crashes the app.
Related Topics
How to Add More Cases for Enum in Swift
Convert Single File to Swift 3 in Xcode 8
Why Would One Use Nested Classes
Enum Initialized with a Non-Existent Rawvalue Does Not Fail and Return Nil
How to Use Crc32 from Zlib in Swift (Xcode 9)
How to Detect If The User Was Deleted from Firebase Auth
Animation Delay on Left Side of Screen in iOS Keyboard Extension
Is There Any Reasonable Way to Access The Contents of a Characterset
Cannot Decode Object of Class (Ampathpopupbutton)'
Wkwebview Won't Load (Nsviewcontroller, Os X)
Is There Any Difference at All Between Suffix(From:) and Dropfirst(_:)
How to Test If an Instance Is a Specific Class or Type in Swift
Swift Protocol Extension Implementing Another Protocol with Shared Associated Type
Swift 2.0 Replicate Objc_Association_Retain
Navigation Link in Bar Items Goes Back to Top of Navigationview