Fastlane 测试失败 libXCTestSwiftSupport.dylib 需要 1.0.0 或更高版本,但 libswiftCore.dylib 提供 0.0.0 版本

Fastlane Tests Failing with libXCTestSwiftSupport.dylib requires version 1.0.0 or later, but libswiftCore.dylib provides version 0.0.0

如有任何帮助,我们将不胜感激。我断断续续地争取了几周的时间来获得我的单元测试 运行ning 作为我使用 Jenkins 和 Fastlane 构建管道的一部分。

当我在本地通过 Fastlane 运行 他们时,一切都很好。我 运行 fastlane unit_tests 一切都编译、模拟器启动和测试 运行.

当我在构建管道上 运行 它们时,在模拟器启动并且应该执行第一个测试后,我看到一个错误。

我不明白这里缺少什么。我原以为 fastlane 使用 scan 选项创建的开发版本足以包含 运行 测试所需的内容。车道定义为:

desc "Run Unit Tests"
lane :unit_tests do
    scan(
        scheme: "myAppTests",
        devices: ["iPhone 11"]
    )
end

我收到的错误是:

[16:20:32]: ▸ Linking myAppTests
[16:20:33]: ▸ Copying provisioning.plist
[16:20:33]: ▸ Copying GoogleService-Info.plist
[16:20:33]: ▸ Compiling SynchronizationViewController.xib
[16:20:33]: ▸ Processing Info.plist
[16:20:33]: ▸ Running script '[CP] Embed Pods Frameworks'
[16:20:33]: Running Tests: ▸ Touching myAppTests.xctest (in target 'myAppTests' from project 'myApp')
[16:20:33]: ▸ Build Succeeded
[16:20:34]: ▸ Linking MYAPP
[16:20:34]: ▸ Running script 'SwiftLint'
[16:20:35]: ▸ Linking myAppTests
[16:20:35]: ▸ 2020-02-20 16:20:35.801 xcodebuild[42315:2308394]  IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
[16:20:35]: ▸ /Users/Jenkins.SVN/Library/Developer/Xcode/DerivedData/MYAPP-gjylxkutiwwowsdxuadsovduecib/Logs/Test/Run-myAppTests-2020.02.20_16-19-59-+0000.xcresult/Staging/2_Test/Diagnostics/myAppTests-35F843CE-22FC-427A-B385-A9EF0F61E4B1/myAppTests-D3C6D752-F909-4965-BAB5-26194C7BB5D0/Session-myAppTests-2020-02-20_162035-s3sDH8.log
[16:20:35]: ▸ 2020-02-20 16:20:35.801 xcodebuild[42315:2306273] [MT] IDETestOperationsObserverDebug: (5D31D2AA-6061-40B3-943F-858AE0181E65) Beginning test session myAppTests-5D31D2AA-6061-40B3-943F-858AE0181E65 at 2020-02-20 16:20:35.801 with Xcode 11C505 on target <DVTiPhoneSimulator: 0x7fa3f1a8e220> {
[16:20:35]: ▸       SimDevice: iPhone 11 (703948B3-684D-4E84-AFD4-34FFB522203D, iOS 13.3, Shutdown)
[16:20:35]: ▸ } (13.3 (17C45))
[16:20:37]: ▸ 2020-02-20 16:20:37.747 xcodebuild[42315:2306273] [MT] IDETestOperationsObserverDebug: (5D31D2AA-6061-40B3-943F-858AE0181E65) Finished requesting crash reports. Continuing with testing.
[16:20:40]: ▸ 2020-02-20 16:20:40.907 xcodebuild[42315:2306273] [MT] IDETestOperationsObserverDebug: 5.110 elapsed -- Testing started completed.
[16:20:40]: ▸ 2020-02-20 16:20:40.907 xcodebuild[42315:2306273] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
[16:20:40]: ▸ 2020-02-20 16:20:40.907 xcodebuild[42315:2306273] [MT] IDETestOperationsObserverDebug: 5.110 sec, +5.110 sec -- end
[16:20:41]: ▸ Testing failed:
[16:20:41]: ▸   myAppTests:
[16:20:41]: ▸       xctest (43228) encountered an error (Failed to load the test bundle. (Underlying error: The bundle “myAppTests” couldn’t be loaded because it is damaged or missing necessary resources. The bundle is damaged or missing necessary resources. dlopen_preflight(/Users/Jenkins.SVN/Library/Developer/Xcode/DerivedData/MYAPP-gjylxkutiwwowsdxuadsovduecib/Build/Products/Debug-iphonesimulator/myAppTests.xctest/myAppTests): Library not loaded: @rpath/libswiftCore.dylib
[16:20:41]: ▸   Referenced from: /Applications/Xcode-11.3.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib
[16:20:41]: ▸   Reason: Incompatible library version: libXCTestSwiftSupport.dylib requires version 1.0.0 or later, but libswiftCore.dylib provides version 0.0.0))
[16:20:41]: ▸ ** TEST FAILED **

播客文件:

# define a global platform for your project
platform :ios, '13.2'

# ignore all warnings from all pods
inhibit_all_warnings!

def default_pods
  pod 'MyAwesomePod'
end

target 'myApp' do
  use_frameworks!
  default_pods
end

target 'myAppTests' do
  inherit! :search_paths
  use_frameworks!
  default_pods
end

target 'myAppUITests' do
  inherit! :search_paths
  use_frameworks!
  default_pods
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'
      config.build_settings['SWIFT_EXEC'] = '$(SRCROOT)/SWIFT_EXEC-no-coverage'
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
      config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
      config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
    end
  end
end

Always Embed Swift Standard Libraries 已在测试目标和应用程序目标中设置为 YES

这似乎是由于使用了错误版本的 swift 工具链造成的。除了通过 Xcode 安装的最新工具链,我们还安装了 4.2.4 和 5.1.2。我相信该应用程序是使用 5.1.2 发布的,它满足了构建目标。

我通过删除未使用的 swift 工具链解决了这个问题。我还可以指定在 fastlane 的 scangym 命令中使用的工具链。