CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
It has over eighteen thousand libraries and can help you scale your projects elegantly. Cocoapods can be
used in your Codename One project to include native iOS libraries without having to go through the hassle
of bundling the actual library into your project. Rather than bundling .h and .a files in your ios/native directory,
you can specify which “pods” your app uses via the ios.pods
build hint. (There are other build hints also
if you need more advanced features).
E.g.:
To include the AFNetworking library in your app use the build
hint:
ios.pods=AFNetworking
To include the AFNetworking version 3.0.x library in your app use
the build hint:
ios.pods=AFNetworking ~> 3.0
For full versioning syntax specifying pods see the
Podfile spec for the “pod” directive.
Including Multiple Pods
Multiple pods can be separated by either commas or semi-colons in the value of the ios.pods
build hint.
E.g. To include GoogleMaps and AFNetworking, you could:
ios.pods=GoogleMaps,AFNetworking
Or specifying versions:
ios.pods=AFNetworking ~> 3.0,GoogleMaps
Other Pod Related Build Hints
ios.pods.platform
: The minimum platform to target. In some cases, Cocoapods require functionality that is
not in older version of iOS. For example, the GoogleMaps pod requires iOS 7.0 or higher, so you would need to
add the ios.pods.platform=7.0
build hint.
ios.pods.sources
: Some pods require that you specify a URL for the source of the pod spec. This may be
optional if the spec is hosted in the central CocoaPods source (https://github.com/CocoaPods/Specs.git
).
Converting PodFile To Build Hints
Most documentation for Cocoapods “pods” provide instructions on what you need to add to your Xcode
project’s PodFile. Here is an example from the GoogleMaps cocoapod to show you how a PodFile can be
converted into equivalent build hints in a Codename One project.
The GoogleMaps cocoapod directs you to add the following to your PodFile:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '7.0' pod 'GoogleMaps'
This would translate to the following build hints in your Codename One project:
ios.pods.sources=https://github.com/CocoaPods/Specs.git ios.pods.platform=7.0 ios.pods=GoogleMaps
Note that the ios.pods.sources directive is optional
|
5 Comments
This is really great! It’s made integrating the Parse iOS SDK *much* simpler. Thanks!!
Would these pods work on all three platforms (iOS, Android and Windows) or are these iOS specific?
No it’s designed for iOS native code.
Is there anything similar for Android?
Sure, Gradle: [https://www.codenameone.com…](https://www.codenameone.com/blog/tip-use-android-gradle-dependencies-native-code.html)