-
Notifications
You must be signed in to change notification settings - Fork 112
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
DependencyValues.swift introduces hard dependency on XCTest.dll in Release builds. #111
Comments
@jeffdav Is it possible to compile with We're definitely open to other options, but SwiftPM's package-level configuration options are pretty much nonexistent right now, so I think we need to rely on other ambient compile-time configuration/flags. |
Unfortunately we cannot, as |
@jeffdav Unfortunate that the flag is unavailable 😕
I may not fully realize what you have in mind, but if this requires a user to remember to do an extra link/import in tests or otherwise risk subtly breaking things, I'm afraid that would be a non-starter in library usability. We'd probably be better off in not supporting release tests at all in that case. We are definitely open to any and all solutions here, but we may need your help in figuring them out, especially since we're a little less versed in Windows. As for including |
I'm not an expert, so I'm not 100% sure of a solution either, but I was imaging something similar to how Binary size is a concern, and static linking--even if it were available--would be to each binary we produce in the package. I'm not sure about a post-build step. And it just seems strange for XCTest.dll to show up in a released product's installer. |
Hi @jeffdav, swift-collection's If I'm understanding your suggestion correctly, we would make a But, even if it was possible, it would mean people need to know that they have to import Really it just seems that we are grappling with Swift's weird testing infrastructure. It's being held back by compatibility with Xcode and super old Objective-C APIs, and it's the whole reason XCTestDynamicOverlay exists in the first place. But we don't think a test support library is the right fix (if even possible). It seems more correct to directly deal with Swift's weirdness by either figuring out how to excise XCTest.dll from the final product, or just accepting it as an artifact of the product. We definitely agree that this isn't ideal, and we are definitely open to any and all explorations to make it better. |
@mbrandonw so, the idea is that this is for testing only, and the usability is critical, so perhaps we can make a different trade off? We could remove the |
Hi @compnerd, dynamically loading the functionality is absolutely a possibility, and we've already done similar things in a number of places, so it's not something we shy away from. We just aren't entirely sure of how to do it in this situation, but we would love some help! Also, for Windows in particular, we really don't have any experience with dynamically loading symbols. We even had to drop Windows support from our |
The equivalent of |
Thanks. I think overall we would need help with wielding these tools. Especially with how it relates to dynamically performing these lines: swift-dependencies/Sources/Dependencies/DependencyValues.swift Lines 402 to 408 in 720e68a
|
Hmm, one immediate workaround that comes to mind - exile the @_spi(DependenciesTestSupport)
public class TestObserver: NSObject {
init() {
_ = "DependenciesTestSupport.dll".withCString(encodedAs: UTF16.self, LoadLibraryW)
}
} @_spi(DependenciesTestSupport) import SwiftDependencies
import XCTest
public extension TestObserver: XCTestObservation {
public func tesCaseWillStart(_ testCase: XCTestCase) {
DependencyValues._current.cachedValues.cached = [:]
}
} |
@compnerd Sorry we lost track of this. I'm not sure I see the full picture, but would you be willing to try and PR such a solution? |
I'm not sure if I have the time to do this right now, but will see if I can get around to do it at some point. In the mean time, this should be something that you should be able to do with the XCTest documentation already. |
#169 I think might be a start towards a solution. |
I believe this is fixed now by merging #169. But let me know if we should reopen it. |
Thanks all! |
Description
When building Release builds of an app that depends on
swift-dependencies
on Windows, we now also have a dependency onXCTest.dll
. We do not want to shipXCTest.dll
. :)I believe that
DependencyValues.swift
, line 402 introduces this issue.This may be related to #79.
Checklist
main
branch of this package.Expected behavior
No dependency on XCTest.dll in non-test, non-debug code.
Actual behavior
There is a dependency in the release build:
Steps to reproduce
Build a project on Windows.
Dependencies version information
9e92056
Destination operating system
Windows 11
Xcode version information
n\a
Swift Compiler version information
The text was updated successfully, but these errors were encountered: