Post

Replies

Boosts

Views

Activity

Reply to Xcode 12 is slow when launching apps (even sample projects)
Still a problem. Xcode Version 12.0 (12A7209) Per advice here, I deleted the iOS 14 folder inside ~/Library/Developer/Xcode/iOS DeviceSupport.   (My iPhone is now on 14.0.1, so I left the 13.7 folder alone.) It took a long time for Xcode to "copy cache files" from the iPhone but once that finally got done, normal build-and-run behavior is back. Nice and snappy.
Oct ’20
Reply to How to use BGAppRefreshTask without server update?
It's true that the typical BG update involves a URL session to get web data, but it doesn't have to. In the App Delegate, you need to set up your app. Here is the code I have in my didFinishLaunchingWithOptions in my app delegate: (Note that self.logSB is my logging, similar to a Print command.) &#9;&#9;&#9;&#9;switch UIApplication.shared.backgroundRefreshStatus {         case .available:             self.logSB.debug("backgroundRefreshStatus is AVAILABLE")         case .denied:             self.logSB.debug("backgroundRefreshStatus is DENIED")         case .restricted:             self.logSB.debug("backgroundRefreshStatus is RESTRICTED")         default:             self.logSB.debug("backgroundRefreshStatus is unknown")         }         if #available(iOS 13.0, *) {             self.logSB.verbose("iOS 13  Registering for Background duty")             BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.WH.myApp.myIdentifier", using: nil) { task in                 self.handleAppRefresh(task: task as! BGAppRefreshTask)                 self.logSB.verbose("iOS 13  Refresh requested")             }         } else {             self.logSB.verbose("iOS < 13  Registering for Background duty")             UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)             //                UIApplication.shared.setMinimumBackgroundFetchInterval(200)         } You can also see that I support the older background session method. That's what my app started with before iOS 13 came along. You could probably drop that. Up at the AppDelegate class level: &#9;&#9;&#9;&#9; var backgroundSessionCompletionHandler: (() -> Void)? &#9;&#9;     var backgroundSynchTask: UIBackgroundTaskIdentifier = .invalid The pre-iOS 13 fetch:     func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {         let dateFormatter = DateFormatter()         dateFormatter.dateStyle = DateFormatter.Style.medium         dateFormatter.timeStyle = DateFormatter.Style.long         var convertedDate = dateFormatter.string(from: Date())         if #available(iOS 13.0, *) {             self.logSB.info("iOS 13 Ignoring Background Fetch called at \(convertedDate)")             completionHandler(.newData)         } else {             self.logSB.info("Background Fetch called at \(convertedDate)")             let myState = UIApplication.shared.applicationState             switch myState {             case .background :                 self.logSB.info("The app state was found to be Background at \(convertedDate)")             case .inactive:                 self.logSB.info("The app state was found to be Inactive at \(convertedDate)")             case .active:                 self.logSB.info("The app state was found to be Active at \(convertedDate)")             default:                 self.logSB.info("The app state was found to be Unknown at \(convertedDate)")             }             Central().fetch {                    convertedDate = dateFormatter.string(from: Date())                 self.logSB.info("Calling the Fetch completion handler at \(convertedDate)\n\n")                 completionHandler(.newData)             } &#9;&#9;&#9;&#9;}     } The Central().fetch function is what goes and gets current web data, but it doesn't have to. It could be anything. And finally:     func applicationDidEnterBackground(_ application: UIApplication) { &#9;      let dateFormatter = DateFormatter()         dateFormatter.dateStyle = DateFormatter.Style.medium         dateFormatter.timeStyle = DateFormatter.Style.long         let convertedDate = dateFormatter.string(from: Date())         self.logSB.info("The app entered the background at \(convertedDate)")         if #available(iOS 13.0, *) {             scheduleAppRefresh()         }     }     @available(iOS 13.0, *)     func scheduleAppRefresh() {         logSB.info("Scheduling the AppRefresh in iOS 13 !!")         let request = BGAppRefreshTaskRequest(identifier: "com.WH.myApp.myIdentifier")         request.earliestBeginDate = Date(timeIntervalSinceNow: 2 * 60)         do {             try BGTaskScheduler.shared.submit(request)         } catch {             logSB.error("Could not schedule app refresh: \(error)")         }     }     @available(iOS 13.0, *)     func handleAppRefresh(task: BGAppRefreshTask) {         logSB.info("Handling the AppRefresh in iOS 13")         scheduleAppRefresh()         let queue = OperationQueue()         queue.maxConcurrentOperationCount = 1         let appRefreshOperation =  Central().fetch2         queue.addOperation(appRefreshOperation)         let lastOperation = queue.operations.last         lastOperation?.completionBlock = {             task.setTaskCompleted(success: !(lastOperation?.isCancelled ?? false))         }         task.expirationHandler = {             queue.cancelAllOperations()         } &#9;      let dateFormatter = DateFormatter()         dateFormatter.dateStyle = DateFormatter.Style.medium         dateFormatter.timeStyle = DateFormatter.Style.long         let convertedDate = dateFormatter.string(from: Date())         self.logSB.info("Completed the iOS 13 App Refresh at \(convertedDate)")     } 
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’20
Reply to Why "would [my app] like to find and connect to devices on your local network"?
SOLVED !! I gave up trying to figure out what was triggering the alert. So to clear Review, I relented and added the info.plist item: Privacy - Local Network Usage Description ...|... String ...|... "my text" Guess what? That squelches the alert entirely! My alert text is never seen. My app is not added to the list of apps that have asked for Local Network access. This fixed both of my affected apps. Seems like a bug. Agreed?
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’20
Reply to Why "would [my app] like to find and connect to devices on your local network"?
If I were in your shoes I’d: Set up a test device running iOS 14. Reset the alert state (FAQ-13). Run and exercise its functionality to see if you can trigger the alert. OK, I've done that and discovered that both my apps, once installed after updating to iOS 14, trigger the alert. So, does accessing data on the web - in a URLSession or by using SafariServices - trigger the alert? The presentation implies that it does not but your (very useful) list leads me to wonder. The only other thing I can think of is that both my apps determine the user's location. It seems like this should be handled fully by the location privacy setting?
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’20
Reply to Why "would [my app] like to find and connect to devices on your local network"?
I just discovered that my app had "Application supports iTunes file sharing" set to "YES". No idea how that happened. I've turned it off. Could that do it? I can't reproduce the problem except by submitting another build for review. [update] Another app of mine has the same setting turned on and there is no alert problem with that app. I gather it's a default setting. I've also discovered that my troubled app contained some c code with print statements. That particular code never executes (and I've deleted it). Could a print command that never runs cause the app to go look for a printer?
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’20