Rxswift: Swift package manager support

Created on 25 Aug 2016  路  11Comments  路  Source: ReactiveX/RxSwift

_Short description_:

Swift package manager does not recognise the 3.0 tag currently in use. The tag should be 3.0.0-alpha.1 according to SemVer or preferably 3.0.0-alpha.1@swift-3 according to the Package Manager docs.

_Self contained code example that reproduces the issue_:

import PackageDescription

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

_Xcode version_:

Tried in DEVELOPMENT-SNAPSHOT-2016-07-25-a and in Xcode Beta 6 toolchains.

_Expected outcome_:

The package should install the 3.0 alpha of RxSwift.

_What actually happens_:

error: The dependency graph could not be satisfied. The package 
(https://github.com/ReactiveX/RxSwift.git) with version tag in range 
(3.0.0..<3.0.9223372036854775807) is not found. Found tags ([0.7.1, 1.2.1, 
1.3.1, 1.8.1, 1.9.1, 2.0.0-alpha.2, 2.0.0-alpha.3, 2.0.0-alpha.4, 2.0.0-beta.1, 
2.0.0-beta.2, 2.0.0-beta.3, 2.0.0-beta.4, 2.0.0-rc.0, 2.0.0, 2.1.0, 2.2.0, 
2.3.0, 2.3.1, 2.5.0, 2.6.0])

_Installation method_:

  • Swift package manager

_I have multiple versions of Xcode installed_:

  • yes (Beta 8, 7.3.1; swift versions managed with swiftenv)

_Level of RxSwift knowledge_:

  • just starting
help wanted

Most helpful comment

woop woop!

Test Suite 'All tests' passed at 2016-09-16 18:22:04.413.
     Executed 723 tests, with 0 failures (0 unexpected) in 19.739 (19.756) seconds

alright, we're halfway there. this has involved some serious renaming, though - things learned so far:

  • SPM does not recognise Test files not in the top level of a suite's directory
  • SPM does recognise linked files in a test suite's directory, but not linked folders

I'll file a pull request on Monday. For now, pub and footy call.

All 11 comments

Hi @gormster ,

Thnx for reporting this.

I've tried to fix SPM, but it's not that trivial. Even if I were to push that tag, it looks like SPM integration would be still broken :(

I'm also unsure what effects would adding @swift-3 cause for other package managers.

If somebody fixes SPM and Linux integration that would be great.
We'll try to publish the next alpha using 3.0.0-alpha.2. I'm not sure is there are any benefits in pushing 3.0.0-alpha.1 right now since it doesn't work anyway.

- is recommended according to Semantic Versioning. SPM uses Semantic Versioning: Version.swift

Oh. I'm fine with '-' :) It would be great if somebody would help us solve other SPM issues that rise after - is added :)

I've noticed a lot of issues with package file :( I guess I'll try to find some time to fix all of this non - issues, but if anyone has some time to spare, it would be great.

I wonder if this should be related to https://github.com/ReactiveX/RxSwift/issues/878

I've got the package building on Mac with SPM, but haven't got tests or Linux working yet. The fixes, so far:

  • Get rid of all the symlinked files in /Sources/RxSwift and just symlink /RxSwift to /Sources/RxSwift
  • Remove the test targets - SPM no longer supports test targets, going as far as to refuse to build any target whose name ends in "Tests"
  • Exclude "Tests/RxCocoaTests"

So my package file now looks like this:

let package = Package(
    name: "RxSwift",
    targets: [
        Target(
            name: "RxSwift"
        ),
        Target(
            name: "RxBlocking",
            dependencies: [
                .Target(name: "RxSwift")
            ]
        ),
    ],
    exclude: [
        "Sources/RxCocoa",
        "Sources/RxTests",
        "Sources/AllTests",
        "Tests/RxCocoaTests"
    ]
)

If I get Linux & Testing working I'll open a pull request.

@gormster that would be awesome.

woop woop!

Test Suite 'All tests' passed at 2016-09-16 18:22:04.413.
     Executed 723 tests, with 0 failures (0 unexpected) in 19.739 (19.756) seconds

alright, we're halfway there. this has involved some serious renaming, though - things learned so far:

  • SPM does not recognise Test files not in the top level of a suite's directory
  • SPM does recognise linked files in a test suite's directory, but not linked folders

I'll file a pull request on Monday. For now, pub and footy call.

Okay, so I've got pretty far with the Linux side of things, but I've hit a roadblock I'm not sure I can cross: RxBlocking depends on CFRunLoop, which is not available in Linux at all. The Swift stdlib equivalent RunLoop is not thread safe, so it's not usable in this case.

My initial instinct is to create a Linux version that just uses Dispatch, but to be honest I'm not even sure what RxBlocking does, let alone how RunLoopLock works or what it's for, so that's kind of a tall order. Is RxBlocking totally necessary for RxSwift to work, or can it be selectively excised from the Linux version?

Alright, I've got some semblance of Linux working. There are two test modules that just don't seem to work at all, inasmuch as the tester just exits without print anything to stderr, just ends. There are also 12 failures on Linux, out of 454 tests:

/root/RxSwift/Tests/RxSwiftTests/SubjectConcurrencyTest.swift:70: error: SubjectConcurrencyTest.testSubjectIsSynchronized : XCTAssertTrue failed - 
/root/RxSwift/Tests/RxSwiftTests/SubjectConcurrencyTest.swift:74: error: SubjectConcurrencyTest.testSubjectIsSynchronized : XCTAssertTrue failed - 
/root/RxSwift/Tests/RxSwiftTests/Observable+CreationTest.swift:89: error: ObservableCreationTests.testJust_DefaultScheduler : XCTAssertEqual failed: ("[]") is not equal to ("[42]") - 
/root/RxSwift/Tests/RxSwiftTests/MainSchedulerTests.swift:61: error: MainSchedulerTest.testMainScheduler_basicScenario : XCTAssertEqual failed: ("[1, 2]") is not equal to ("[1, 2, 3, 4, 5]") - 
/root/RxSwift/Tests/RxSwiftTests/MainSchedulerTests.swift:85: error: MainSchedulerTest.testMainScheduler_disposing1 : XCTAssertEqual failed: ("[1, 2]") is not equal to ("[1, 2, 3, 4]") - 
/root/RxSwift/Tests/RxTests/XCTest+Rx.swift:93: error: ObservableSingleTest.testRetryWhen_ObservableNever : XCTAssertEqual failed: ("[next(2) @ 210, next(3) @ 220, next(4) @ 230, next(5) @ 240, error(dummyError) @ 250]") is not equal to ("[next(2) @ 210, next(3) @ 220, next(4) @ 230, next(5) @ 240]") - 
/root/RxSwift/Tests/RxTests/XCTest+Rx.swift:93: error: ObservableSingleTest.testRetryWhen_ObservableNextError : XCTAssertEqual failed: ("[next(1) @ 210, next(2) @ 220, error(dummyError) @ 230]") is not equal to ("[next(1) @ 210, next(2) @ 220, next(1) @ 240, next(2) @ 250, error(dummyError1) @ 260]") - 
/root/RxSwift/Tests/RxSwiftTests/Observable+SingleTest.swift:1261: error: ObservableSingleTest.testRetryWhen_ObservableNextError : XCTAssertEqual failed: ("[(200 : 230)]") is not equal to ("[(200 : 230), (230 : 260)]") - 
/root/RxSwift/Tests/RxTests/XCTest+Rx.swift:93: error: ObservableSingleTest.testRetryWhen_ObservableComplete : XCTAssertEqual failed: ("[next(1) @ 210, next(2) @ 220, error(dummyError) @ 230]") is not equal to ("[next(1) @ 210, next(2) @ 220, completed @ 230]") - 
/root/RxSwift/Tests/RxTests/XCTest+Rx.swift:93: error: ObservableSingleTest.testRetryWhen_ObservableNextComplete : XCTAssertEqual failed: ("[next(1) @ 210, next(2) @ 220, error(dummyError) @ 230]") is not equal to ("[next(1) @ 210, next(2) @ 220, next(1) @ 240, next(2) @ 250, completed @ 260]") - 
/root/RxSwift/Tests/RxSwiftTests/Observable+SingleTest.swift:1334: error: ObservableSingleTest.testRetryWhen_ObservableNextComplete : XCTAssertEqual failed: ("[(200 : 230)]") is not equal to ("[(200 : 230), (230 : 260)]") - 
/root/RxSwift/Tests/RxTests/XCTest+Rx.swift:93: error: ObservableSingleTest.testRetryWhen_ObservableInfinite : XCTAssertEqual failed: ("[next(1) @ 210, next(2) @ 220, error(dummyError) @ 230]") is not equal to ("[next(1) @ 210, next(2) @ 220]") - 

I haven't filed a PR, because I'm not sure it's worth it, but you can have a look at my changes here: https://github.com/gormster/RxSwift/tree/swift-package-manager

Hi @gormster ,

could you maybe rebase your changes of the top of master maybe? It's little hard to see changes for some reason.

I think we can maybe just use import Dispatch on OSX also instead of Foundation is some cases.

+#if os(Linux)
+import Dispatch
+#endif

This should work now on master branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hannesstruss picture hannesstruss  路  3Comments

jaumard picture jaumard  路  3Comments

lyricsboy picture lyricsboy  路  3Comments

trungp picture trungp  路  3Comments

marlowcharite picture marlowcharite  路  3Comments