Closed vzsg closed 1 year ago
I did some tests, it seems the RxTest product is the one that kills the mood. The other four, in any combination, work fine.
I wonder what's so special about it... The only thing I see is this symlink.
That symlink is a red herring, Xcode could clone it just fine and it appeared as a regular file at the proper place. In fact, the complete Sources folder in RxSwift is just a bunch of symlinks.
There was another red herring in the build logs:
Changing the deployment target in Dependencies/Package.swift to macOS 10.15 made the warning go away, but did not change the original error.
My next suspicion is the fact that RxTest is pulling in XCTest, and that might somehow be illegal for a playground.
It's definitely the XCTest import! There is a single file inside RxTest that imports it. After removing this file from the project, the playground started working.
On a whim, I tried to make a playground for Nimble, and that resulted in the same kind of errors.
Thanks a lot for raising this and finding out about XCTest!
I know XCTest didn't work in playgrounds in the past but I thought that wasn't a problem anymore. I'll see what I can do.
Raised as FB8882995. From what I gather this might be a problem with playgrounds.
A similar issue occurs when you try to add a SPM package product that imports XCTest to a command line project. In order for the project to build you must make certain changes to the build settings:
For the project build settings, search for "Runpath Search Paths" and add the following paths:
For the project build settings, set "Enable Testing Search Paths" to "Yes"
You don't have access to these settings in a playground, so there's probably nothing you can do.
@pointfreeco have come up with a workaround to ship XCTFail
in library code and I wonder if this would work in a playground as well.
It's using their new package XCTest Dynamic Overlay. I'll need to try this but perhaps adding this package and import XCTestDynamicOverlay
at the top might work?
This might require defining all the other XCTest symbols though - the library only declares XCTFail
.
I wonder if conditional linking of XCTest
would be a workable solution (upstream): https://github.com/apple/swift-collections/blob/main/Package.swift#L72-L81
I've just tried this with RxSwift 6.5.0 and Xcode 14.1 and this seems to be fixed now:
As we've discussed on Discord, using Arena 1.0.0 to make a playground for RxSwift (5.1.1 at the time of writing) results in a seemingly valid workspace playground that Xcode loads successfully, with autocomplete to boot.
However, running the playground fails with errors such as:
An example repo is available here (GH link), or here (ZIP).
As a workaround, editing Dependencies/Package.swift and removing all product dependencies except RxSwift makes the playground work.
From:
To: