fix: Cleanup config plugin JS

This commit is contained in:
Marc Rousavy 2022-01-11 12:36:38 +01:00
parent 17a3430c98
commit ca41133dc0

View File

@ -10,23 +10,18 @@ export const withDisableFrameProcessorsIOS: ConfigPlugin = (c) => {
const xcodeProject: XcodeProject = config.modResults; const xcodeProject: XcodeProject = config.modResults;
const configurations = xcodeProject.pbxXCBuildConfigurationSection(); const configurations = xcodeProject.pbxXCBuildConfigurationSection();
let key;
let buildSettings;
const inheritKey = '"$(inherited)"'; const inheritKey = '"$(inherited)"';
const valueKey = '"VISION_CAMERA_DISABLE_FRAME_PROCESSORS=1"'; const valueKey = '"VISION_CAMERA_DISABLE_FRAME_PROCESSORS=1"';
for (key in configurations) { for (const key in configurations) {
buildSettings = configurations[key].buildSettings; const buildSettings = configurations[key].buildSettings;
if (typeof buildSettings?.GCC_PREPROCESSOR_DEFINITIONS !== 'undefined') { if (buildSettings == null) continue;
// alright, this is the DEBUG config, push our setting to it
if (buildSettings.GCC_PREPROCESSOR_DEFINITIONS.includes(valueKey) === false) const preprocessorDefinitions = (buildSettings.GCC_PREPROCESSOR_DEFINITIONS ?? [inheritKey]) as string[];
buildSettings.GCC_PREPROCESSOR_DEFINITIONS.push(valueKey);
} else if (typeof buildSettings !== 'undefined') { if (!preprocessorDefinitions.includes(valueKey)) preprocessorDefinitions.push(valueKey);
// new projects do not have GCC_PREPROCESSOR_DEFINITIONS for "Release", lets create it buildSettings.GCC_PREPROCESSOR_DEFINITIONS = preprocessorDefinitions;
// we need to add the inheritKey or it will break the release build.
buildSettings.GCC_PREPROCESSOR_DEFINITIONS = [inheritKey, valueKey];
}
} }
return config; return config;
}); });