watchOS 2 working with CocoaPods

4.5k views Asked by At

Has anyone gotten CocoaPods working with watchOS 2? I tried using ‘use_framework!’ with ‘platform :watchos, ‘2.0’ but it says "[!] Invalid Podfile file: Unsupported platform watchos2. Platform must be :ios or :osx.. Updating CocoaPods might fix the issue.”

I am on the latest version of CocoaPods.

3

There are 3 answers

0
Keith Smiley On BEST ANSWER

CocoaPods currently doesn't support watchos. There is a work in progress issue here for adding support for it.

0
Yusuke Kita On

CocoaPods released new version which is 0.38.0 and now supports watchOS 2.
http://blog.cocoapods.org/CocoaPods-0.38/

According to the blog above, deployment target can be set to watchOS 2 in Podspec.

Pod::Spec.new do |s|
# …
s.watchos.deployment_target = '2.0'
end

You can set target for watchOS 2 in Podfile with the version.
However, library has to set the deployment target explicitly, so you need to check whether it's supported for each library in Podspec.

0
Senseful On

The latest version of CocoaPods supports this.

If you just need to get a pod working on watchOS 2 (e.g. Parse), the you can simply use a Podfile such as this:

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!

target 'MyApp' do

end

target 'MyApp WatchKit App' do

end

target 'MyApp WatchKit Extension' do
    platform :watchos, '2.0'
    pod 'Parse', '~> 1.11'
end

If however, you need to use the pod in multiple targets of different platforms (e.g. iOS and watchOS 2), things are slightly tricker. See this answer for more information.