Skip to content

Commit d9b5a1a

Browse files
committed
Extract to separate method
1 parent a45ca6f commit d9b5a1a

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

ios/test_app.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,7 @@ def make_project!(xcodeproj, project_root, target_platform, options)
161161
FileUtils.cp_r(xcodeproj_src, destination)
162162
name, display_name, version, single_app = app_config(project_root)
163163
xcschemes_path = File.join(xcodeproj_dst, 'xcshareddata', 'xcschemes')
164-
165-
# Read "metalAPIValidation from the app config and apply it to the xcscheme"
166-
metal_api_validation = platform_config('metalAPIValidation', project_root, target_platform)
167-
puts "metalAPIValidation: #{metal_api_validation}"
168-
169-
if metal_api_validation
170-
xcscheme = File.join(xcschemes_path, "ReactTestApp.xcscheme")
171-
puts "xcscheme: #{xcscheme}"
172-
xcscheme_content = File.read(xcscheme)
173-
new_content = xcscheme_content.gsub(/^\s*enableGPUValidationMode\s*=\s*"1"\s*$/, '')
174-
puts "new_content: #{new_content}"
175-
File.write(xcscheme, new_content)
176-
end
177-
178-
unless name.nil?
179-
FileUtils.cp(File.join(xcschemes_path, 'ReactTestApp.xcscheme'),
180-
File.join(xcschemes_path, "#{name}.xcscheme"))
181-
end
182-
164+
configure_xcschemes!(xcschemes_path, project_root, target_platform, name)
183165

184166
# Link source files
185167
%w[ReactTestApp ReactTestAppTests ReactTestAppUITests].each do |file|

ios/xcode.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ def override_build_settings!(build_settings, overrides)
2020
build_settings[setting] = value
2121
end
2222
end
23+
24+
def configure_xcschemes!(xcschemes_path, project_root, target_platform, name)
25+
xcscheme = File.join(xcschemes_path, "ReactTestApp.xcscheme")
26+
metal_api_validation = platform_config('metalAPIValidation', project_root, target_platform)
27+
28+
# Oddly enough, to disable Metal API validation, we need to remove the `enableGPUValidationMode` key from the xcscheme file.
29+
# A default Xcode project does not have this key, so lets follow that pattern and only add it if it is enabled.
30+
if metal_api_validation.nil? || metal_api_validation == true
31+
xcscheme_content = File.read(xcscheme)
32+
new_content = xcscheme_content.gsub(/^\s*enableGPUValidationMode\s*=\s*"1"\s*$/, '')
33+
File.write(xcscheme, new_content)
34+
return
35+
end
36+
37+
# Make a copy of the ReactTestApp.xcscheme file with the app name for convenience.
38+
unless name.nil?
39+
FileUtils.cp(xcscheme, File.join(xcschemes_path, "#{name}.xcscheme"))
40+
end
41+
end

0 commit comments

Comments
 (0)