@@ -3,9 +3,9 @@ import { basename, join } from 'path';
33import { rimraf } from 'rimraf' ;
44
55import { runTask } from '../common' ;
6- import type { Config } from '../definitions' ;
6+ import { XcodeExportMethod , type Config } from '../definitions' ;
77import { logSuccess } from '../log' ;
8- import type { BuildCommandOptions } from '../tasks/build' ;
8+ import { type BuildCommandOptions } from '../tasks/build' ;
99import { checkPackageManager } from '../util/spm' ;
1010import { runCommand } from '../util/subprocess' ;
1111
@@ -25,59 +25,84 @@ export async function buildiOS(config: Config, buildOptions: BuildCommandOptions
2525 projectName = basename ( await config . ios . nativeXcodeProjDirAbs ) ;
2626 }
2727
28+ if (
29+ buildOptions . xcodeSigningType == 'manual' &&
30+ ( ! buildOptions . xcodeSigningCertificate || ! buildOptions . xcodeProvisioningProfile )
31+ ) {
32+ throw 'Manually signed Xcode builds require a signing certificate and provisioning profile.' ;
33+ }
34+
35+ const buildArgs = [
36+ typeOfBuild ,
37+ projectName ,
38+ '-scheme' ,
39+ `${ theScheme } ` ,
40+ '-destination' ,
41+ `generic/platform=iOS` ,
42+ '-archivePath' ,
43+ `${ theScheme } .xcarchive` ,
44+ 'archive' ,
45+ ] ;
46+
47+ if ( buildOptions . xcodeTeamId ) {
48+ buildArgs . push ( `DEVELOPMENT_TEAM=${ buildOptions . xcodeTeamId } ` ) ;
49+ }
50+
51+ if ( buildOptions . xcodeSigningType == 'manual' ) {
52+ buildArgs . push ( `PROVISIONING_PROFILE_SPECIFIER=${ buildOptions . xcodeProvisioningProfile } ` ) ;
53+ }
54+
2855 await runTask ( 'Building xArchive' , async ( ) =>
29- runCommand (
30- 'xcodebuild' ,
31- [
32- typeOfBuild ,
33- projectName ,
34- '-scheme' ,
35- `${ theScheme } ` ,
36- '-destination' ,
37- `generic/platform=iOS` ,
38- '-archivePath' ,
39- `${ theScheme } .xcarchive` ,
40- 'archive' ,
41- ] ,
42- {
43- cwd : config . ios . nativeProjectDirAbs ,
44- } ,
45- ) ,
56+ runCommand ( 'xcodebuild' , buildArgs , {
57+ cwd : config . ios . nativeProjectDirAbs ,
58+ } ) ,
4659 ) ;
4760
61+ const manualSigningContents = `<key>provisioningProfiles</key>
62+ <dict>
63+ <key>${ config . app . appId } </key>
64+ <string>${ buildOptions . xcodeProvisioningProfile ?? '' } </string>
65+ </dict>
66+ <key>signingCertificate</key>
67+ <string>${ buildOptions . xcodeSigningCertificate ?? '' } </string>` ;
68+
4869 const archivePlistContents = `<?xml version="1.0" encoding="UTF-8"?>
4970<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
5071<plist version="1.0">
5172<dict>
5273<key>method</key>
53- <string>app-store-connect</string>
74+ <string>${ buildOptions . xcodeExportMethod ?? XcodeExportMethod . AppStoreConnect } </string>
75+ <key>signingStyle</key>
76+ <string>${ buildOptions . xcodeSigningType } </string>
77+ ${ buildOptions . xcodeSigningType == 'manual' ? manualSigningContents : '' }
5478</dict>
5579</plist>` ;
5680
5781 const archivePlistPath = join ( `${ config . ios . nativeProjectDirAbs } ` , 'archive.plist' ) ;
5882
5983 writeFileSync ( archivePlistPath , archivePlistContents ) ;
6084
85+ const archiveArgs = [
86+ 'archive' ,
87+ '-archivePath' ,
88+ `${ theScheme } .xcarchive` ,
89+ '-exportArchive' ,
90+ '-exportOptionsPlist' ,
91+ 'archive.plist' ,
92+ '-exportPath' ,
93+ 'output' ,
94+ '-configuration' ,
95+ buildOptions . configuration ,
96+ ] ;
97+
98+ if ( buildOptions . xcodeSigningType == 'automatic' ) {
99+ archiveArgs . push ( '-allowProvisioningUpdates' ) ;
100+ }
101+
61102 await runTask ( 'Building IPA' , async ( ) =>
62- runCommand (
63- 'xcodebuild' ,
64- [
65- 'archive' ,
66- '-archivePath' ,
67- `${ theScheme } .xcarchive` ,
68- '-exportArchive' ,
69- '-exportOptionsPlist' ,
70- 'archive.plist' ,
71- '-exportPath' ,
72- 'output' ,
73- '-allowProvisioningUpdates' ,
74- '-configuration' ,
75- buildOptions . configuration ,
76- ] ,
77- {
78- cwd : config . ios . nativeProjectDirAbs ,
79- } ,
80- ) ,
103+ runCommand ( 'xcodebuild' , archiveArgs , {
104+ cwd : config . ios . nativeProjectDirAbs ,
105+ } ) ,
81106 ) ;
82107
83108 await runTask ( 'Cleaning up' , async ( ) => {
0 commit comments