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

Add async/await functionality to abtesting [SwiftUI] #1214

Merged
merged 3 commits into from
Jul 12, 2021

Conversation

jrcrespoh
Copy link
Contributor

Use updateFromRemoteConfigAsync when using iOS 15 pull-down-to-refresh functionality.

Where else should async/await functionality be used? Should the app log something special to showcase async/await?

Use updateFromRemoteConfigAsync for iOS 15
abtesting/Shared/AppConfig.swift Outdated Show resolved Hide resolved
abtesting/Shared/ContentView.swift Outdated Show resolved Hide resolved
abtesting/Shared/AppConfig.swift Outdated Show resolved Hide resolved
abtesting/Shared/AppConfig.swift Outdated Show resolved Hide resolved
@paulb777
Copy link
Member

paulb777 commented Jul 9, 2021

The test is failing because of missing #if swift 5.5 checks. See firebase/firebase-ios-sdk#8289 for examples.

Before fixing that, it would be good to investigate why the CI is succeeding despite the error.

@paulb777
Copy link
Member

paulb777 commented Jul 9, 2021

We might want to make a subset of https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/build.sh#L111 with the RunXcodebuild() function in the scripts directory of this repo as well.

@paulb777
Copy link
Member

paulb777 commented Jul 9, 2021

You should be able to repro the CI build failures with Xcode 12.

@jrcrespoh
Copy link
Contributor Author

Before fixing that, it would be good to investigate why the CI is succeeding despite the error.

@morganchen12 @paulb777 I am not very sure, but my current understanding is that while xcodebuild is failing, xcpretty is exiting successfully, but that seems to contradict other scripts which do something like (xcodebuild "$@" | xcpretty) || EXIT_STATUS="$?"...

Also, is there a better way of debugging CI issues instead of committing changes and waiting for GHA checks?

@jrcrespoh
Copy link
Contributor Author

We might want to make a subset of https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/build.sh#L111 with the RunXcodebuild() function in the scripts directory of this repo as well.

@paulb777 Should I go ahead and look into this and incorporating it with abtesting?

@jrcrespoh
Copy link
Contributor Author

Should updating the NotificationCenter observer to either Combine or async/await be a separate PR?

Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to merge here and follow up in separate PRs for the other tasks.

@jrcrespoh jrcrespoh marked this pull request as ready for review July 12, 2021 23:19
@jrcrespoh jrcrespoh merged commit 8f6dfc6 into master Jul 12, 2021
@jrcrespoh jrcrespoh deleted the jc-abtesting-async branch July 12, 2021 23:21
let value = remoteConfig["color_scheme"].stringValue ?? "nil"
if changed {
print("Remote Config changed to: \(value)")
DispatchQueue.main.async {
Copy link
Contributor

@peterfriese peterfriese Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to use @MainActor to ensure colorScheme is updated on the main actor?

Using DispatchQueue.main.async in combination with the new async/await features feels a bit like an anti-pattern to me.

See https://peterfriese.dev/swiftui-concurrency-essentials-part1/#updating-published-properties

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks! I will include this change in a separate PR 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, is there an alternative other than using @MainActor? Since we need the app to be backward-compatible with previous versions of iOS, I am not sure how to conditionally add @MainActor...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of options:

  1. You could apply it to a function that needs to run on the main actor (and the #ifdef that function)
  2. Add it to the class (and #ifdef it there)
  3. Call MainAction.run directly: https://www.avanderlee.com/swift/mainactor-dispatch-main-thread/#using-the-main-actor-directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, in that case I can apply it to the already conditionally-compiled async function. Thanks for the pointers!

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

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy