iOS发布应用的方式:
- 通过 Xcode 上传
- 通过 Transporter App 上传
- 通过 altool 上传
使用 XCode 和 Transporter App 时总是卡在 Authenticating with the app Store...
于是就尝试使用 altool 上传。
1. 获取密钥 ID 和 issuer ID 下载 API 秘钥
步骤:点击用户和访问 > 秘钥 > 生成秘钥
UsersAndAccess
然后下载 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
网友评论