Using Cocoapods with watchOS 2
Cocoapods are a lifesaver. Until they break.
With the introduction of watchOS 2, developers can now create completely native watch apps. Which means, at some point, we will want to use Cocoapods in our watch extensions.
It turns out that Xcode now treats watchOS as a separate platform, so most Cocoapods repos will not function.
If you try to use pods with a watch extension you will receive a warning that looks like this:
Target ‘Pods-MyWatchExtension’ of project ‘Pods’ was rejected as an implicit dependency for ‘Pods_MyWatchExtension.framework’ because it doesn’t contain platform ‘watchsimulator’ in its SUPPORTED_PLATFORMS ‘iphonesimulator, iphoneos’
You will also have an error saying:
No such module 'PodIAmTryingToUse'
To fix this, two things must happen:
The podspec for the repository you are trying to use must add watchOS support. Which you can do like so:
And you must edit your podfile to correctly handle the watch extension’s target:
target 'My App' do
platform :ios, '9.0'
target 'My App Watch Extension' do
platform :watchos, '2.0'
Since both Mantle and AFNetworking do not support ‘watchos’ as a platform yet, Orta suggests forking the pod and making the edit.