Podfile -> Right Click -> Pod Install

The Pod Install Automator trick
TL:DR: Github Link

Hi friends!

Recently when I was trying my hands on working with dependencies in Android when I came across a nice Android Studio feature.

In android, dependencies are implemented in a build.gradle file in the below format:

apply plugin: 'com.android.application'
android { ... }
dependencies {
// Dependency on a local library module
compile project(":mylibrary")
    // Dependency on local binaries
compile fileTree(dir: 'libs', include: ['*.jar'])
    // Dependency on a remote binary
compile 'com.example.android:app-magic:12.3'
}

Well! In iOS too, we do something similar... like the Podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target ‘MyApp’ do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Kingfisher', '~> 3.0'
pod 'Alamofire', '~> 4.4'
end

But! There’s a catch!

  • In iOS, on updating the podfile , we have to manually hit “pod install” in Terminal, to install/uninstall the dependencies but,
  • In Android, we have a toolbar icon for updating dependencies.

So, I thought of creating something similar in iOS as well and here it goes.


The Automator 😉

I created an automator work-flow for doing the pod install trick.

The Automator Pod Install Service

We first create an automator service workflow, wherein we:

  • Specify Input Source as Files & Folders
  • Get the selected Finder Items & Copy them to Clipboard to get their absolute addresses
  • Save the address to variable named podFilePath
  • Run shell script (which extracts the podfile’s folder & runs pod install)

Conclusion

This little trick saves time and now we don’t need to open terminal to run pod install. However , you may need to do a Show in Finder on the pod file (in Xcode) but I a working on making this more robust and slick.

Like what you read? Give Abhishek Bedi a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.