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
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:
It should now download MWPhotoBrowser library and its dependencies.
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.
Hope this helped you! Have fun & happy coding!