iOS發(fā)布應(yīng)用的方式:
- 通過 Xcode 上傳
- 通過 Transporter App 上傳
- 通過 altool 上傳
使用 XCode 和 Transporter App 時總是卡在 Authenticating with the app Store...
于是就嘗試使用 altool 上傳妄迁。
1. 獲取密鑰 ID 和 issuer ID 下載 API 秘鑰
步驟:點擊用戶和訪問 > 秘鑰 > 生成秘鑰
然后下載 API 密鑰,將下載的密鑰保存至 ~/.private_keys 目錄下:
/Users/user_name/.private_keys
└── AuthKey_75xxxxx96.p8
2. 更新 iTMSTransporter:
altool 上傳時用到了 iTMSTransporter,需要先更新,這一步很慢损俭,需要耐心涩禀。
其緩存目錄為:~/Library/Caches/com.apple.amp.itmstransporter/
$ /Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/itms/bin/iTMSTransporter -help
[2020-03-16 17:43:54 CST] <main> INFO: Configuring logging...
[2020-03-16 17:43:54 CST] <main> INFO: Logging level set to eXtreme
[2020-03-16 17:43:54 CST] <main> INFO: Transporter is searching for new software components.
[2020-03-16 17:43:54 CST] <main> INFO: INFO: using cached repository.xml file.
[2020-03-16 17:43:54 CST] <main> INFO: Update check complete.
[2020-03-16 17:43:55 CST] <main> DEBUG: Attempting refresh of configuration data from https://contentdelivery.itunes.apple.com/transporter/Defaults.properties
[2020-03-16 17:43:56 CST] <main> DEBUG: Configuration refresh successful.
[2020-03-16 17:43:56 CST] <main> DEBUG: Saving configuration to local path: /Users/ting/Library/Caches/com.apple.amp.itmstransporter/Defaults.properties
usage: iTMSTransporter [-help <arg> | -info | -m <arg> | -version] [-o <arg>] [-v
<arg>] [-WONoPause <arg>] [-Xmx4096m]
iTMSTransporter : iTunes Store Transporter 2.0.0
-help <arg> Show this help. If a mode value is specified, show help specific
to that mode.
-info The -info option should be used by itself and returns the
copyright notice and acknowledgements.
-m <arg> The -m option specifies the tool's mode. The valid values are:
verify, upload, provider, diagnostic, lookupMetadata,
createArtist, lookupArtist, status, statusAll,
createMetadataTicket, queryTickets, generateSchema, transferTest,
downloadMetadataGuides, listReports, requestReport
-o <arg> The -o option specifies the directory and filename you want to use
to log output information. By default, Transporter logs output
information to standard out. If you specify a filename,
Transporter logs the output to the specified file, as well as to
standard out.
-v <arg> The -v option specifies the level of logging. The five values
are: off, detailed, informational, critical, eXtreme.
-version The -version option should be used by itself and returns the
version of the tool.
-WONoPause <arg> The -WONoPause option is only valid on Windows and its value can
be 'true' or 'false'. If an error occurs during script execution,
the process idles because the message 'Press any key...' is
displayed on the console and the system awaits a keypress. To
avoid this behavior, set this property to true
-Xmx4096m Specifies that you want to change the Java Virtual Machine's (JVM)
allocated memory by increasing the JVM heap size. By default,
Transporter uses a 2048MB heap size. You can use the -Xmx4096m
option to specify a 4-gigabyte (GB) heap size. Apple recommends,
if needed, increasing the heap size to 4096MB by specifying the
-Xmx4096m (or -Xmx4g) option and adjusting as needed.
[2020-03-16 17:43:56 CST] <main> DBG-X: Returning 0
3. 驗證/上傳 ipa:
# 驗證 ipa
$ xcrun altool --validate-app -f xxx.ipa -t ios -u xxx.com --apiKey xxx --apiIssuer xxx --verbose
# 驗證成功會有輸出:
No errors validating archive at 'xxx.ipa'
# 上傳 ipa
$ xcrun altool --upload-app -f xxx.ipa -t ios -u xxx.com --apiKey xxx --apiIssuer xxx --verbose
# 此時會出錯:
Errors: (
"Error Domain=ITunesTransporterErrorDomain Code=-18000 \"The -apiIssuer option must not include the -u option.\" UserInfo={NSLocalizedRecoverySuggestion=The -apiIssuer option must not include the -u option., NSLocalizedDescription=The -apiIssuer option must not include the -u option., NSLocalizedFailureReason=The -apiIssuer option must not include the -u option.}"
)
# 提示不需要 -u username,就把 username 去掉
$ xcrun altool --upload-app -f xxx.ipa -t ios --apiKey xxx --apiIssuer xxx --verbose
altool[74124:2395796] Package Summary:
altool[74124:2395796]
altool[74124:2395796] 1 packages were uploaded successfully:
altool[74124:2395796] /var/folders/bq/c5341cyn3fs0jzsl3rgbts0m0000gn/T/8779FA07-3166-4E47-955B-6A59B48E78C5/1233538364.itmsp
altool[74124:2395796] [2020-03-26 15:17:45 CST] <main> DBG-X: Returning 0
No errors uploading 'xxx.ipa'
altool[74124:2395796] 'IosApplicationArchiveExpander', cleanupDestinationDirectory: '/var/folders/bq/c5341cyn3fs0jzsl3rgbts0m0000gn/T/xxx-1.ipa'
altool[74124:2395796] Cleaning up files....
altool[74124:2395796] Deleted temporary package at '/var/folders/bq/c5341cyn3fs0jzsl3rgbts0m0000gn/T/8779FA07-3166-4E47-955B-6A59B48E78C5/1233538364.itmsp'.
altool[74124:2395796] -[ITunesTransporter dealloc] <ITunesTransporter: 0x7fe536f1f020>
altool[74124:2395796] Deallocating <ITunesSoftwareServiceWorkSeriesFactory: 0x7fe538903270>
參考:
https://help.apple.com/app-store-connect/#/devb1c185036
https://juejin.im/post/5e460212f265da574657cadf
https://juejin.im/post/5dbbc051f265da4cf406f809