Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 14 compatibility issues #28

Closed
nylki opened this issue Feb 3, 2021 · 4 comments
Closed

iOS 14 compatibility issues #28

nylki opened this issue Feb 3, 2021 · 4 comments

Comments

@nylki
Copy link

nylki commented Feb 3, 2021

Hi!
I was trying to get the getting-started code snippets working in a freshly created swiftUI project that targets iOS 14.
But I am running into issues.

First, perhaps unrelated, I had to bump the iOS version in Package.swift from v12 to v13 in a fork, to able to resolve it inside XCode as a SwiftPackage, because of features like Future requiring at least iOS v13.

After getting the package installed I tried out the snippet in my ContentView, but got stuck at following errors:
Screenshot 2021-02-03 at 12 19 40

@alexdrone
Copy link
Owner

Have you tried by having the action type explicit - as in CounterAction.increase(amount: 1) ?

@nylki
Copy link
Author

nylki commented Feb 4, 2021

Thank you for the quick response alex! I followed your suggestion and tried it. It resolved those errors but created new ones:
Screenshot 2021-02-04 at 17 39 30

For reference, here is my full ContentView.swift:

//  ContentView.swift

import SwiftUI
import Store

struct Counter { var count = 0 }

enum CounterAction: Action {
  case increase(amount: Int)
  case decrease(amount: Int)

  func reduce(context: TransactionContext<Store<Counter>, Self>) {
    defer {
      context.fulfill()
    }
    switch self {
    case .increase(let amount):
      context.reduceModel { $0.count += amount }
    case .decrease(let amount):
      context.reduceModel { $0.count -= amount }
    }
  }

  func cancel(context: TransactionContext<Store<Counter>, Self>) { }
}


// MARK: - UI
struct ContentView: View {
    @StateObject var store = Store<Counter>(model: Counter())
    
    var body: some View {
//        Text("Text without Logic")
        Text("counter \(store.model.count)").onTapGesture {
            store.run(action: CounterAction.increase(amount: 1))
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView().background(Color.gray)
    }
}

@alexdrone
Copy link
Owner

Hi! sorry for the late reply :(

This is now fixed in Store 3.6

@nylki
Copy link
Author

nylki commented Mar 1, 2021

@alexdrone No worries, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants