|
35 | 35 | # Platform: ios |
36 | 36 | extension_target = project.new_target(:app_extension, extension_target_name, :ios) |
37 | 37 | puts "Created new target: #{extension_target_name}" |
38 | | - |
39 | | - # Force creation of build configurations (Debug/Release/etc to match project) |
40 | | - # new_target usually creates default configs. |
| 38 | +end |
| 39 | + |
| 40 | +# 2.1 Sync Build Configurations |
| 41 | +# Ensure extension target has the same configurations as the project (e.g. Development, Shipping, Test) |
| 42 | +project.build_configurations.each do |proj_config| |
| 43 | + unless extension_target.build_configurations.any? { |c| c.name == proj_config.name } |
| 44 | + # Clone 'Release' or first available config |
| 45 | + base_config = extension_target.build_configurations.find { |c| c.name == 'Release' } || extension_target.build_configurations.first |
| 46 | + if base_config |
| 47 | + new_config = extension_target.add_build_configuration(proj_config.name, base_config.type) |
| 48 | + new_config.build_settings = base_config.build_settings.clone |
| 49 | + puts "Created configuration '#{proj_config.name}' for extension target." |
| 50 | + end |
| 51 | + end |
41 | 52 | end |
42 | 53 |
|
43 | 54 | # 3. Add Source Files |
|
113 | 124 | if provisioning_profile_specifier && !provisioning_profile_specifier.empty? |
114 | 125 | config.build_settings['CODE_SIGN_STYLE'] = 'Manual' |
115 | 126 | config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = provisioning_profile_specifier |
116 | | - puts "Manual Signing Configured: Team #{team_id}, Profile #{provisioning_profile_specifier}" |
| 127 | + puts "[#{config.name}] Manual Signing Configured: Team #{team_id}, Profile #{provisioning_profile_specifier}" |
117 | 128 | else |
118 | 129 | config.build_settings['CODE_SIGN_STYLE'] = 'Automatic' |
119 | | - puts "Automatic Signing Configured: Team #{team_id}" |
| 130 | + puts "[#{config.name}] Automatic Signing Configured: Team #{team_id}" |
120 | 131 | end |
121 | 132 |
|
122 | 133 | elsif main_dev_team && !main_dev_team.empty? |
|
125 | 136 | else |
126 | 137 | config.build_settings['CODE_SIGN_STYLE'] = 'Automatic' |
127 | 138 | end |
| 139 | + |
| 140 | + # Extra Settings |
| 141 | + config.build_settings['INFOPLIST_PREPROCESS'] = 'YES' |
| 142 | + config.build_settings['GENERATE_INFOPLIST_FILE'] = 'NO' |
| 143 | + config.build_settings['ALWAYS_SEARCH_USER_PATHS'] = 'NO' |
128 | 144 | end |
129 | 145 |
|
130 | 146 | # 5. Add Frameworks |
|
138 | 154 |
|
139 | 155 | if File.exist?(framework_fullpath) |
140 | 156 | # 1. Add File Reference to Project |
141 | | - # We want to add it to a group, maybe "IOSFramework" group or "Frameworks" group? |
142 | | - # Let's create/find IOSFramework group in project root |
143 | 157 |
|
144 | 158 | # Calculate relative path to framework |
145 | 159 | # Project: [Root]/Intermediate/ProjectFiles/[Project].xcodeproj |
|
152 | 166 |
|
153 | 167 | puts "Framework Relative Path: #{framework_relative_path}" |
154 | 168 |
|
155 | | - # Find or Create Group "IOSFramework" |
156 | | - framework_group = project.main_group.find_subpath("IOSFramework") || project.main_group.new_group("IOSFramework", "../../IOSFramework") |
| 169 | + # Find or Create Group "Frameworks" (Standard location) |
| 170 | + # Do NOT create IOSFramework group in root to avoid clutter |
| 171 | + framework_group = project.main_group.find_subpath("Frameworks") || project.main_group.new_group("Frameworks") |
157 | 172 |
|
158 | 173 | # Check if ref exists |
159 | | - framework_ref = framework_group.files.find { |f| f.path == framework_name } |
| 174 | + framework_ref = framework_group.files.find { |f| f.path == framework_relative_path } |
160 | 175 | unless framework_ref |
161 | | - # add_reference expects path relative to group if group has path, or absolute? |
162 | | - # If group path is "../../IOSFramework", then adding "AgoraReplayKitExtension.framework" works if it's inside. |
163 | | - framework_ref = framework_group.new_reference(framework_name) |
| 176 | + framework_ref = framework_group.new_reference(framework_relative_path) |
164 | 177 | end |
165 | 178 |
|
166 | 179 | # 2. Add to Frameworks Build Phase |
|
176 | 189 | paths = [] if paths.nil? |
177 | 190 |
|
178 | 191 | # Add path relative to project |
179 | | - # If the group logic above used "../../IOSFramework", let's use that. |
| 192 | + # Using ../../IOSFramework because file is located there |
180 | 193 | search_path = "$(PROJECT_DIR)/../../IOSFramework" |
181 | 194 |
|
182 | 195 | unless paths.include?(search_path) |
|
0 commit comments