forked from CocoaPods/pod-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigureSwift.rb
62 lines (48 loc) · 1.85 KB
/
ConfigureSwift.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module Pod
class ConfigureSwift
attr_reader :configurator
def self.perform(options)
new(options).perform
end
def initialize(options)
@configurator = options.fetch(:configurator)
end
def perform
keep_demo = configurator.ask_with_answers("Would you like to include a demo application with your library", ["Yes", "No"]).to_sym
framework = configurator.ask_with_answers("Which testing frameworks will you use", ["Quick", "None"]).to_sym
case framework
when :quick
configurator.add_pod_to_podfile "Quick', '~> 2.2.0"
configurator.add_pod_to_podfile "Nimble', '~> 8.0.7"
configurator.set_test_framework "quick", "swift", "swift"
when :none
configurator.set_test_framework "xctest", "swift", "swift"
end
snapshots = configurator.ask_with_answers("Would you like to do view based testing", ["Yes", "No"]).to_sym
case snapshots
when :yes
configurator.add_pod_to_podfile "FBSnapshotTestCase' , '~> 2.1.4"
if keep_demo == :no
puts " Putting demo application back in, you cannot do view tests without a host application."
keep_demo = :yes
end
if framework == :quick
configurator.add_pod_to_podfile "Nimble-Snapshots' , '~> 8.0.0"
end
end
Pod::ProjectManipulator.new({
:configurator => @configurator,
:xcodeproj_path => "templates/swift/Example/PROJECT.xcodeproj",
:platform => :ios,
:remove_demo_project => (keep_demo == :no),
:prefix => ""
}).run
# There has to be a single file in the Classes dir
# or a framework won't be created
`touch Pod/Classes/ReplaceMe.swift`
`mv ./templates/swift/* ./`
# remove podspec for osx
`rm ./NAME-osx.podspec`
end
end
end