-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): support manual signing on build command #7769
base: main
Are you sure you want to change the base?
Changes from all commits
2306058
4383b67
bc63823
e96c4f1
23300df
bc80d75
8e50ecb
ab7e9b9
e40dd06
4159a23
936f033
b87cd77
400e01f
069ab09
79f401f
af2f2eb
e2347fe
e438586
5858e67
6b28c45
3f648b8
a9418ba
a209f6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ import { basename, join } from 'path'; | |
import { rimraf } from 'rimraf'; | ||
|
||
import { runTask } from '../common'; | ||
import type { Config } from '../definitions'; | ||
import { XcodeExportMethod, type Config } from '../definitions'; | ||
import { logSuccess } from '../log'; | ||
import type { BuildCommandOptions } from '../tasks/build'; | ||
import { type BuildCommandOptions } from '../tasks/build'; | ||
import { checkPackageManager } from '../util/spm'; | ||
import { runCommand } from '../util/subprocess'; | ||
|
||
|
@@ -25,59 +25,84 @@ export async function buildiOS(config: Config, buildOptions: BuildCommandOptions | |
projectName = basename(await config.ios.nativeXcodeProjDirAbs); | ||
} | ||
|
||
if ( | ||
buildOptions.xcodeSigningType == 'manual' && | ||
(!buildOptions.xcodeSigningCertificate || !buildOptions.xcodeProvisioningProfile) | ||
) { | ||
throw 'Manually signed Xcode builds require a signing certificate and provisioning profile.'; | ||
} | ||
|
||
const buildArgs = [ | ||
typeOfBuild, | ||
projectName, | ||
'-scheme', | ||
`${theScheme}`, | ||
'-destination', | ||
`generic/platform=iOS`, | ||
'-archivePath', | ||
`${theScheme}.xcarchive`, | ||
'archive', | ||
]; | ||
|
||
if (buildOptions.xcodeTeamId) { | ||
buildArgs.push(`DEVELOPMENT_TEAM=${buildOptions.xcodeTeamId}`); | ||
} | ||
|
||
if (buildOptions.xcodeSigningType == 'manual') { | ||
buildArgs.push(`PROVISIONING_PROFILE_SPECIFIER=${buildOptions.xcodeProvisioningProfile}`); | ||
} | ||
|
||
await runTask('Building xArchive', async () => | ||
runCommand( | ||
'xcodebuild', | ||
[ | ||
typeOfBuild, | ||
projectName, | ||
'-scheme', | ||
`${theScheme}`, | ||
'-destination', | ||
`generic/platform=iOS`, | ||
'-archivePath', | ||
`${theScheme}.xcarchive`, | ||
'archive', | ||
], | ||
{ | ||
cwd: config.ios.nativeProjectDirAbs, | ||
}, | ||
), | ||
runCommand('xcodebuild', buildArgs, { | ||
cwd: config.ios.nativeProjectDirAbs, | ||
}), | ||
); | ||
|
||
const manualSigningContents = `<key>provisioningProfiles</key> | ||
<dict> | ||
<key>${config.app.appId}</key> | ||
<string>${buildOptions.xcodeProvisioningProfile ?? ''}</string> | ||
</dict> | ||
<key>signingCertificate</key> | ||
<string>${buildOptions.xcodeSigningCertificate ?? ''}</string>`; | ||
Comment on lines
+63
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will these be OK as empty strings, or would it fail the build? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that block is only added if signing style is manual, and if that's chosen, presumably, the developer would be supplying a provisioning profile and/or signing certificate. If what they supply is wrong (or if it's empty), then it won't work. I believe the signing certificate can be optional, so I may push up a change to remove that key and string if the value is empty. |
||
|
||
const archivePlistContents = `<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>method</key> | ||
<string>app-store-connect</string> | ||
<string>${buildOptions.xcodeExportMethod ?? XcodeExportMethod.Debugging}</string> | ||
<key>signingStyle</key> | ||
<string>${buildOptions.xcodeSigningType}</string> | ||
${buildOptions.xcodeSigningType == 'manual' ? manualSigningContents : ''} | ||
</dict> | ||
</plist>`; | ||
|
||
const archivePlistPath = join(`${config.ios.nativeProjectDirAbs}`, 'archive.plist'); | ||
|
||
writeFileSync(archivePlistPath, archivePlistContents); | ||
|
||
const archiveArgs = [ | ||
'archive', | ||
'-archivePath', | ||
`${theScheme}.xcarchive`, | ||
'-exportArchive', | ||
'-exportOptionsPlist', | ||
'archive.plist', | ||
'-exportPath', | ||
'output', | ||
'-configuration', | ||
buildOptions.configuration, | ||
]; | ||
|
||
if (buildOptions.xcodeSigningType == 'automatic') { | ||
archiveArgs.push('-allowProvisioningUpdates'); | ||
} | ||
|
||
await runTask('Building IPA', async () => | ||
runCommand( | ||
'xcodebuild', | ||
[ | ||
'archive', | ||
'-archivePath', | ||
`${theScheme}.xcarchive`, | ||
'-exportArchive', | ||
'-exportOptionsPlist', | ||
'archive.plist', | ||
'-exportPath', | ||
'output', | ||
'-allowProvisioningUpdates', | ||
'-configuration', | ||
buildOptions.configuration, | ||
], | ||
{ | ||
cwd: config.ios.nativeProjectDirAbs, | ||
}, | ||
), | ||
runCommand('xcodebuild', archiveArgs, { | ||
cwd: config.ios.nativeProjectDirAbs, | ||
}), | ||
); | ||
|
||
await runTask('Cleaning up', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look correct, verified via xcodebuild -help, method section