Skip to content

Commit 4f1d902

Browse files
committed
feat: update xcode permission by command
1 parent fa54eb3 commit 4f1d902

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

Tools/ios_extension_setup.rb

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,20 @@
3535
# Platform: ios
3636
extension_target = project.new_target(:app_extension, extension_target_name, :ios)
3737
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
4152
end
4253

4354
# 3. Add Source Files
@@ -113,10 +124,10 @@
113124
if provisioning_profile_specifier && !provisioning_profile_specifier.empty?
114125
config.build_settings['CODE_SIGN_STYLE'] = 'Manual'
115126
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}"
117128
else
118129
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}"
120131
end
121132

122133
elsif main_dev_team && !main_dev_team.empty?
@@ -125,6 +136,11 @@
125136
else
126137
config.build_settings['CODE_SIGN_STYLE'] = 'Automatic'
127138
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'
128144
end
129145

130146
# 5. Add Frameworks
@@ -138,8 +154,6 @@
138154

139155
if File.exist?(framework_fullpath)
140156
# 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
143157

144158
# Calculate relative path to framework
145159
# Project: [Root]/Intermediate/ProjectFiles/[Project].xcodeproj
@@ -152,15 +166,14 @@
152166

153167
puts "Framework Relative Path: #{framework_relative_path}"
154168

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")
157172

158173
# 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 }
160175
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)
164177
end
165178

166179
# 2. Add to Frameworks Build Phase
@@ -176,7 +189,7 @@
176189
paths = [] if paths.nil?
177190

178191
# 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
180193
search_path = "$(PROJECT_DIR)/../../IOSFramework"
181194

182195
unless paths.include?(search_path)

0 commit comments

Comments
 (0)