Rxswift: No such module 'RxTest' with Swift Package Manager

Created on 23 Apr 2017  Â·  6Comments  Â·  Source: ReactiveX/RxSwift

Short description of the issue:

I'd like to install RxTest framework via Swift Package Manager.

// Package.swift
import PackageDescription

let package = Package(
  name: "ReactorKit",
  dependencies: [
    .Package(url: "https://github.com/ReactiveX/RxSwift.git", majorVersion: 3),
  ]
)

Expected outcome:

// MyAppTests.swift
import RxTest // expected this line to not make a compile error

What actually happens:

// MyTest.swift
import RxTest // No such module 'RxTest'

Self contained code example that reproduces the issue:

$ swift --version
Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Target: x86_64-apple-macosx10.9
$ mkdir MyApp
$ cd MyApp
$ swift package init
# Add RxSwift dependency to Package.swift
# Add 'import RxTest' to Tests/MyAppTests/MyAppTests.swift
$ swift test
Compile Swift Module 'MyAppTests' (1 sources)
/MyApp/Tests/MyAppTests/MyAppTests.swift:2:18: error: no such module 'MyApp'
@testable import MyApp
                 ^

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

Latest (3.4.0)

Platform/Environment

  • [x] iOS
  • [x] macOS
  • [x] tvOS
  • [x] watchOS
  • [ ] playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • [x] easy, 100% repro
  • [ ] sometimes, 10%-100%
  • [ ] hard, 2% - 10%
  • [ ] extremely hard, %0 - 2%

Xcode version:

8.3.2 (8E2002)

:warning: Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. :warning:

Installation method:

  • [ ] CocoaPods
  • [ ] Carthage
  • [ ] Git submodules
  • [x] Swift Package Manager

I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)

  • [ ] yes (which ones)
  • [x] no

Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

  • [ ] just starting
  • [ ] I have a small code base
  • [x] I have a significant code base

Most helpful comment

Hi @devxoul ,

I've pushed a fix for this.

All 6 comments

Hi @devxoul ,

I've pushed a fix for this.

@kzaher, Thanks for quick fix :100:

Hi @devxoul ,

I'm retesting this and I'm having issues when I run SPM outside of unit tests.

dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest

It looks like we might need to pull this out again.

@kzaher, I used it on RxExpect and there was no problem. I just tried with another project but the result was same.

$ mkdir MyApp
$ cd MyApp
$ swift package init --type executable
$ vim Package.swift
let package = Package(
  name: "MyApp",
  dependencies: [
    // Use temporary release from my fork
    .Package(url: "https://github.com/devxoul/RxSwift.git", majorVersion: 3),
  ]
)
$ swift build
Fetching https://github.com/devxoul/RxSwift.git
Cloning https://github.com/devxoul/RxSwift.git
Resolving https://github.com/devxoul/RxSwift.git at 3.4.1
Compile Swift Module 'RxSwift' (157 sources)
Compile RxCocoaRuntime _RXObjCRuntime.m
Compile RxCocoaRuntime _RXKVOObserver.m
Compile RxCocoaRuntime _RXDelegateProxy.m
Compile RxCocoaRuntime _RX.m
Compile Swift Module 'RxTest' (13 sources)
Compile Swift Module 'RxBlocking' (8 sources)
Linking RxCocoaRuntime
Compile Swift Module 'RxCocoa' (93 sources)
Compile Swift Module 'MyApp' (1 sources)
Linking ./.build/debug/MyApp

How can I reproduce that?

Hi @devxoul ,

I've added an environmental variable TEST=1 to fix that issue.

RxTest will be included if you run TEST=1 swift test. If you don't set TEST=1 environmental variable RxTest will be excluded as a dependency.

I'm hoping SPM will provide us some built in way to distinguish this. ¯\_(ツ)_/¯
I think we are good for now :), maybe we can improve this in future. Let me know does this work for you.

@kzaher Cool! It works like a charm :)

Was this page helpful?
0 / 5 - 0 ratings