mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
434 stars 234 forks source link

Warnings when compiled with Xcode 14.3 RC #595

Closed bealex closed 1 year ago

bealex commented 1 year ago

There are several warnings appeared if compile with Xcode 14.3. Can you please fix them? Here is the log from the build:

.../mixpanel-swift/Sources/Network.swift:144:54: warning: heterogeneous collection literal could only be inferred to '[String : Any]'; add explicit type annotation if this is intentional
        let requestData = JSONHandler.encodeAPIData([["event": eventName, "properties": trackProperties]])
                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                         as [String : Any]
.../mixpanel-swift/Sources/Network.swift:182:57: warning: heterogeneous collection literal could only be inferred to '[String : Any]'; add explicit type annotation if this is intentional
            let engageData = JSONHandler.encodeAPIData([["$token": apiToken, "$distinct_id": distinctId, "$add": [eventName: 1]]])
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                                                 as [String : Any]
.../mixpanel-swift/Sources/People.swift:269:43: warning: empty collection literal requires an explicit type
        set(properties: ["$transactions": []])
                                          ^~

.../mixpanel-swift/Sources/SessionMetadata.swift:34:52: warning: heterogeneous collection literal could only be inferred to '[String : Any]'; add explicit type annotation if this is intentional
        let dict: [String: Any] = ["$mp_metadata": ["$mp_event_id": String.randomId(),
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RamblinWreck77 commented 1 year ago

I don't see any warnings on xcode 14.3/mixpanel 4.1/4.1.1 and using SPM.

How are you integrating?

bealex commented 1 year ago

As the SPM package. 4.0.4 was imported, I've updated to 4.1.1 but nothing's changed. Here is the discussion about this warning.

https://forums.swift.org/t/swift-5-8-new-warnings-for-any-collections/63484/10 and https://github.com/apple/swift/issues/60011

xmanu commented 1 year ago

Is there any progress on this? I see the same warnings and I'd love to have these fixed...

RamblinWreck77 commented 1 year ago

https://github.com/mixpanel/mixpanel-swift/pull/602

jaredmixpanel commented 1 year ago

@xmanu I will get a release out today with #602 in it

jaredmixpanel commented 1 year ago

Fixed in v4.1.2