-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanualize.rb
More file actions
60 lines (51 loc) · 2.24 KB
/
manualize.rb
File metadata and controls
60 lines (51 loc) · 2.24 KB
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
module Fastlane
module Actions
class ManualizeAction < Action
def self.run(params)
UI.message ""
UI.message Terminal::Table.new(
title: "Manualize".green,
headings: ["Option", "Value"],
rows: params.values
)
UI.message ""
pbxproj_path = File.join(Dir.pwd, params[:project], 'project.pbxproj')
pbxproj = File.read(pbxproj_path)
target_id = /([0-9-A-Z]+) \/\* Unity-iPhone \*\/,/.match(pbxproj)[1]
target_attributes = "#{target_id} = {\n\tProvisioningStyle = Manual;\n};"
attributes = /\t+attributes = {\n\t+TargetAttributes = {\n((.|\n)*)\n\t+};\n\t+};/.match(pbxproj)
File.write(pbxproj_path, pbxproj.sub!(attributes[1], "#{target_attributes}\n#{attributes[1]}"))
UI.message "Updated target #{target_id} with ProvisioningStyle #{params[:style]}"
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Set Provisioning Style"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :project,
env_name: "FL_MANUALIZE_PROJECT",
description: "Xcode Project Path",
verify_block: proc do |value|
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :style,
env_name: "FL_MANUALIZE_STYLE",
description: "Provisioning Style",
verify_block: proc do |value|
options = ["Automatic", "Manual"]
UI.user_error!("Provisioning Style must be either #{options.join(' or ')}") unless options.include?(value)
end)
]
end
def self.authors
["thedoritos"]
end
def self.is_supported?(platform)
platform == :ios
end
end
end
end