Skip to content

Commit

Permalink
Fix concurrency warnings in PersonalInfoField.swift and RemoteSVGVi…
Browse files Browse the repository at this point in the history
…ew.swift` (#267)

* Fix concurrency warning on defaultPersonalInfo

* Fix concurrency warning on webView delegate method

* Trigger Build

* Fix the concurrency warning that happens when we run `make validate-podspec

- WARN | xcodebuild: /Users/pinarolguc/Development/Gravatar-SDK-iOS/Sources/GravatarUI/ProfileFields/PersonalInfoField.swift:18:57: warning: main actor-isolated static property ‘defaultPersonalInfo’ can not be referenced from a non-isolated context; this is an error in Swift 6
  - NOTE | xcodebuild: /Users/pinarolguc/Development/Gravatar-SDK-iOS/Sources/GravatarUI/ProfileFields/PersonalInfoField.swift:6:23: note: static property declared here

* Add a note

* Revert "Add a note"

This reverts commit ae2fe79.

* Revert "Fix the concurrency warning that happens when we run `make validate-podspec"

This reverts commit 34ade28.

* Bump up swift versions in the podspec

* Revert "Bump up swift versions in the podspec"

This reverts commit a38bab0.

* Bump up swift versions in the podspec

* Revert "Revert "Fix the concurrency warning that happens when we run `make validate-podspec""

This reverts commit f882d6c.

* Revert "Revert "Add a note""

This reverts commit 30313df.

* Revert "Bump up swift versions in the podspec"

This reverts commit b036b74.
  • Loading branch information
pinarol authored Jun 4, 2024
1 parent 4c3b461 commit 7adb230
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 11 additions & 10 deletions Sources/GravatarUI/ProfileFields/PersonalInfoField.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import UIKit

public enum PersonalInfoConstants {
public static let defaultPersonalInfo: [PersonalInfoLine] =
[
.init([.jobTitle]),
.init([.namePronunciation, .pronouns, .location]),
]
}

@MainActor
public struct PersonalInfoBuilder {
static let defaultSeparator: String = ""

public static let defaultPersonalInfo: [PersonalInfoLine] = [
.init([.jobTitle]),
.init([.namePronunciation, .pronouns, .location]),
]
let label: UILabel
init(label: UILabel) {
self.label = label
Expand All @@ -20,10 +15,16 @@ public struct PersonalInfoBuilder {
@discardableResult
public func content(
_ model: PersonalInfoModel,
lines: [PersonalInfoLine] = PersonalInfoConstants.defaultPersonalInfo,
lines: [PersonalInfoLine]? = nil,
separator: String? = nil
) -> PersonalInfoBuilder {
let separator = separator ?? Self.defaultSeparator
// Note: PersonalInfoBuilder.defaultPersonalInfo was meant to be a default
// argument declared in the method signature. But then `make validate-pod`
// generates this warning:
// "main actor-isolated static property ‘defaultPersonalInfo’ can not be referenced
// from a non-isolated context; this is an error in Swift 6" and the validation fails.
let lines = lines ?? PersonalInfoBuilder.defaultPersonalInfo
let text = lines.map { line in
line.buildingBlocks
.compactMap { $0.text(from: model) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ class RemoteSVGButton: UIControl, WKNavigationDelegate {
}
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
nonisolated func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
Task {
await showWebView()
}
}

func showWebView() {
webView.isHidden = false
}

Expand Down

0 comments on commit 7adb230

Please sign in to comment.