-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Test target does not build when RxCocoa Swift Package is used #2057
Comments
I created a fork of RxSwift, and declared RxCocoaRuntime as a product/library. Linking RxCocoaRuntime with test targets makes it possible to build the target. But tests do not get launched, it seems RxSwift symbols are included in both host app, and test target because RxCocoaRuntime depends on RxSwift. Then the process stops with EXC_BAD_ACCESS. The same happens when RxCocoa is not imported and tests build, but RxTest or RxBlocking is linked with test target. |
Also troubled by this problem 💔 |
Have you found any solution to this ? @michallaskowski |
Xcode 11 GM, problem still exists. UPDATE: |
Happy to accept a PR around this if anyone's interested to investigate. I'll only have time in a a week or two. |
I tried to reproduce duplicated symbols issue with a separate, small project. But SPM had no issues with it. I am not sure yet what triggers it for RxSwift, but also had not enough time to dig into it. |
I have the same problem with the SPM and XCode 11. I investigated a bit, but I couldn’t solve it. I think, there are two problems: One with the RxCocoaRuntime, that is not found. And the other, that RxBlocking/RxTest depend also on RxSwift. Therefore the test target contains the RxSwift symbols twice and crashes. I think, the dependencies between the RxSwift targets need to be declared differently, that SPM works also for the test targets. |
I have same problem with XCode 11 with spm, but im only getting this error when including RxSwift in a iOS intents extension. |
Anyone tested with Xcode 11.1? |
Same issue here with Xcode 11.0 (11A420a). Is anyone fixing it? |
I'm not sure if it's the same case for everyone. But in my case, when I add "RxCocoa" to "Link Binary with Libraries" in the test target's Build Phase tab, it successfully built. |
I have found out that it is a known issue with rdar://problem/54587458. Work around is to add flag to explicitly append modulemap to the
|
@achernoprudov where did you find a reference to that radar ? |
@freak4pc I found it in swift-nio library. Issue-1228 |
I tested the changes, thanks for the info. While the tests build now, they are crashing on Xcodes 11.0, 11.1 GM, and 11.2 beta. On Xcode 11.1, Sample project updated: https://github.com/michallaskowski/RxCocoaTestsIssue |
I had that crash as well and fixed it by not adding a swift package dependency that isn't a dynamic library multiple times on different targets. |
Well, yes. Removing RxTest and RxBlocking from test target stops the crash. But also doesn't solve anything, if I want to test reactive parts of code. Unless you mean something else in this case, @FabianTerhorst ? RxTest and RxBlocking both depend on RxSwift target, which is linked in the host application. |
I don't have time to test this but seems to me the best way would be adding the flags @achernoprudov mentioned above using SPM's More info: |
I was able to get my tests to run by setting up the flag @achernoprudov mentioned
Also by adding the 5 frameworks from RXSwift directly to my main target only and removing them all from my test target. |
I have the |
@iwheelbuy you have crash because
|
@achernoprudov I'd love to go the 2nd way, but how do I use RxSwift in the test target? If I try to import
I got If I try not to import
I got the Edit: |
@iwheelbuy my project have the same problem. I download you sample code and remove Allow testing Host Application APIs flag but still crash. what can i do to fix it? |
Can anyone confirm if this is working in Xcode 11.3 or its still a valid issue? Thanks ! |
Not working for me in Xcode 11.3.1 (that is, I cannot run tests, get the |
I think this is causing my test crashes in Xcode 11.3.1 as well, Also, lots of console messages like:
....which I suspect is the problem: RxSwift is static in both the test and the app. |
Since my unit tests don't use the UI, I just made them logic tests for now, so they're isolated from the app and don't have duplicate symbols with it. |
Hey both. I'm sorry you're having this issue, but as far as I can tell, this is entirely an SPM problem (or it would happen in other package managers, or without one). I suggest filing a repoducible bug at bugs.swift.org and reference this thread, as well. Thanks ! |
Thanks. I just set up an RxDataSources project to show the problem, and sent feedback to Apple, since for me, even if I say in a fork that RxSwift is dynamic, it's also including it as static. |
Thanks, mind sharing the link here? |
I suggest having one in bugs.swift.org specifically as it seems SPM-specific. Feedback would take longer to get noticed IMO |
@AJBeltran3 how did you solve the main app crashing at startup with |
Had to fix "missing required module 'RxCocoaRuntime'" error with ReactiveX/RxSwift#2057 (comment)
I'm here from google, tried to resolve another, but a similar bug. When I use Swift Package Manager and set "Host Application" to None for test target's settings, test target stops building with linking issues of SPM's dependencies. So I need to explicitly add those dependencies to test target's both Dependencies and Link Binary With Libraries sections in Build Phases tab. Thanks for suggestion! |
Update: "Clean Build" helped. I initially installed the dependencies using SPM, and then replaced them with frameworks built by Carthage. Somehow, Xcode got confused. |
Uhm, I just tried it in Carthage and it worked fine. Could you provide a repro project? @kean |
Saw your comment. Thanks for the update. I'll be closing this for now. |
The path to modulemap file has changed in Xcode 12, the |
@RinatAbidullin Are you positive? If yes, it's worth filing an SPM bug. |
Hi all for those of us just joining the party, what's the latest solution to this? i see some compiler flag (that maybe doesn't work?), I see a screenshot recommending adding the dependency manually to the test target, etc. Is this documented somewhere? Thanks! |
Hey Gal 👋 |
Depending on what you are building for (simulator, device, archive build) the modulemap path will reference the
|
Not working in Xcode Version 14.2 (14C18) |
This worked for me as well |
Short description of the issue:
When RxCocoa is used in a project in Xcode 11, and it is imported as RxSwift package, unit tests for that project do not build, with following error:
I am not an expert on Swift Packages, just starting with it. I see RxCocoaRuntime is declared as a target in Package.swift, and RxCocoa depends on it. But it is not declared as a product.
This may be also Xcode's issue. But I don't have issues with other dependencies.
Expected outcome:
Tests build and are executed.
What actually happens:
Build fails.
Self contained code example that reproduces the issue:
Sample, minimal project: https://github.com/michallaskowski/RxCocoaTestsIssue
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
Current master, commit 6b2a406
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
Xcode 11 beta 7, tested also with beta 6
Installation method:
other - Swift Packages :)
I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)
The text was updated successfully, but these errors were encountered: