1+ require 'xcodeproj'
2+
13module 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