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**
- [x] iOS
- [ ] macOS
- [ ] tvOS
- [ ] watchOS
- [ ] playgrounds
**How easy is to reproduce? (chances of successful reproduce after running the self contained code)**
- [x] easy, 100% repro
- [ ] sometimes, 10%-100%
- [ ] hard, 2% - 10%
- [ ] extremely hard, %0 - 2%
**Xcode version**:
Xcode 9.4.1
```
:warning: 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. :warning:
Installation method:
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)
I can confirm this issue, have exact same message. However it is present in my one project where I use CocoaPods. I use RxSwift 4.3 as git submodule in other project and no issues there while building.
Interesting. I tried locally and couldn't reproduce. Can you try producing a brand new Xcode 9 projects where this happens?
Hi @freak4pc,
Unfortunately I have updated my only instance of Xcode to version 10 (build 10A255).
More about my pod env settings:
```CocoaPods : 1.5.3
Ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
RubyGems : 2.7.6
Host : Mac OS X 10.13.6 (17G65)
Xcode : 10.0 (10A255)
Git : git version 2.17.1 (Apple Git-112)
Ruby lib dir : /usr/local/Cellar/ruby/2.5.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 4f751f5b883fc56ba101711ff6b2ee225cbedbaa
cocoapods-deintegrate : 1.0.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.0
cocoapods-try : 1.1.0
Hi @freak4pc ,
I create a new project, a single view app, with a viewController with nothing, just import RxSwift in Xcode 9.
my podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'testRxSwift' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testRxSwift
# Rx
pod 'RxSwift'
pod 'RxCocoa'
target 'testRxSwiftTests' do
inherit! :search_paths
# Pods for testing
end
target 'testRxSwiftUITests' do
inherit! :search_paths
# Pods for testing
end
end
I'm now using Cocoapod version 1.6.0.beta.1, but I had the same issue with the previous version.
I don't still have the problem.
@ludivinefafournoux you mean that you can reproduce this issue with Xcode 9 or you cannot?
@bdolewski i can't reproduce this issue with a new project, I tried my actual project with Xcode 10, and I have the same issue, but with a new one, I don't have the problem.
Sometimes, if I clear DerivedData and clean my project and build again, it works, with Xcode 9. (I'm not using Xcode 10 yet)
@ludivinefafournoux thanks for clarification :)
Hi again @freak4pc,
is it possible for you to retest RxSwift 4.3 with Xcode 10 with CocoaPods and with git submodule?
@freak4pc: Recently I was reproduce this issue, but I can not remember that configuratión. Actually, compiles me fine iOS and Mac in __Xcode 9.4__ with both __RxSwift 4.3__ and __RxSwift in master branch__ and in __Xcode 10__ with __RxSwift in master branch__.
@bdolewski: Maybe a __subspec__, but with this would be necessary to use pod 'RxSwift/4.2' or similar, being this a bit weird.
@ludivinefafournoux, what is your SWIFT_VERSION build setting in your updated project?
@bdolewski Sorry, nothing personal but I can't really find time to make tests for other issues :)
If you have a reproducible example for an issue, I'd love to take a look.
@freak4pc
Sure, no problem :) Since it's related to my commercial work, I'll try to provide the smallest project to reproduce this issue.
Have the same issue, any updates?
@ludivinefafournoux, what is your
SWIFT_VERSIONbuild setting in your updated project?
Swift 3.3 in my actual project with which I have the issue and Swift 4.1 with the empty project with RxSwift only.
Getting the same error in XCode 10, SWIFT_VERSION 4, Compiling RxSwift as 4.2
@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:
...
pod 'RxSwift', '~> 3.0'
...
Please use Swift 4.x with RxSwift 4.x. The reason why this compilation fails is because you are using Swift 3.x.
Might be i solved the issue i add
fileprivate var _lock = SpinLock()
instead of
private var _lock = SpinLock()
There is no issue with the project, you’re probably using Swift 3 with a version of
RxSwift that’s too new.
来个中文版 升级一下Xcode 如果不升级开发的团队 我相信你是能够解决着一Bug的 毕竟我是个人开发,随意升级了 祝你好运
DisposeBag.swift class u ll find lock declaration with private, change it to fileprivate it worked for me
I solved it this way:
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['RxSwift', 'RxCocoa'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
end
end
end
Though it would be better to understand, why Cocoapods sets Swift version to 3. Probably, podspec is wrong.
Most helpful comment
Please use Swift 4.x with RxSwift 4.x. The reason why this compilation fails is because you are using Swift 3.x.