RxSwift: error when compiling with RxSwift - '_lock' is inaccessible due to 'private' protection level in DisposeBag
Short description of the issue:
Since few days, I add RxSwift with cocoapods in my iOS project. when i build it, i have this error :
Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift:107:31: '_lock' is inaccessible due to 'private' protection level
Expected outcome:
My project builds
What actually happens:
I have a problem with the declaration in disposebag private var _lock = SpinLock()
/// Convenience function allows an array of disposables to be gathered for disposal.
public func insert(_ disposables: [Disposable]) {
_lock.lock(); defer { _lock.unlock() }
if _isDisposed {
disposables.forEach { $0.dispose() }
} else {
_disposables += disposables
}
}
i have this error '_lock' is inaccessible due to 'private' protection level at the line _lock.lock(); defer { _lock.unlock() }
Self contained code example that reproduces the issue:
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
RxSwift 4.3.0 RxCocoa 4.3.0
Platform/Environment
- iOS
- macOS
- tvOS
- watchOS
- playgrounds
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
- easy, 100% repro
- sometimes, 10%-100%
- hard, 2% - 10%
- extremely hard, %0 - 2%
Xcode version:
Xcode 9.4.1
⚠️ Fields below are optional for general issues or in case those questions aren’t related to your issue, but filling them out will increase the chances of getting your issue resolved. ⚠️
Installation method:
- CocoaPods
- Carthage
- Git submodules
I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)
- yes (which ones)
- no
Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)
- just starting
- I have a small code base
- I have a significant code base
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (7 by maintainers)
Please use Swift 4.x with RxSwift 4.x. The reason why this compilation fails is because you are using Swift 3.x.
@ludivinefafournoux I think you should use RxSwift version 3.x for Swift 3. Take a look here: https://github.com/ReactiveX/RxSwift/#requirements that is to say: