adamayoung / TMDb

The Movie Database Swift Package
https://adamayoung.github.io/TMDb/documentation/tmdb
Apache License 2.0
112 stars 29 forks source link

Network requests do not work in Simulator #125

Closed dcamenisch closed 1 year ago

dcamenisch commented 1 year ago

Network requests do not seem to work in the Simulator and only on an actual device. The following code was used:

return try await trendingService.tvSeries(inTimeWindow: .week, page: page).results

The call never returns.

This behavior was observed with the newest version of TMDb (bb032f0) and iOS 17.0 (both on device and in the Simulator).

dcamenisch commented 1 year ago

Seemed to be a issue related to the simulator. After reinstalling the app and restarting the simulator it worked.

However, after sometime it breaks again.

yood commented 9 months ago

I'm having the same issue, where the call never returns. Re-install in simulator fixed it, then it failed again soon after.

I think it might be due to multipathServiceType = .handover in the default client.

https://github.com/adamayoung/TMDb/blob/6049b86f2d28abd35a114e962db5a41b5c2fb027/Sources/TMDb/TMDbFactory.swift#L74

To use the .handover multiparth service type, you have to add the entitlement to Xcode. https://developer.apple.com/documentation/foundation/nsurlsessionmultipathservicetype/nsurlsessionmultipathservicetypehandover

I added the entitlement, but the problem persisted.

I was finally able to fix it by passing in my own client with a URLSession with multipathServiceType left to the default.

Xcode 15.2 macOS 14.3

movesmyers commented 6 months ago

@yood can you clarify how you passed in your own client? I'm having this same issue and I'm having trouble with figuring out the fix.