Install Cocoapods without Admin privileges (sudo-less)




WHAT IS COCOAPODS

According to Wikipedia, CocoaPods is an application level dependency manager for the Objective-C, Swift and any other languages that run on the Objective-C runtime, such as RubyMotion, that provides a standard format for managing external libraries. It was developed by Eloy Durán and Fabio Pelosin, who continue to manage the project with the help and contributions of many others. They began development in August 2011 and made the first public release on September 1, 2011. CocoaPods is strongly inspired by a combination of the Ruby projects RubyGems and Bundler.

CocoaPods focuses on the source-based distribution of third-party code and automatic integration into Xcode projects.

COCOAPODS SUDO-LESS INSTALLATION 

As soon as I started working with DataCore and Firebase on my iOS applications, I realized I need Admin privileges in order to install Cocoapods on a MAC computer. However, at the time I was writing this, I did not own a MAC and was using PCL Media Lab to complete my iOS homework, and of course, I was not granted admin privileges on those lab computers. So how could I pass by this issue?

Here is a walk-around I followed to install Cocoapods without admin privileges.

Instead of granting RubyGems admin privileges to install Cocoapods, you can also install Cocoapods into your user directory either by using the flag --user-install when running the command gem install or by configuring the environment. Simply to config the RubyGems environment, create or edit the .profile file in your home directory and add these two lines:


export GEM_HOME=$HOME/.gem

export PATH=$GEM_HOME/bin:$PATH

For some reasons, this solution did not work out with the lab computer I was using, so I stayed with the option --user-install and the lab computer was happy with it. To install Cocoapods into your user directory, simply run this command in the command prompt:

$ gem install cocoapods --user-install

Even if you choose to install Cocoapods into your user directory, you still need to configure your .profile file to set the PATH or you have to use the command prepended by the full path whenever you run pod commands. You can find out where gem is installed with gem which cocoapods.

$ gem install cocoapods --user-install 
$ gem which cocoapods 
/Users/<your_user_directory>/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb 
Beyond this point, you can run pod commands from your Xcode project directory. E.g.

From to your Xcode directory, create a Podfile if there isn't existing one:

$ /Users/<your_user_directory>/.gem/ruby/2.0.0/bin/pod init

Open and edit your Podfile to include necessary pod features that you need, then install pod with the following command that will generate a Podfile.lock for your project. Now you are good to go :)

$ /Users/<your_user_directory>/.gem/ruby/2.0.0/bin/pod install

No comments:

Post a Comment

Pages