Last active
October 6, 2025 11:01
-
-
Save KimmoHernborg/9a77844b20293cf7bf0c172f81452a9b to your computer and use it in GitHub Desktop.
withCustomXcodeBuildSettings
This file contains hidden or 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
| const { IOSConfig, withXcodeProject } = require('@expo/config-plugins'); | |
| const withCustomXcodeBuildSettings = ( | |
| config, | |
| { | |
| buildNumber, | |
| codeSignIdentity, | |
| developmentTeam, | |
| keychainFile, | |
| provisioningProfile, | |
| version, | |
| } = {}, | |
| ) => { | |
| return withXcodeProject(config, (config) => { | |
| const project = config.modResults; | |
| const targets = IOSConfig.Target.findSignableTargets(project); | |
| targets.forEach(([nativeTargetId, nativeTarget]) => { | |
| IOSConfig.XcodeUtils.getBuildConfigurationsForListId( | |
| project, | |
| nativeTarget.buildConfigurationList, | |
| ).forEach((config) => { | |
| const [, item] = config; | |
| item.buildSettings.DEVELOPMENT_TEAM = developmentTeam; | |
| item.buildSettings.CODE_SIGN_IDENTITY = `"${codeSignIdentity}"`; | |
| item.buildSettings.PROVISIONING_PROFILE = `"${provisioningProfile}"`; | |
| item.buildSettings.CODE_SIGN_STYLE = 'Manual'; | |
| if (keychainFile) { | |
| item.buildSettings.OTHER_CODE_SIGN_FLAGS = `"--keychain=${keychainFile}"`; | |
| } | |
| }); | |
| Object.entries(IOSConfig.XcodeUtils.getProjectSection(project)) | |
| .filter(IOSConfig.XcodeUtils.isNotComment) | |
| .forEach(([, item]) => { | |
| if (!item.attributes.TargetAttributes[nativeTargetId]) { | |
| item.attributes.TargetAttributes[nativeTargetId] = {}; | |
| } | |
| item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = | |
| 'Manual'; | |
| item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = | |
| developmentTeam; | |
| item.attributes.TargetAttributes[nativeTargetId].CodeSignStyle = | |
| `"${codeSignIdentity}"`; | |
| }); | |
| }); | |
| if (version) { | |
| project.addBuildProperty('MARKETING_VERSION', version); | |
| } | |
| if (buildNumber) { | |
| project.addBuildProperty('CURRENT_PROJECT_VERSION', buildNumber); | |
| } | |
| return config; | |
| }); | |
| }; | |
| module.exports = withCustomXcodeBuildSettings; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Combination of code from these issues:
expo/expo#29526
expo/expo#28363 (comment)
To be able to set Marketing version and Project version and also Code signing options.