This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: XCode 14.3 temp issues with config plugin (#2005)
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); |