-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_file.rb
More file actions
40 lines (27 loc) · 975 Bytes
/
Copy pathadd_file.rb
File metadata and controls
40 lines (27 loc) · 975 Bytes
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
require 'xcodeproj'
#打开项目工程A.xcodeproj
project_path = ARGV[0]
jsonPath = ARGV[1]
modelPath = ARGV[2]
yamlPath = ARGV[3]
project = Xcodeproj::Project.open(project_path)
# 1、显示所有的target
project.targets.each do |target|
puts target.name
end
target = project.targets.first
##找到要插入的group (参数中true表示如果找不到group,就创建一个group)
rainGroup = project.main_group.find_subpath(File.join("Rain"),false)
if !rainGroup.nil? then
rainGroup.clear()
rainGroup.remove_from_project
end
newRainGroup = project.main_group.find_subpath(File.join('Rain'), true)
newRainGroup.set_source_tree('SOURCE_ROOT')
#向group中增加文件引用
#'/Users/rainedAllNight/Desktop/RainTest/Rain'
file_ref1 = newRainGroup.new_reference(jsonPath)
file_ref2 = newRainGroup.new_reference(modelPath)
file_ref3 = newRainGroup.new_reference(yamlPath)
ret = target.add_file_references([file_ref1, file_ref2, file_ref3])
project.save