Cocoa pods in xamarin iox
Hope you know what is Cocoa pods?
cocoa pods is …
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 37 thousand libraries and is used in over 2.6 million apps. CocoaPods can help you scale your projects elegantly.
First of all you need install ruby and cocoapods gem in to your mac.
Better if you have latest ruby version . You can check your ruby version using following code when you run on your terminal (mar terminal)
If you want to update ruby , better to use multiple ruby version with same machine. To do that I am recommend to use
rvm – Ruby Version Manager
Todo it you need to install Homebrew. For it first you need to run following command in terminal,
Your computer will then attempt to find the software, and then will start downloading it. A popup will appear.
Once the software is installed, click Done. That’s it! You’re now ready to install homebrew .
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install rvm use following code on terminal
curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --rails
This will take a few minutes, and once it’s done, quit and relaunch Terminal, then run this command:
type rvm | head -1
If you get rvm is a function, that means RVM was successfully installed. If not, go to the Troubleshooting section.
To make sure the latest versions of RVM, Ruby and Rails were installed, run the commands below:
You should get rvm 1.29.1 or higher.
Now you can install new ruby version using following code.
rvm install [version]
rvm install 2.3.1
This output also lets you know which version is the default and which one is the current one in use.
To use a specific version (2.2.0 in the example below) and also set it as the default version for new shell sessions:
rvm use 2.3.1 --default
Wow now you are ready to install cocoapods. To install cocoapods you following code on your mac terminal
sudo gem install cocoapods
Now all done. Now we want to use cocoapods libraries with xamarin. Todo that we need to install another package to your mac. its call
Objective Sharpie is currently a standalone command line tool for Mac OS X 10.10 and newer, and is not a fully supported Xamarin product. It should only be used by advanced developers to assist in creating a binding project to a 3rd party Objective-C library.
Objective Sharpie can be downloaded as a standard OS X package installer. Run the installer and follow all of the on-screen prompts from the installation wizard:
The sharpie pod command has one global option and two subcommands:
$ sharpie pod -help
usage: sharpie pod [OPTIONS] COMMAND [COMMAND_OPTIONS]
-d, -dir DIR Use DIR as the CocoaPods binding directory,
defaulting to the current directory
init Initialize a new Xamarin C# CocoaPods binding project
bind Bind an existing Xamarin C# CocoaPods project
The init subcommand also has some useful help:
$ sharpie pod init -help
usage: sharpie pod init [INIT_OPTIONS] TARGET_SDK POD_SPEC_NAMES
-f, -force Initialize a new Podfile and run actions against
it even if one already exists
Multiple CocoaPod names and subspec names can be provided to init.
$ sharpie pod init ios SWNetworking
I used SWNetworking library for example.
after above code you will see success message on the terminal.
Once your CocoaPod has been set up, you can now create the binding:
$ sharpie pod bind
This will result in the CocoaPod Xcode project being built and then evaluated and parsed by Objective Sharpie. A lot of console output will be generated, but should result in the binding definition at the end:
That is it. You are done…