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

Commit

Permalink
fix: XCode 14.3 temp issues with config plugin (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
hirbod authored Apr 3, 2023
1 parent 446c098 commit 7482e59
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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]);

0 comments on commit 7482e59

Please sign in to comment.