37
37
project = Xcodeproj ::Project . open ( project_path )
38
38
project_framework_group = project . frameworks_group
39
39
40
- def add_ref ( group , path , source_tree , phase )
40
+ def add_ref ( group , path , source_tree , phase_list )
41
41
ref = group . new_reference ( "#{ path } " )
42
42
ref . name = "#{ File . basename ( path ) } "
43
43
ref . source_tree = source_tree
44
- phase . add_file_reference ( ref )
44
+ phase_list . each do |phase |
45
+ phase . add_file_reference ( ref )
46
+ end
45
47
puts ref
46
48
end
47
49
@@ -53,7 +55,7 @@ def add_ref(group, path, source_tree, phase)
53
55
add_ref ( project . main_group ,
54
56
framework_path ,
55
57
source_tree ,
56
- project_target . resources_build_phase )
58
+ [ project_target . resources_build_phase ] )
57
59
end
58
60
else
59
61
framework_group = Dir . glob ( File . join ( framework_path , "*.{#{ file_ext } }" ) )
@@ -62,12 +64,13 @@ def add_ref(group, path, source_tree, phase)
62
64
next unless project_target . name == target
63
65
framework_set = project_target . frameworks_build_phase . files . to_set
64
66
puts "The following frameworks are added to #{ project_target } "
67
+ embed_frameworks_phase = project_target . new_copy_files_build_phase ( "Embed Frameworks" )
65
68
framework_group . each do |framework |
66
69
next if framework_set . size == framework_set . add ( framework ) . size
67
70
add_ref ( project_framework_group ,
68
71
framework ,
69
72
source_tree ,
70
- project_target . frameworks_build_phase )
73
+ [ project_target . frameworks_build_phase , embed_frameworks_phase ] )
71
74
end
72
75
end
73
76
end
@@ -78,7 +81,7 @@ def add_ref(group, path, source_tree, phase)
78
81
add_ref ( project_framework_group ,
79
82
framework_path ,
80
83
source_tree ,
81
- project_target . frameworks_build_phase )
84
+ [ project_target . frameworks_build_phase ] )
82
85
end
83
86
end
84
87
project . save ( )
0 commit comments