fix playback offset
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { withDangerousMod, createRunOncePlugin } = require("@expo/config-plugins");
|
||||
|
||||
const PATCH_MARKER = "Applied fmt consteval workaround in fmt/base.h";
|
||||
|
||||
const PATCH_BLOCK = [
|
||||
" # Workaround for Xcode/clang consteval regression with fmt 11.0.2.",
|
||||
" # Keep this until React Native ships a newer fmt pod.",
|
||||
" fmt_base_header = File.join(installer.sandbox.root.to_s, 'fmt', 'include', 'fmt', 'base.h')",
|
||||
" if File.exist?(fmt_base_header)",
|
||||
" content = File.read(fmt_base_header)",
|
||||
" old_line = ' detail::parse_format_string<true>(str_, checker(s));'",
|
||||
" new_line = ' detail::parse_format_string<true>(str_, checker(str_));'",
|
||||
" if content.include?(old_line)",
|
||||
" File.chmod(0o644, fmt_base_header) unless File.writable?(fmt_base_header)",
|
||||
" File.write(fmt_base_header, content.sub(old_line, new_line))",
|
||||
` Pod::UI.puts('${PATCH_MARKER}')`,
|
||||
" end",
|
||||
" end",
|
||||
].join("\n");
|
||||
|
||||
function applyFmtPatchToPodfile(contents) {
|
||||
if (contents.includes(PATCH_MARKER)) {
|
||||
return contents;
|
||||
}
|
||||
|
||||
const primaryAnchor =
|
||||
" # This is necessary for Xcode 14, because it signs resource bundles by default";
|
||||
if (contents.includes(primaryAnchor)) {
|
||||
return contents.replace(primaryAnchor, `${PATCH_BLOCK}\n\n${primaryAnchor}`);
|
||||
}
|
||||
|
||||
const fallbackAnchor = " installer.target_installation_results.pod_target_installation_results";
|
||||
if (contents.includes(fallbackAnchor)) {
|
||||
return contents.replace(fallbackAnchor, `${PATCH_BLOCK}\n\n${fallbackAnchor}`);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"withFmtConstevalWorkaround: could not find insertion anchor in ios/Podfile."
|
||||
);
|
||||
}
|
||||
|
||||
const withFmtConstevalWorkaround = (config) =>
|
||||
withDangerousMod(config, [
|
||||
"ios",
|
||||
async (config) => {
|
||||
const podfilePath = path.join(config.modRequest.platformProjectRoot, "Podfile");
|
||||
if (!fs.existsSync(podfilePath)) {
|
||||
return config;
|
||||
}
|
||||
|
||||
const podfile = fs.readFileSync(podfilePath, "utf8");
|
||||
const patched = applyFmtPatchToPodfile(podfile);
|
||||
if (patched !== podfile) {
|
||||
fs.writeFileSync(podfilePath, patched);
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
|
||||
module.exports = createRunOncePlugin(
|
||||
withFmtConstevalWorkaround,
|
||||
"with-fmt-consteval-workaround",
|
||||
"1.0.0"
|
||||
);
|
||||
Reference in New Issue
Block a user