This repository was archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathadd_generated_models.rb
More file actions
executable file
·48 lines (41 loc) · 1.68 KB
/
add_generated_models.rb
File metadata and controls
executable file
·48 lines (41 loc) · 1.68 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
require 'xcodeproj'
def addfiles(direc, current_group, main_target, changed = false)
puts "addfiles - `direct`=`#{direc}`, `current_group`=`#{current_group}`, `main_target`=`#{main_target}`"
current_group.clear
Dir.glob(direc) do |item|
puts "addfiles - `item`=`#{item}`"
next puts "Next because `.` or `.DS_Store`" if item == '.' or item == '.DS_Store'
if File.directory?(item)
new_folder = File.basename(item)
created_group = current_group.new_group(new_folder)
changed = addfiles("#{item}/*", created_group, main_target, changed)
else
i = current_group.new_file(item)
if item.include? ".m"
build_files = main_target.add_file_references([i])
changed = true
end
if item.include? ".h"
build_files = main_target.add_file_references([i])
build_files[0].settings = { 'ATTRIBUTES' => ['Public']}
changed = true
end
end
end
return changed
end
def add_group_to_project(project_path, name_of_generated_folder)
project = Xcodeproj::Project.open(project_path)
generated_group = project.main_group[name_of_generated_folder]
unless generated_group
generated_group = project.main_group.new_group(name_of_generated_folder)
end
main_target = project.targets.first
added_new_files = addfiles("#{name_of_generated_folder}/*", generated_group, main_target)
if added_new_files
project.save
end
end
project_path = 'MSGraphClientModels.xcodeproj'
puts "`project_path`=`#{project_path}`"
add_group_to_project(project_path, 'GeneratedModels')