The whole networking module is conforming to Sendable protocol but this warning I have no idea how to fix. Is there a way I can fix this with minimum changes. Any help is highly appreciated.
What this is telling you is UIDevice.current is only safe to access from the MainActor. Meaning it is main-thread-only.
This looks like a static value. One potential option would be to instead create this string on the main thread at some high-level entry point to your application. And then, pass it down into wherever you create the networking system that needs it.
This is something we could do, but passing user agent info in each network request is not a good design and extra overhead just to satisfy this warning.
I wasn't suggesting passing it into each request! I was suggesting creating the string on the MainActor, and then passing it into your system. From there you should be able to maintain the same API you have today (computed property -> stored property).
Further, I think it's worthwhile filing a bug about this. I don't immediately see why these UIDevice properties need MainActor isolation. This could be an oversight!
We could do it but as I have mentioned, the issue is networking module and await for each request is an extra overhead which is not good in terms of performance.
I don't think awaiting small variable will decrease your performance somehow. This is correct behaviour in the end—there are some stuff in UIDevice (it's UI in the end) that should run on main thread, accessing it from other threads is basically a side effect.
And regarding the ticket—UIDevice being @MainActor is correct, think what @mattie ment is that this exact properties model and systemVersion shouldn't.
Since UIDevice info clearly is not going to change during app launch, I think the best option pass it on init or await it once and cache, then use without any additional actions in requests. I don’t think there is performance impact if you just await as @jaleel suggested, but I think in general it is better to reduce number of awaits if possible, including such cases as well.