khose
(Marcos Hernandez)
1
Hello!
I'm trying to extract some of our internal modules to external modules, compiled and distributed as xcframeworks. I'm struggling right now linking back the new xcframework back to the app.
When I compile the application with the new dependency added, I get several errors in the generated swiftinterface.
The original code (the library to be extracted) contains among many other things, an extension on Swift.Result:
public extension Swift.Result {
typealias Callback = (_ result: Swift.Result<Success, Failure>) -> Void
init(value: Success) {
self = .success(value)
}
init(error: Failure) {
self = .failure(error)
}
var value: Success? {
return try? self.get()
}
...
Where Success and Failure are defined as generic types of Swift.Result:
// A value that represents either a success or a failure, including an
/// associated value in each case.
@frozen public enum Result<Success, Failure> where Failure : Error {
/// A success, storing a `Success` value.
case success(Success)
/// A failure, storing a `Failure` value.
case failure(Failure)
...
The generated .swiftinterface contains these declarations as expected, but when I try to compile the app it raises an "use of undeclared type" for both Success and Failure. How can I let the compiler know those are generic types?
This is definitely a bug -- any .swiftinterface that the compiler produces when BUILD_LIBRARY_FOR_DISTRIBUTION is enabled needs to be compilable. Is there any chance you can file it on bugs.swift.org and attach a small project that reproduces the issue?
1 Like
khose
(Marcos Hernandez)
3
Sure!
Thanks for coming back so quickly. I'll try to generate a minimal version with the current setup and file it.
1 Like