Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 54b6df0

Browse files
committed
Support --platform and --platform_version args
Fixes #13
1 parent 576672f commit 54b6df0

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cocoapods-playgrounds (1.0.0)
4+
cocoapods-playgrounds (1.1.0)
55
cocoapods (~> 1.0.0)
66

77
GEM

lib/cocoapods-playgrounds/command/playgrounds.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
require 'xcodeproj'
2+
13
module Pod
24
class Command
35
class Playgrounds < Command
6+
DEFAULT_PLATFORM_NAME = :ios
7+
48
self.summary = 'Generates a Swift Playground for any Pod.'
59

610
self.description = <<-DESC
@@ -11,14 +15,23 @@ class Playgrounds < Command
1115

1216
def self.options
1317
[
14-
['--no-install', 'Skip running `pod install`']
18+
['--no-install', 'Skip running `pod install`'],
19+
['--platform', "Platform to generate for (default: #{DEFAULT_PLATFORM_NAME})"],
20+
['--platform_version', 'Platform version to generate for ' \
21+
"(default: #{default_version_for_platform(DEFAULT_PLATFORM_NAME)})"]
1522
]
1623
end
1724

25+
def self.default_version_for_platform(platform)
26+
Xcodeproj::Constants.const_get("LAST_KNOWN_#{platform.upcase}_SDK")
27+
end
28+
1829
def initialize(argv)
1930
arg = argv.shift_argument
2031
@names = arg.split(',') if arg
2132
@install = argv.flag?('install', true)
33+
@platform = argv.option('platform', DEFAULT_PLATFORM_NAME).to_sym
34+
@platform_version = argv.option('platform_version', Playgrounds.default_version_for_platform(@platform))
2235
super
2336
end
2437

@@ -29,7 +42,7 @@ def validate!
2942

3043
def run
3144
# TODO: Pass platform and deployment target from configuration
32-
generator = WorkspaceGenerator.new(@names)
45+
generator = WorkspaceGenerator.new(@names, :cocoapods, @platform, @platform_version)
3346
generator.generate(@install)
3447
end
3548
end

0 commit comments

Comments
 (0)