Mobile Tech Talk

Dependency manager to ease the use of libraries

We often use 3rd party libraries (both paid and free) in our projects to reduce development time and increase app functionality. This practice has served pretty well so far and will continue to assist in programming.

What if we can still use these, with additional features without having to manually download/update the right version? That would be great, right? A dependency manager tool can add the following features to the existing solution.

  • Dependencies are downloaded on need basis.
  • Automatic update of libraries; no manual interaction needed. There is still an option to stick to any specific version of library.
  • Libraries are available in centralized location, making it easy to search and integrate.
  • Get the latest patches/updates to the libraries.
  • Less than 2 minutes to include any available library to the project.
  • Existing projects can also be moved to dependency manager.

Dependency manager tool is available for both iOS and Android platforms.
It is straightforward and takes very less time to setup.

iOS

It has 4 simple steps

1. Install CocoaPods (to setup cocoa pods in the machine and it is one time task)[code lang=”js”]$ sudo gem install cocoapods[/code]

2. Create the Podfile with init command

[code lang=”js”]$ pod init[/code]

3. Add dependencies to Podfile

[code lang=”js”]platform :ios, ‘9.0’
use_frameworks!
target ‘MyApp’ do
..
pod ‘Google’, ‘~> 1.1’
pod ‘GoogleAnalytics’, ‘~> 3.13’
..
end[/code]

4. Install the dependencies with pos install command. This will install all the dependencies to your project.

[code lang=”js”]$ pod install[/code]

Now, Open the .xcworkspace file and you are set to use the libraries as you have used earlier.

Detailed instructions are given in the link “https://cocoapods.org/

Android

Android Studio supports this using gradle. We just have to add the dependencies to the build.gradle file

1. Add dependencies to build.gradle file[code lang=”js”]dependencies {

compile ‘com.android.support:appcompat-v7:19.0.1’

}[/code]

2. Click on sync now, it will automatically download the library files.
Now, you are set to use the libraries as you have used earlier.
We recommend using these dependency managers in projects. It helps in maintaining the source code and keeps in sync with the latest patches available in the libraries.

Hope you found this useful. Feedback, suggestions? Comment in.

Dhanaraj
Dhanaraj is a Solutions Architect and has a thorough knowledge of the app or product life-cycle from conceptualization to delivery.

Leave Your Comment

Your Comment*

Your Name*
Your Webpage