[iOS SDK] Installing CocoaPods – MWPhotoBrowser into your Xcode project

This seems to be quite simple in the beginning, but the truth is that i had to fight with it for several hours/days. I’ll post the simplest step-by-step version of the process. For deeper info, visit cocoapods site and MWPhotoBrowser‘s page on GitHub.

1.- Installing Cocoapods:

Open a terminal (for beginners, CMD+Space, write “Terminal”, enter) and when open, write

sudo gem install cocoapods

the cursor will remain blank for a few minutes; This is normal. Be patient and wait for the process to finish. If you find conflicts during the install, mostly because of an old cocoapods install, you may want to try to delete cocoapods, as it is explained in this thread.

sudo rm -rf ~/.cocoapods

Captura de pantalla 2014-12-01 a la(s) 17.42.47

Once you get a green “Setup completed” message, time to create your Xcode project and configure cocoapods into it.

2.- Creating an Xcode projects that uses cocoapods

Create an Xcode project with “File > New > Project”, for example a “Single view application”. Name it whatever you want.

Now, on the terminal, go into recently created project’s folder, and create a file named “Podfile”.

cd projects/iOS/MyRecentlyCreatedProject/
touch Podfile

Now edit Podfile with a text editor of your choice, and include the desired libraries on it. In my case, i’ll include MWPhotoBrowser.

platform :ios, 7
pod 'MWPhotoBrowser'

Save the Podfile, and again inside your project’s directory, execute:

pod install

It should now download MWPhotoBrowser library and its dependencies.

Captura de pantalla 2014-12-01 a la(s) 17.35.45

When done, do an ls. You may notice a new file named MyRecentlyCreatedProject.xcworkspace that was not there before. Double-click it to open the project with Xcode.

You are now able to import MWPhotoBrowser’s sources into your classes.

 Captura de pantalla 2014-12-01 a la(s) 17.37.46

Hope this helped you! Have fun & happy coding!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s