forked from stripe/stripe-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_cardio.rb
executable file
·43 lines (35 loc) · 1.26 KB
/
install_cardio.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
#!/usr/bin/env ruby
# encoding: utf-8
# This script adds card.io to the swift example app.
begin
gem "xcodeproj"
rescue LoadError
system("gem install xcodeproj")
Gem.clear_paths
end
require 'xcodeproj'
puts '▸ Installing card.io – this may take a while'
open('Example/Cartfile', 'a') { |f|
f.puts "github \"card-io/card.io-iOS-source\""
}
system('cd Example; carthage update --platform ios')
project_name = 'Basic Integration'
project_path = "Example/#{project_name}.xcodeproj"
project = Xcodeproj::Project.open(project_path)
# add framework
lib_path = 'Carthage/Build/iOS/CardIO.framework'
libRef = project['Frameworks'].new_file(lib_path);
framework_buildphase = project.objects.select {
|x| x.class == Xcodeproj::Project::Object::PBXFrameworksBuildPhase
}[0];
framework_buildphase.add_file_reference(libRef);
# update carthage build phase
carthage_buildphase = project.objects.select {
|x| x.class == Xcodeproj::Project::Object::PBXShellScriptBuildPhase && x.name == "Carthage Copy Frameworks"
}[0];
carthage_buildphase.input_paths = [
'$(SRCROOT)/Carthage/Build/iOS/CardIO.framework',
]
project.save();
puts "▸ Updated #{project_name} to use card.io."
puts "▸ If you run the example app on a device, you'll see a 'Scan Card' option when adding a new card."