Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

fix: XCode 14.3 temp issues with config plugin #2005

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/expo/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default {
"./plugins/react-native-cronet.js",
"./plugins/with-spotify-sdk.js",
"./plugins/with-android-splash-screen.js",
"./plugins/fix-deployment-target.js",
[
withInfoPlist,
(config) => {
Expand Down
42 changes: 42 additions & 0 deletions apps/expo/plugins/fix-deployment-target.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Credit: https://github.com/facebook/react-native/issues/34106#issuecomment-1493040686
// This plugin is used to fix the deployment target issue in iOS
const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const {
mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const { readFileSync, writeFileSync } = require("fs");
const { resolve } = require("path");

const withFixedDeploymentTarget = (c) => {
return withDangerousMod(c, [
"ios",
async (config) => {
const file = resolve(config.modRequest.platformProjectRoot, "Podfile");
const contents = readFileSync(file, { encoding: "utf-8" });
writeFileSync(file, fixDeploymentTarget(contents));
return config;
},
]);
};

function fixDeploymentTarget(src) {
return mergeContents({
tag: `rn-fix-deployment-target`,
src,
newSrc: `
installer.pods_project.targets.each do |target|
if target.to_s === 'React-Codegen'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
`,
anchor: /post_install/,
offset: 1,
comment: "#",
}).contents;
}

module.exports = (config) => withPlugins(config, [withFixedDeploymentTarget]);