cocoapods1

When Cocoapods ATTACK!

In my NativeScript apps, I tend to use some carefully-selected plugins to enable third-party functionality such as CardViews and the FAB (floating action button) for fancy navigation and UI building. Another plugin that I’m actively using is Eddy Verbruggen’s Firebase plugin for NativeScript: https://github.com/EddyVerbruggen/nativescript-plugin-firebase. With this plugin, you can integrate your app into the very awesome Firebase platform, such that in one fell swoop you get a database, authentication including social auth, file storage, Remote Config (which allows you to push content into your production app without requiring a re-submission of the app to the store) and push notifications.

Firebase is pretty awesome.

However, this plugin and Firebase itself is moving pretty fast. You need to keep on top of the changes by periodically updating the plugin’s version in the dependencies list of package.json:

“nativescript-plugin-firebase”: “^3.4.0”,

You may need to bump the plugin version up, and normally you would do that by augmenting the number in package.json after a release by Eddy, and then in the NativeScript CLI typing `tns install`. Normally the plugin would also update the Cocoapod on which this plugin is based, but sometimes you might run into problems. It’s important to have the plugin and the Cocoapod version that it’s expecting match up, but sometimes you might run into trouble and the plugin update will fail, because your system won’t update the Cocoapod.

Note, for NativeScript, you need to remain on version 0.39.0 of Cocoapods. There’s an update to 1.0.x but don’t go there!

Here’s how to handle problems you might encounter with updating your Firebase installation.

You might get this error, indicating that the plugin needs a higher level of Firebase’s SDK as installed by its Cocoapod.

Analyzing dependencies
[!] Unable to satisfy the following requirements:

- `Firebase/Database (~> 3.3)` required by `Podfile`
Processing node_modules failed. Error: Command sandbox-pod failed with exit code 1 Error output: 
 [!] Unable to load a specification for the plugin `/Library/Ruby/Gems/2.0.0/gems/cocoapods-deintegrate-1.0.0`

[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`

You could go in to node_modules/nativescript-plugin-firebase/platforms/ios and look for the Firebase Podfile, changing the reference to the SDK required, but I don’t recommend this, as it’s there to enforce the right SDK.

Instead, look at the error message. The Cocoapod isn’t able to update its master repo.

You need to get rid of any older installation of a Firebase SDK on your system before you can install a new one. Normally to do this, you can go to /platforms/ios and type: pod repo update --verbose.

For me, this was failing because there were some rogue, untracked pods in my /Specs folder.

Using the –verbose flag, you can see which ones they are, and remove them manually:

For me the problem folders were:

Updating spec repo `master`
  $ /usr/local/bin/git pull --ff-only
  error: The following untracked working tree files would be overwritten by merge:
    Specs/JLCustomImagesViewerView/1.0.0/JLCustomImagesViewerView.podspec.json
    Specs/PJFDataSource/1.0.0/PJFDataSource.podspec.json
    Specs/Spotify-iOS-SDK/0.16.1/Spotify-iOS-SDK.podspec.json
  Please move or remove them before you can merge.
  Aborting
  Updating 3c20e73..89624d8

Once I removed these folders, I hit pod install and the entire repo is updated via Git, installing Firebase 3.3.0. After that, you can update your plugin via tns install, and move on down the road to Firebase happiness!

 

 

 

Leave a Reply