Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such module 'RxTest' with Swift Package Manager #1215

Closed
8 of 18 tasks
devxoul opened this issue Apr 23, 2017 · 8 comments
Closed
8 of 18 tasks

No such module 'RxTest' with Swift Package Manager #1215

devxoul opened this issue Apr 23, 2017 · 8 comments

Comments

@devxoul
Copy link
Contributor

devxoul commented Apr 23, 2017

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

  • iOS
  • macOS
  • tvOS
  • watchOS
  • playgrounds

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

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

Xcode version:

8.3.2 (8E2002)

⚠️ 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. ⚠️

Installation method:

  • CocoaPods
  • Carthage
  • Git submodules
  • 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)
  • 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
  • I have a significant code base
@devxoul devxoul changed the title RxTest via Swift Package Manager No such module 'RxTest' with Swift Package Manager Apr 23, 2017
kzaher added a commit that referenced this issue Apr 25, 2017
@kzaher
Copy link
Member

kzaher commented Apr 25, 2017

Hi @devxoul ,

I've pushed a fix for this.

@devxoul
Copy link
Contributor Author

devxoul commented Apr 25, 2017

@kzaher, Thanks for quick fix 💯

@devxoul devxoul closed this as completed Apr 25, 2017
@kzaher kzaher reopened this Apr 30, 2017
@kzaher
Copy link
Member

kzaher commented Apr 30, 2017

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.

@devxoul
Copy link
Contributor Author

devxoul commented May 1, 2017

@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?

@kzaher
Copy link
Member

kzaher commented May 1, 2017

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 kzaher closed this as completed May 1, 2017
@devxoul
Copy link
Contributor Author

devxoul commented May 2, 2017

@kzaher Cool! It works like a charm :)

@SamarthKejriwal
Copy link

SamarthKejriwal commented Apr 8, 2022

Hi @devxoul @kzaher
I tried adding the Environment variable to my target, still, the import issue is not fixed for me

@vanjang
Copy link

vanjang commented Dec 5, 2022

I had this issue that indicates no such module RxTest(or RxBlocking) and environmental variable is not editable so I fixed this issue by adding RxTest/RxBlocking in through project pane Targets(test) -> Build phases -> Link Binary With Libraries. I am using SPM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants