使用libXCTestSwiftSupport.dylib进行的快速测试失败,需要版本1.0.0或更高版本,但libswiftCore.dylib提供的版本为0.0.0

问题描述 投票:0回答:1

任何帮助将不胜感激。我一直在努力奋战几周,以使我的单元测试作为与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 **

Podfile:

# 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

Always Embed Swift Standard Libraries = YES

ios swift xcode jenkins fastlane
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.