Post

Replies

Boosts

Views

Activity

Reply to URLSessionDataTask response from URLCache or not?
Thanks Matt for your support, this is exactly what I was looking for. Side question: sometimes there are two transactions (the first one hitting the cache, the second one the network). I assume the first transaction finds out that the cached response is stale, hence the second transaction. If I'm correct, is there any property describing the cache transaction result? Thanks again, Aurélien.
Feb ’21
Reply to URLSessionDataTask response from URLCache or not?
First I create the URLRequest object with a cachePolicy (usually .useProtocolCachePolicy).      var urlRequest = URLRequest(url: url, cachePolicy: cachePolicy, timeoutInterval: timeoutInterval) Then I retrieve the cachedResponse from URLCache as follows:      let cachedResponse = URLCache.shared.cachedResponse(for: urlRequest) Here, cachedResponse(for:) always returns a new object (different pointer) if called several times with the same URLRequest. And it's the same for the HTTPURLResponse that I get as follows:      let cachedHTTPURLResponse = cachedResponse?.response Finally I create and resume the URLSessionDataTask, assuming the response will cached in URLCache (if the cache policy allows it).      let dataTask = urlSession.dataTask(with: urlRequest) { ... }      dataTask.resume()
Feb ’21
Reply to Embedded frameworks architectures check fail with XCode 12.3
So, as I cannot wait for third party XCFrameworks to be delivered, I went through the path of repacking the legacy frameworks into XCFrameworks and it works fine, as long as the XCFrameworks are there when compiling (which is not necessary with common frameworks). But this is another story. For those interested in how to create these XCFrameworks on the fly, here is how I managed to do so: Create an aggregate target in your project Add a build phase script to this new target to build the XCFrameworks Edit the scheme of the primary target (the one for your app) and add the aggregate target to the top of the targets list (build tab) Uncheck "Parallelize Build" to preserve the targets order
Dec ’20
Reply to iOS 14 Local Network Privacy
Quinn, I gave it a try with the test app I made back then and, unfortunately, the first message send still fails for every newly created socket. App build with Xcode 12.2 and run on iOS 14.2. Here is the test app by the way: https://github.com/acostarz/cfsocket_first_message Regards, Aurélien.
Nov ’20
Reply to iOS 14 Local Network Privacy
Hi Doive, We've indeed investigated furthermore with Quinn through the DTS incident ; he has reproduced the issue and filed a radar for the engineering team. It seems it's a difference of libraries used by Xcode 12 and previous versions of Xcode that brings this regression. What we've observed using Xcode 12 is that the first message you send to a newly created CFSocket always fails, even if the user has already authorised the app to access the local network. The very same code works fine when built with Xcode 11. As it was the case for my app, I made two workarounds ("ceinture et bretelles" as we say in France): I reuse the same CFSocket as much as possible. Your app will have to be aware of network state changes and of switches between background and foreground in order to destroy / create the CFSocket, otherwise it will fail to send messages. If a send fails, I always try it again once Quinn also confirmed me that, for the time being, CFSockets can still send multicast requests even if you have not (requested, obtained and) included the Multicast entitlement to your app. But, as it's considered a bug, we have to be prepared for a later iOS 14 update where this entitlement becomes required even when using CFSockets. Hope it helps, Aurélien.
Nov ’20
Reply to iOS 14 Local Network Privacy
Hi Quinn and thanks again for your time. I opened a DTS incident, here is the follow-up : 747881523. Meanwhile, I checked the errno and it's equal to 65 (<No Route to host> I presume) right after the call to CFSocketSendData fails. It seems the route to the UPnP host:port (239.255.255.250:1900) cannot be established. Finally, I also observed that I don't reproduce the issue when building the app with xcode 12 and running it on an iPhone 6+ with iOS 12.4.8. So far, the issue only occurs with the most common configuration: xcode 12 and a device on iOS 14.
Sep ’20
Reply to iOS 14 Local Network Privacy
Thanks Quinn for your quick response. Actually I do define NSLocalNetworkUsageDescription in Info.plist as our app also uses the GoogleCast SDK. The LNA system popup is properly displayed with our message the first time the app (or GCK) accesses the local network. So if the system does not require the multicast entitlement yet, there would be no reason for the app built with xcode 12 to fail to use BSD sockets, whereas the very same code built with xcode 11.6 works fine (which I've just confirmed with my MBP still using xcode 11.6). If the change of behaviour you mentioned is confirmed, do you think this is a bug? If so, shall I file a bug to Apple? And do you think there's a chance for it to be fixed in the future? Finally, as my problem could have a totally different cause, do you have any hints to share to help me debug the CFSocketSendData call returning an error? Thanks again.
Sep ’20