|
| 1 | +require 'rexml/document' |
| 2 | +require 'rexml/xpath' |
| 3 | + |
1 | 4 | IPHONEOS_DEPLOYMENT_TARGET = 'IPHONEOS_DEPLOYMENT_TARGET'.freeze |
2 | 5 | MACOSX_DEPLOYMENT_TARGET = 'MACOSX_DEPLOYMENT_TARGET'.freeze |
3 | 6 | XROS_DEPLOYMENT_TARGET = 'XROS_DEPLOYMENT_TARGET'.freeze |
@@ -25,13 +28,16 @@ def configure_xcschemes!(xcschemes_path, project_root, target_platform, name) |
25 | 28 | xcscheme = File.join(xcschemes_path, "ReactTestApp.xcscheme") |
26 | 29 | metal_api_validation = platform_config('metalAPIValidation', project_root, target_platform) |
27 | 30 |
|
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 | + |
| 32 | + # Oddly enough, to disable Metal API validation, we need to add `enableGPUValidationMode = "1"` to the xcscheme Launch Action. |
| 33 | + if metal_api_validation == false |
31 | 34 | 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 | + doc = REXML::Document.new(xcscheme_content) |
| 36 | + doc.root.elements['LaunchAction'].attributes['enableGPUValidationMode'] = '1' |
| 37 | + |
| 38 | + File.open(xcscheme, 'w') do |file| |
| 39 | + doc.write(file) |
| 40 | + end |
35 | 41 | end |
36 | 42 |
|
37 | 43 | # Make a copy of the ReactTestApp.xcscheme file with the app name for convenience. |
|
0 commit comments