Posts

Post marked as solved
6 Replies
2.7k Views
Hi, Many developers are working behind a company proxy and Xcode doesn't seem to pick up the system's settings (either with automatic or manual configuration). It makes it impossible to use SPM as Xcode is not able to fetch dependencies, getting very regularly the error message "No Route to host (-1)". I came across some workaround like changing the java config to use the system's settings or modifying the java exec used by Xcode to specify the proxy, but Xcode 14 doesn't seem to use java anymore (or at least I can't find where the config is located now). I also tried to set the JAVA_TOOL_OPTIONS env variable with my proxy details and with java.net.useSystemProxies=true, with no luck. Is there any way to configure the proxy within Xcode ? As anyone managed to make Xcode and SPM work behind a company proxy? I'd really appreciate some help. Thanks!
Posted Last updated
.
Post not yet marked as solved
0 Replies
706 Views
iOS 16 introduced a new API for forcing orientation changes, which implies using the requestGeometryUpdate(_:errorHandler:). It seems that it's not working as expected when using a full screen modal. For example, let's say we have an app that locks the orientation in portrait mode except for a modally presented controller, a parent controller A and a modal controller B : A is displayed We put the device in landscape mode - A stays in portrait mode B is opened modally fullscreen from A B is displayed in landscape B has a button to go back to portrait mode using the requestGeometryUpdate(_:errorHandler:) B is dismissed through a button A ends up in landscape In the app delegate, we used supportedInterfaceOrientationsFor to force the app in portait mode except for the controller B. We tried to call setNeedsUpdateOfSupportedInterfaceOrientations every time we call requestGeometryUpdate(_:errorHandler:). We also tried to call it on the viewWillAppear from the controller A. We finally tried to call requestGeometryUpdate(_:errorHandler:) from the controller A's viewWillAppear, without any luck as well. Is this a bug in iOS 16 or are we missing something ? It seems to be working as expected when displaying the modal over the current context, but it's not what we want in this case. I can provide an example project if needed.
Posted Last updated
.
Post not yet marked as solved
1 Replies
927 Views
I'm encountering a strange behaviour with List when using section and either task or onAppear. Let's say I have a list with sections and rows in each section. When I put a task to run a async task when each row appears, it doesn't call it even though it's displayed on screen. The same problem applies when using onAppear instead of task. It's easily reproducible with the given example. You can just run and scroll down to the bottom. You'll notice that the onAppear for the last row isn't called despite the row and the section is on screen. struct ContentView: View {  private var dataSource: [Int: [String]] = (0..<30).reduce([Int: [String]]()) { result, key in   var result = result   let items = (0..<4).map { "Item \($0)" }   result[key] = items   return result  }  var body: some View {   List {     ForEach(Array(dataSource.keys), id: \.self) { section in      let rows = dataSource[section]      Section {       ForEach(rows ?? [], id: \.self) { row in        let text = "\(section)-\(row)"        Text(text)         .onAppear {          print("ROW ON APPEAR \(text)")         }       }       .onAppear {        print("ON APPEAR \(section)")       }      } header: {       Text("Section \(section)")      }     }   }  } } Does anyone have an explanation ? Am I missing something ? As is my understanding of the documentation, onAppear should be called every time the view appears on screen. The interesting thing is that is seems to work fine when they're no sections.... Could it just be a bug in SwiftUI? I managed to fix this problem by using a ScrollView which embeds a LazyVStack, but by doing so I'm loosing some of the features from List, such as swipe to delete.
Posted Last updated
.
Post marked as solved
1 Replies
1.3k Views
Given I have a standard background URLSession and URLSessionDownloadTask, as below (I deliberately simplified the code for the sake of the example): let sessionConfig = URLSessionConfiguration.background(withIdentifier: "mySessionID") sessionConfig.isDiscretionary = false sessionConfig.sessionSendsLaunchEvents = true self.urlSession = URLSession(configuration: sessionConfig, &amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9; delegate: self, &amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9; delegateQueue: nil) let task = urlSession.downloadTask(with: url) task.resume() It seems that enabling/disabling Background App Refresh (Settings =&gt; General =&gt; Background App Refresh) changes how URLSession and its delegate behave. When background app refresh is on, the OS wakes up my app in background and call the delegate methods as described in Apple's documentation, - https://developer.apple.com/documentation/foundation/url_loading_system/downloading_files_in_the_background which allows me for example to move my downloaded file in the Photo library. When background app refresh is off, the delegate methods are never called while the app is in background. They are however called when the app the user puts the app back in foreground. The code running in both scenarios is the same, it implements URLSessionDownloadDelegate in a manager and application(_:handleEventsForBackgroundURLSession:completionHandler:) in the app delegate. I can't find any official documentation from Apple stating this is true. Background app refresh is only supposed to have an effect on the Background App Refresh API (which allows you to use background fetch and background processing). Has anyone been able to download a file in background and move it in background with Background App Refresh turned off?
Posted Last updated
.