RxSwift: RxTest referencing to invalid libswiftXCTest.dylib

Hello everyone, I was wondering if someone here had my same issue.

I have an iOS project in which there are multiple modules. each module has its own test bundle. Tests run perfectly until I install via cocoa pods RxTest.

After install, test bundles crash with the following message in console:

2019-09-25 17:46:29.756701+0100 xctest[70947:11876875] The bundle “MyModuleTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2019-09-25 17:46:29.756838+0100 xctest[70947:11876875] (dlopen_preflight(/Users/…/Library/Developer/Xcode/DerivedData/…/Products/Debug-Dev-iphonesimulator/MyModuleTests.xctest/MyModuleTests): Library not loaded: /usr/lib/swift/libswiftXCTest.dylib Referenced from: /Users/…/Library/Developer/Xcode/DerivedData/…/Build/Products/Debug-Dev-iphonesimulator/MyModuleTests.xctest/MyModuleTests/RxTest.framework/RxTest Reason: no suitable image found. Did find: /usr/lib/swift/libswiftXCTest.dylib: mach-o, but not built for iOS simulator) Program ended with exit code: 9

I checked already the usual suspects: The run path searchPath is $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'as it should be.

I tried for quite a lot of time to get this to work playing with build configurations, but all without any success. If I remove RxTest, everything goes back to normal and tests start running again.

Suggestions?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 12
  • Comments: 34 (19 by maintainers)

Most upvoted comments

I noticed the same issue. But it seems that I can run the tests from XCode 11 on the iOS 13 simulator. But when I try to run them on a simulator with an older iOS version (in my case iOS 11.4) I see that exact same errors as you do

I solved the same issue in my project by switching everything to Swift 5 and adding a line of code in the podspec that requires XCTest.

Before:

  s.frameworks = 'XCTest', 'XCTAutomationSupport'
  
  s.xcconfig = {
    'LD_RUNPATH_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" "$(PLATFORM_DIR)/Developer/Library/PrivateFrameworks"',
    'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" "$(PLATFORM_DIR)/Developer/Library/PrivateFrameworks"'
  }

After:

  s.frameworks = 'XCTest', 'XCTAutomationSupport'
  
  s.xcconfig = {
    'LIBRARY_SEARCH_PATHS' => '$(TOOLCHAIN_DIR)/usr/lib/swift-$(SWIFT_VERSION)/$(PLATFORM_NAME) $(inherited)',
    'LD_RUNPATH_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" "$(PLATFORM_DIR)/Developer/Library/PrivateFrameworks"',
    'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" "$(PLATFORM_DIR)/Developer/Library/PrivateFrameworks"'
  }

I hope this can help.

@schroepf Same for me. Tests run on iOS 13 simulator, but fail on everything older than that.

I am using XCode 12.4

I tried everything above, but when I changed from app to test target, the problem finish.

Screen Shot 2021-04-11 at 02 57 25

I finally found a solution for this issue. Turns out that it’s an Apple bug. Anybody thats looking for a fix should reference this gist: https://gist.github.com/liamnichols/3507faf70ecca201cb4300645caa9b74

Just swap out your simulator version and you should be good to go.

@muehlemann I just removed the xcconfig files and add the custom configurations as user defined build configs directly to the project (which is equivalent if you have just one project).