xcode 如何从命令行执行 iOS 应用验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7568420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:02:35  来源:igfitidea点击:

How To Perform iOS App Validation From the Command Line

iphoneiosxcode

提问by dtuckernet

Is it possible to perform the local Validation for iOS applications (which can be see in the Organizer under Archives) function via the command line?

是否可以通过命令行执行 iOS 应用程序的本地验证(可以在管理器中的档案下看到)功能?

UPDATE: Just to clarify - the goal here is to eventually make this validation a part of the continuous integration process for my iOS applications.

更新:澄清一下 - 这里的目标是最终使此验证成为我的 iOS 应用程序持续集成过程的一部分。

采纳答案by Mike Weller

In the past I've used this command:

过去我使用过这个命令:

xcrun -sdk iphoneos Validation /path/to/MyApp.app or /path/to/MyApp.ipa

This will check the codesigning, icon dimensions etc. I'm not sure if the Xcode Organizer or Application Loader app do any other validation in addition to this tool, and the tool itself has zero help or command line flags that I can find.

这将检查协同设计、图标尺寸等。我不确定 Xcode Organizer 或 Application Loader 应用程序是否除此工具外还执行任何其他验证,并且我可以找到该工具本身的零帮助或命令行标志。

UPDATE:

更新

This question has prompted me to dig a bit deeper. Running the stringstool reveals the following switches:

这个问题促使我深入挖掘。运行该strings工具会显示以下开关:

-verbose
-upload
-warnings
-errors
-online

The -onlineoption apparently will validate the binary for the first available app in iTunes connect, but I have not figured out how to pass a username/password to the command. However I'm guessing for continuous integration you probably only want the local validation.

-online选项显然将验证 iTunes 连接中第一个可用应用程序的二进制文件,但我还没有弄清楚如何将用户名/密码传递给命令。但是,我猜测对于持续集成,您可能只需要本地验证。

回答by Andrew

You can validate from the command line using the command:

您可以使用以下命令从命令行进行验证:

xcrun -sdk iphoneos Validation /path/to/App.{app or ipa}

It's a bit unclear what checks it performs, but presumably it does as least code-signing and icon dimensions.

有点不清楚它执行什么检查,但据推测它至少是代码签名和图标尺寸。

In addition to local validation, it's possible to perform online validation (but only for IPA packages):

除了本地验证之外,还可以执行在线验证(但仅适用于 IPA 包):

xcrun -sdk iphoneos Validation -verbose -online /path/to/App.ipa

For this to work you need to have your iTunes Connectcredentials stored in a special entry on your keychain. To create this entry:

为此,您需要将iTunes Connect凭据存储在钥匙串上的特殊条目中。要创建此条目:

  1. Open the Keychain Accessapplication;
  2. Create a new password item (File> New Password item…)
  3. Keychain Item Name: Xcode:itunesconnect.apple.com
  4. Account Name/Password: Your credentials for iTunes Connect
  1. 打开钥匙串访问应用程序;
  2. 创建一个新密码项(文件>新密码项...
  3. 钥匙扣项目名称: Xcode:itunesconnect.apple.com
  4. 帐户名/密码:您的 iTunes Connect 凭据

Online validation seems to be fairly rough, but does all the checks that would otherwise be performed validating an archive from with the Organiser window in Xcode. Sadly it doesn't seem to set a non-zero exit code on failure, which means output scraping to detect errors. My current heuristic for detecting failure is the presence of any output after the Performing online validation...line.

在线验证似乎相当粗糙,但会执行所有检查,否则会使用 Xcode 中的管理器窗口验证存档。遗憾的是,它似乎没有在失败时设置非零退出代码,这意味着输出抓取以检测错误。我目前用于检测故障的启发式方法是在该Performing online validation...行之后是否存在任何输出。

Given the lack of documentation it's almost certainly not supported.

鉴于缺乏文档,它几乎肯定不受支持。

回答by Krzysztof Romanowski

If you want only to validate the signed ipa file, there is tool to do it altool

如果您只想验证已签名的 ipa 文件,则可以使用工具altool

$ /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool -h
Copyright (c) 2009-2015, Apple Inc.  Version 1.1

Usage: altool --validate-app -f file -t platform -u username [-p password]
       altool --upload-app -f file -t platform -u username -p password

 -f, --file                         Filename.
 -t, --type                         Type/Platform: osx, ios.
 -u, --username                     Username. Required to connect for validation and upload.
 -p, --password                     Password. Required if username specified.  Password is read from stdin if one is not supplied.
                                    May use @keychain: or @env: prefixes followed by the keychain or environment variable lookup name.
                                    e.g. -p @env:SECRET which would use the value in the SECRET environment variable.

 -v, --validate-app                 Validate an app archive. The username, password, and file path to app archive are required.
     --upload-app                   Uploads the given app archive.  The username, password, and file path to app archive are required.
     --output-format [xml | normal] 'xml' displays error output in a structured format; 'normal' outputs in an unstructured format (default)

 -h, --help                         Display this output.

For ex.

例如。

 /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool -v -f APP.ipa -u [email protected] -p password

回答by Venkat

You can validate app with the help of altool command as shown bellow:

您可以在 altool 命令的帮助下验证应用程序,如下所示:

./altool --validate-app -f <'ipaFile'>

./altool --validate-app -f <'ipaFile'>