to get a stable module interface. Then I import the generated arm64.swiftinterface file and the .a to another demo project, I got a compile error.
(update: I also used BUILD_LIBRARY_FOR_DISTRIBUTION flag method, and still got the same result. The detail steps are describe in the reply)
I wonder it may be a bug of compiler. The generated swiftinterface have the wrong content. When I add the missing init() method in the generated swiftinterface file, It runs correctly.
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.1 (swiftlang-1100.0.266.1 clang-1100.0.32.1)
// swift-module-flags: -target arm64-apple-ios8.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name RxSwift
The RxSwift source code
/// Base class for all disposables.
public class DisposeBase {
init() {
#if TRACE_RESOURCES
_ = Resources.incrementTotal()
#endif
}
deinit {
#if TRACE_RESOURCES
_ = Resources.decrementTotal()
#endif
}
}
public final class DisposeBag: DisposeBase {
private var _lock = SpinLock()
// state
fileprivate var _disposables = [Disposable]()
fileprivate var _isDisposed = false
/// Constructs new empty dispose bag.
public override init() {
super.init()
}
This is at least one bug and possibly two. DisposeBase doesn't have a public init, and so calling DisposeBag's init an override is incorrect from outside the module. However, I'm not sure we actually implement this correctly (where calling DisposeBag's init from a convenience initializer works without being able to see DisposeBase's init), so the broken interface is potentially protecting you from this issue.
We have a Radar for this already, but no Jira. Mind filing one? (https://bugs.swift.org)
@harlanhaskins Is there a way we could opt libraries in the swift source compat suite into swiftinterface support so we can possibly catch some of these issues? I'm not sure it would have caught this specifically but it seems like that may help surface some adoption blockers
Thank you for the bug reports. The first one is already fixed in swift-5.3-branch and the second is a dupe of a known issue. I'll try to tackle the third one at some point.
In the meantime, there's unfortunately no real workaround for the first bug, other than making the overridden initializer public in the original API.
A possible workaround for bug #2 and #3 is to pass the -module-interface-preserve-types-as-written flag when building the interface file.