React Native 迁移 - 仅在 CircleCI 上 iOS "Archive failed" 的 Fastlane 构建失败

React Native migration - Fastlane build fail for iOS "Archive failed" only on CircleCI

正在努力将移动应用程序从 React Native 0.59.0 迁移到 0.60.5 并支持 Android X。更新后的应用程序在 iOS 和 Android 上都运行良好,并且Android 的 CircleCI 构建工作正常。

在存档期间,使用 Fastlane 为 iOS 构建 CircleCI 在 CircleCI 上失败。有没有其他人看到并解决过这个问题?

当 运行 bundle exec fastlane ios build_release 在本地工作正常。

Environment (on CircleCI):
Xcode version: 10.2.1
Fastlane version: 2.130.0
Gym SDK: iphoneos12.2

+----------------------------------------------------+--------------------------------------------------------------+
|                                              Summary for gym 2.130.0                                              |
+----------------------------------------------------+--------------------------------------------------------------+
| scheme                                             | MyApp                                                        |
| export_method                                      | app-store                                                    |
| export_options.provisioningProfiles.com.myapp.app  | match AppStore com.myapp.app                                 |
| workspace                                          | ./MyApp.xcworkspace                                          |
| destination                                        | generic/platform=iOS                                         |
| output_name                                        | MyApp                                                        |
| build_path                                         | /Users/distiller/Library/Developer/Xcode/Archives/2019-09-06 |
| clean                                              | false                                                        |
| output_directory                                   | .                                                            |
| silent                                             | false                                                        |
| skip_package_ipa                                   | false                                                        |
| result_bundle                                      | false                                                        |
| buildlog_path                                      | ~/Library/Logs/gym                                           |
| skip_profile_detection                             | false                                                        |
| xcode_path                                         | /Applications/Xcode-10.2.1.app                               |
+----------------------------------------------------+--------------------------------------------------------------+

Output:
▸ Touching MyApp.app
▸ Signing /Users/distiller/Library/Developer/Xcode/DerivedData/MyApp-crgfinutbidjbqcbnlrwjwautwhq/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
▸ Touching MyApp.app.dSYM
** ARCHIVE FAILED **
[06:24:02]: Exit status: 65
[06:24:02]: 
[06:24:02]: Maybe the error shown is caused by using the wrong version of Xcode
[06:24:02]: Found multiple versions of Xcode in '/Applications/'
[06:24:02]: Make sure you selected the right version for your project
[06:24:02]: This build process was executed using '/Applications/Xcode-10.2.1.app'
[06:24:02]: If you want to update your Xcode path, either
[06:24:02]: 
[06:24:02]: - Specify the Xcode version in your Fastfile
[06:24:02]: ▸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[06:24:02]: 
[06:24:02]: - Specify an absolute path to your Xcode installation in your Fastfile
[06:24:02]: ▸ xcode_select "/Applications/Xcode8.app"
[06:24:02]: 
[06:24:02]: - Manually update the path using
[06:24:02]: ▸ sudo xcode-select -s /Applications/Xcode.app
[06:24:02]: 

+---------------+--------------------------------+
|               Build environment                |
+---------------+--------------------------------+
| xcode_path    | /Applications/Xcode-10.2.1.app |
| gym_version   | 2.130.0                        |
| export_method | app-store                      |
| sdk           | iPhoneOS12.2.sdk               |
+---------------+--------------------------------+

[06:24:02]: ▸ Touch /Users/distiller/Library/Developer/Xcode/DerivedData/MyApp-crgfinutbidjbqcbnlrwjwautwhq/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app.dSYM
[06:24:02]: ▸     cd /Users/distiller/mobile-app/ios
[06:24:02]: ▸     export PATH="/Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode-10.2.1.app/Contents/Developer/usr/bin:/Users/distiller/.gem/ruby/2.4.6/bin:/Users/distiller/.rubies/ruby-2.4.6/lib/ruby/gems/2.4.0/bin:/Users/distiller/.rubies/ruby-2.4.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
[06:24:02]: ▸     /usr/bin/touch -c /Users/distiller/Library/Developer/Xcode/DerivedData/MyApp-crgfinutbidjbqcbnlrwjwautwhq/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app.dSYM

如错误日志中所述 - 您使用了错误的 xcode 版本,因此 fastline 无法 select 正确的版本;

要定义 xcode 的版本,您应该在 fastline 配置文件中添加

xcversion(version: "10.2")

我不建议在 Fastfile 中设置 Xcode 版本,因为它会一直更改。也许你在本地和 CI 机器上有不同的 Xcode 版本。

我们曾经在 Fastfile 的顶部设置它:

xcode_select '/Applications/Xcode.app'

确保 Xcode 在名为 Xcode 的应用程序文件夹中,然后它应该可以工作...