Real-World Example using CocoaPods
- PDF for offline use
Let us know how you feel about this
last updated: 2017-03
This example uses the AFNetworking CocoaPod.
New in version 3.0, Objective Sharpie supports binding CocoaPods, and even has a frontend command (
sharpie pod) to make downloading, configuring, and building CocoaPods very easy. You should faimilarize yourself with CocoaPods in general before using this feature.
sharpie pod command has one global option and two subcommands:
$ sharpie pod -help usage: sharpie pod [OPTIONS] COMMAND [COMMAND_OPTIONS] Pod Options: -d, -dir DIR Use DIR as the CocoaPods binding directory, defaulting to the current directory Available Commands: init Initialize a new Xamarin C# CocoaPods binding project bind Bind an existing Xamarin C# CocoaPods project
init subcommand also has some useful help:
$ sharpie pod init -help usage: sharpie pod init [INIT_OPTIONS] TARGET_SDK POD_SPEC_NAMES Init Options: -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
$ sharpie pod init ios AFNetworking ** Setting up CocoaPods master repo ... (this may take a while the first time) ** Searching for requested CocoaPods ... ** Working directory: ** - Writing Podfile ... ** - Installing CocoaPods ... ** (running `pod install --no-integrate --no-repo-update`) Analyzing dependencies Downloading dependencies Installing AFNetworking (2.6.0) Generating Pods project Sending stats ** 🍻 Success! You can now use other `sharpie pod` commands.
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:
(... lots of build output ...) Parsing 19 header files... Binding... [write] ApiDefinitions.cs [write] StructsAndEnums.cs Done.