exponea / exponea-ios-sdk

MIT License
20 stars 29 forks source link

Shared Not Concurrency Safe #74

Open emadhegab opened 1 month ago

emadhegab commented 1 month ago

Hello, We have latest exponea sdk 2.28.0, we get the warning Reference to class property 'shared' is not concurrency-safe because it involves shared mutable state; this is an error in the Swift 6 language mode

Screenshot 2024-08-21 at 14 45 54

Screenshot 2024-08-21 at 14 46 15

is there a better way than singleton to init the exponea in the newest versions?

Ankmara commented 1 month ago

Hi, thank you for report. We don't support beta versions (Swift 6). When the version of Swift is officially released, we will definitely cover it. You can use ExponeaInternal() as a public property instead of shared, but we can't guarantee functionality.

emadhegab commented 1 month ago

As swift 6 officially released. we can't work anymore with the sdk

Ankmara commented 1 month ago

Hi, I am trying to simulate this warning, but no luck. How this warning blocked you? Could you share your implementation for ExponeaServicing please?

emadhegab commented 1 month ago

sure.. here is how the error now looks when we start using swift 6 in our project. you need to make your SPM or the main bundle uses swift 6

Screenshot 2024-09-18 at 13 40 55

and here is the code directly so you can see it yourself

`

class ExponeaService: ExponeaServicing {
    func setup(withTrackingConsent: Bool) {
        Exponea.shared.configure(
            Exponea.ProjectSettings(
                projectToken: "<PROJECT_ID",
                authorization: .token("<TOKEN>"),
                baseUrl: "https://api.eu1.exponea.com"
            ),
            pushNotificationTracking:
                withTrackingConsent ? .enabled(appGroup: AppConfigurations.Environment.appGroupBundleID) : .disabled
        )
    }

    func anonymizeUser() {
        Exponea.shared.anonymize()
    }

    func sendUserID(_ id: String) {

        let properties: [String: String] = [
            "customer_id": id
        ]

        Exponea.shared.identifyCustomer(customerIds: properties,
                                        properties: [:], timestamp: nil)
    }

    func registerToken(_ token: Data) {
        guard Exponea.shared.isConfigured else { return }
        Exponea.shared.trackPushToken(token)
    }
}

`

Ankmara commented 1 month ago

Thank you. We started with fixing.