Comments (16)
Hi, yes, will check it later today or tomorrow.
Stay tuned
from reactiveswift-composable-architecture.
Hi, I'm using this library with an iOS 11.4+ project. I think, that the problem should not be in the implementation. Can you provide more information about the errors you got?
from reactiveswift-composable-architecture.
Well, let's take as an example: https://github.com/trading-point/reactiveswift-composable-architecture/blob/master/Examples/TicTacToe/Sources/Views-UIKit/GameViewController.swift.
It uses inside viewDidLoad method
self.viewStore.produced.title
.assign(to: \.text, on: titleLabel)
Definition of ViewStore is to conform to ObservableObject, which is part of Combine.
Are you using ViewStore to access properties inside the ViewController, or you use Store directly?
from reactiveswift-composable-architecture.
Hi @AndreiVidrasco,
At my work we using this library, including ViewStore
in a project that supports iOS 12 with no problem at all. In fact that was the whole purpose of the port, to be able to use it with iOS 12!
Even though ViewStore
conforms to ObservableObject
since the ObservableObject
protocol is annotated with @available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
this turns into a no-op and for iOS 12 builds there is no protocol conformance. We are not linking Combine in our app at all.
In our View Controllers we have things like:
viewStore.produced.isContinueButtonEnabled
.startWithValues { [weak self] in
self?.continueButton.isEnabled = $0
}
and:
backButton.reactive
.controlEvents(.primaryActionTriggered)
.observeValues { [weak self] _ in
self?.viewStore.send(.prevPage)
}
Are you getting a particular compiler or build error when using ViewStore
?
from reactiveswift-composable-architecture.
We are not linking Combine in our app at all.
Regarding this, please see this comment in the README.
You will need to weak link Combine and SwiftUI, but they will never be loaded. I have tested this running on an iOS 12 simulator.
from reactiveswift-composable-architecture.
The reason that the ObservableObject
conformance was kept was so that this library could still be used with SwiftUI if you wanted to, on a version of the OS that supports it.
from reactiveswift-composable-architecture.
Also SwiftUI
embeds Combine
, so it is enough to embed SwiftUI
only.
And I did it in an XCodeUI-way by adding SwiftUI
to target's frameworks with embed value: "Do Not Embed".
Then in build phases in "Link Binary With Libraries" phase I changed SwiftUI
status from required to optional.
from reactiveswift-composable-architecture.
Ok, thank you very much for your help.
My setup is a bit more extreme (and experimental).
We're using this tool https://github.com/readdle/swift-android-toolchain Swift Android Toolchain to have business logic in Swift (in future with composable architecture)
Turns out that Reactive Swift is running already on Linux, which made running it on Android trivial. PointFree's case paths don't have any dependencies and they run out of box on Android.
So, last missing piece was this repo to add. And as you can imagine even weak-linking is not really an option.
But no worries, I thought that the stuff from Combine is actually mandatory needed.
I will just fork and remove all mentions from Combine and use it like
viewStore.produced.isContinueButtonEnabled
.startWithValues { [weak self] in
self?.continueButton.isEnabled = $0
}
Thanks for your help, closing the issue
from reactiveswift-composable-architecture.
Interesting use case. I hadn't considered using the lib on non-Apple platforms.
It might be possible to use conditional compilation do optionally exclude the Combine dependency completely.
I'll see what I can do 👍
from reactiveswift-composable-architecture.
It might be as straightforward as using #if canImport(Combine)
. I will try this in a branch and let you know.
from reactiveswift-composable-architecture.
I tried initially to do that, with #if canImport, but stumbled on this issue with ViewStore's conformance.
I guess some could write
#if canImport(Combine) // or os(Android)
public final class ViewStore<State, Action> {
#else
public final class ViewStore<State, Action>: ObservableObject {
#endif
But I thought that is too narrow use-case to submit a PR
from reactiveswift-composable-architecture.
I just created the branch michael/if-can-import-combine
which conditionally excludes Combine and SwiftUI stuff from ViewStore
. Let me know if it works for you:
UPDATE:
It might be necessary to add canImport
to all the source files in the SwiftUI
source folder of ComposableArchitecture.
from reactiveswift-composable-architecture.
@mluisbrown
it's not that simple. #26
Yes, I added #if canImport(SwiftUI) everywhere, because it was indeed needed.
But there is also, os.signpost
, which unfortunately doesn't work, but I don't know the solution for it, and since I don't really need it for my use case, I completely deleted the file.
Other changes that I made:
#if os(Linux) || os(Android)
import let CDispatch.NSEC_PER_USEC
import let CDispatch.NSEC_PER_SEC
#endif
inside Sources/ComposableArchitecture/Internal/Debug.swift
This part I deleted completely(again, don't really need for my use case):
extension UnsafeMutablePointer where Pointee == os_unfair_lock_s {
@inlinable @discardableResult
func sync<R>(_ work: () -> R) -> R {
os_unfair_lock_lock(self)
defer { os_unfair_lock_unlock(self) }
return work()
}
}
And I think that's all changes. Now, the swift-android-toolchain is a bit behind, it works only on Swift 5.0.3, so I needed to add explicit return
in a few places, but I don't think it's needed to add in the library, because there is a plan to update swift-android-toolchain.
from reactiveswift-composable-architecture.
Ok, I merged your PR into my branch 👍
But there is also, os.signpost, which unfortunately doesn't work, but I don't know the solution for it, and since I don't really need it for my use case, I completely deleted the file.
I added #if canImport(os)
around the ReducerInstrumentation.swift file, which should solve this.
For the use of os_unfair_lock
I guarded the code with #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
.
So, apart from the explicit returns this should be enough. Are you able to check it in your environment?
from reactiveswift-composable-architecture.
Hi,
Sorry for taking this long. Yes, looks like it's working. The moment swift-android-toolchain will be updated to Swift 5.3 it's gonna be possible to use this out of box.
from reactiveswift-composable-architecture.
Nice! I'm going to turn the branch into a PR then, and try to get CI running on Linux for it. Thanks for your help!
from reactiveswift-composable-architecture.
Related Issues (8)
- Nested properties keyPath support for Produced values HOT 6
- Change TestStore so that it isn't only compiled when running in DEBUG HOT 4
- Multiple calls to store.ifLet HOT 2
- Is there any plans on releasing this framework to CocoaPods? HOT 10
- Please make Effect.throttle public HOT 12
- Object get deallocated on Signal.Observer HOT 3
- Include TCA Swift Concurrency changes from release 0.39.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveswift-composable-architecture.