-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxcodeproj_config.rb
126 lines (119 loc) · 4.29 KB
/
xcodeproj_config.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
require 'rubygems'
require 'xcodeproj'
require 'yaml'
project = Xcodeproj::Project.open(ARGV[0])
config = YAML.load(File.read(ARGV[1]))
build_setting = config["build_setting"]
project_setting = build_setting["project"]
if (project_setting != nil)
project_setting.each do |key, value|
if (value.class == Hash)
value.each do |cfgName, val|
project.build_settings(cfgName)[key] = val
end
else
project.build_configurations.each do |configuration|
configuration.build_settings[key] = value
end
end
end
end
targets_setting = build_setting["targets"]
if (targets_setting != nil)
project.targets.each do |target|
target_setting = targets_setting[target.name]
if (target_setting != nil)
target_setting.each do |key, value|
if (value.class == Hash)
value.each do |cfgName, val|
target.build_settings(cfgName)[key] = val
end
else
target.build_configurations.each do |configuration|
configuration.build_settings[key] = value
end
end
end
end
end
end
phases_config = config["build_phase"]
if (phases_config != nil)
# run_script
run_script_phases = phases_config["create_run_scripts"]
if (run_script_phases != nil)
run_script_phases.each do |name, phase|
if (phase.class == Hash)
phases_target = phase["tragets"]
script = phase["script"]
phases_target.each do |target_name|
project.targets.each do |target|
if (target_name == target.name)
run_script_phase = target.new_shell_script_build_phase(name)
run_script_phase.shell_script = script != nil ? script : ""
break
end
end
end
else
project.targets.each do |target|
run_script_phase = target.new_shell_script_build_phase(name)
run_script_phase.shell_script = phase
end
end
end
end
# add resources
resources = phases_config["add_resources"]
if (resources != nil)
resources.each do | resource |
if (resource.class == Hash)
phases_target = resource["tragets"]
file = resource["file"]
phases_target.each do |target_name|
project.targets.each do |target|
if (target_name == target.name)
file_ref = project.main_group.new_reference(file)
target.add_resources([file_ref])
break
end
end
end
else
project.targets.each do |target|
file_ref = project.main_group.new_reference(resource)
target.add_resources([file_ref])
end
end
end
end
# add source
sources = phases_config["add_source"]
if (sources != nil)
sources.each do | source |
if (source.class == Hash)
phases_target = source["tragets"]
file = source["file"]
phases_target.each do |target_name|
project.targets.each do |target|
if (target_name == target.name)
file_ref = project.main_group.new_reference(file)
if (file.end_with?('.h') == false)
target.add_file_references([file_ref])
end
break
end
end
end
else
project.targets.each do |target|
file_ref = project.main_group.new_reference(source)
if (source.end_with?('.h') == false)
target.add_file_references([file_ref])
end
end
end
end
end
end
project.save()