firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.49k stars 1.43k forks source link

FR: Instructions for Adding Firebase to macOS App #1757

Closed cliftonlabrum closed 5 years ago

cliftonlabrum commented 5 years ago

I recently installed Firebase in a macOS+iOS app in Xcode manually (I didn't use CocoaPods). I followed the instructions in the Readme that are included in the frameworks download that Google provides here: https://firebase.google.com/docs/ios/setup?authuser=1#frameworks

I did everything the same during the installation between iOS and macOS (linking the frameworks, other linker flags, etc.).

I can successfully build my iOS app with Firebase and can write data to the server. Yay.

But when I attempt to build my macOS app, I get 238 build errors and warnings. 😱 I have attached a few examples.

errors warnings

There seems to be little point in going in and trying to address each and every one. Clearly I did something wrong.

Are there macOS installation instructions somewhere to assist me in my plight? I'm desperately hoping to get Firebase to work for macOS and iOS together. 🙂Thanks!

paulb777 commented 5 years ago

@cliftonlabrum Thanks for the report. Sorry, we don't have instructions or provide binaries for manual installation of macOS. Only CocoaPods installations are currently available for macOS and tvOS.

cliftonlabrum commented 5 years ago

Thanks for your quick reply. So in order to get iOS and macOS in Cocoapods, would I have to do something like this where I grab everything for iOS, but have to cherry pick the specific pods for macOS?

target :ios do
  pod 'Firebase/Core'
end

target :osx do
  pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
  pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
  pod 'FirebaseDatabase', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
  pod 'FirebaseStorage', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
end

Or, if I want full parity between iOS and macOS, could I just install the 4 pods supported by macOS for both?

pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
pod 'FirebaseDatabase', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
pod 'FirebaseStorage', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'

Thank you!

paulb777 commented 5 years ago

You could just install the four pods for both. The difference would be that you won't get FirebaseAnalytics which is only available for iOS and gets installed with Firebase/Core.

I would recommend only specifying the following to get the latest released versions instead of the very latest sources:

pod 'FirebaseCore'
pod 'FirebaseAuth'
pod 'FirebaseDatabase'
pod 'FirebaseStorage'
cliftonlabrum commented 5 years ago

Perfect, thank you!

Jaycyn commented 5 years ago

I am encountering a macOS issue in that the project compiles and Authentication is working but I am not able to connect to the database. I used the pod setup shown in a prior comment. I've got the app added to the Firebase project and GoogleService-Info correct. This line runs when a button is clicked in the UI

let fbRef = Database.database().reference()

but the result is that fbRef is not a valid value

fbRef DatabaseReference 0x0000000000000000

oh - the in the AppDelegate I have this

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        FirebaseApp.configure()
    }

Is there something else needed to use Firebase on macOS?

paulb777 commented 5 years ago

@visdyn It might be #2248

Jaycyn commented 5 years ago

And that is 100% the correct answer. That one change fixed it. I was searching the issues for macOS in title. Thanks for the lightning fast response.

rawmean commented 4 years ago

You could just install the four pods for both. The difference would be that you won't get FirebaseAnalytics which is only available for iOS and gets installed with Firebase/Core.

I would recommend only specifying the following to get the latest released versions instead of the very latest sources:

pod 'FirebaseCore'
pod 'FirebaseAuth'
pod 'FirebaseDatabase'
pod 'FirebaseStorage'

Given that FirebaseAnalytics is not supported for macOS, how can I exclude it when building for macOS? As you pointed out, FirebaseAnalytics gets installed automatically when FirebaseCore is installed.

paulb777 commented 4 years ago

Note the difference between Firebase/Core and FirebaseCore. The first is a subspec of the Firebase pod that depends on FirebaseAnalytics. The second is only the FirebaseCore pod. Only the latter should be used for macOS.

rawmean commented 4 years ago

Note the difference between Firebase/Core and FirebaseCore. The first is a subspec of the Firebase pod that depends on FirebaseAnalytics. The second is only the FirebaseCore pod. Only the latter should be used for macOS.

Solved! Thank you so much. I spent an entire day trying to fix this.

loucimj commented 4 years ago

pod 'FirebaseCore' pod 'FirebaseAuth' pod 'FirebaseDatabase' pod 'FirebaseStorage'

I've updated to the latest versions of those libs and I can't get to compile a previously working code. It throws the following error: FIRAuthKeychainServices.h' file not found

Any hint of what is going on here?

Here is my podfile:

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

target 'QontactAdmin' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  pod 'FirebaseCore'
  pod 'FirebaseAuth'
  pod 'FirebaseDatabase'
  pod 'FirebaseStorage'

  # Pods for QontactAdmin

  target 'QontactAdminTests' do
    inherit! :search_paths
    # Pods for testing

  end

end
paulb777 commented 4 years ago

@loucimj Try cleaning the project and DerivedData

Jaycyn commented 4 years ago

I just now updated from 6.0 to 6.1 and it compiled and worked correctly with no error. My podfile is identical to yours.

loucimj commented 4 years ago

@loucimj Try cleaning the project and DerivedData

I've cleaned the project and the error persisted. The trick was to erase the DerivedData folder. Thanks!!

rawmean commented 4 years ago

The iOS app works perfectly and can access the firebase database, but the Catalyst app gives the following error:

6.11.0 - [Firebase/Database][I-RDB038012] Listener at /my_database/path failed: permission_denied

I have created an app in firebase console with the same bundleID of the Catalyst app and downloaded the and included the GoogleService-info.plist in the project (replaced the one for the iOS app).

my PodFile:

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
# Uncomment this line if you're using Swift

def reusepods
end

target 'MyTargerName' do
    use_frameworks!
#    pod 'Firebase/Core'
    pod 'FirebaseCore'
    pod 'Firebase/Database'
    pod 'Firebase/Auth'
    pod 'Charts'
    pod 'EMAlertController'    
end
paulb777 commented 4 years ago

@rawmean Thanks for the report. Please create a new issue to track the Catalyst specific problem.