Post

Replies

Boosts

Views

Activity

How to get true orientation when iOS device uses rotation lock?
Using AV Foundation to take photos, and I have the age old issue now of users locking rotation in portrait, turning the device, and taking a landscape photo. StackOverflow is filled with suggestions on using the accelerometer etc to monitor device changes. Wow - that's a lot of work. Isn't there anything in iOS 13 or 14 that will return the actual device orientation? Something like: 	UIDevice.current.actualOrientation Sure would be nice! Not hopeful for an answer, but hey maybe something changed in the last few years. David
0
0
460
Aug ’20
Do background upload tasks have the same rate limiter as download tasks?
The Apple documentation for background downloads contains this paragraph: Use Background Sessions Efficiently When the system resumes or relaunches your app, it uses a rate limiter to prevent abuse of background downloads. When your app starts a new download task while in the background, the task doesn't begin until the delay expires. The delay increases each time the system resumes or relaunches your app. As a result, if your app starts a single background download, gets resumed when the download completes, and then starts a new download, it will greatly increase the delay. Instead, use a small number of background sessions — ideally just one — and use these sessions to start many download tasks at once. This allows the system to perform multiple downloads at once, and resume your app when they have completed. My question is, if I'm using the background task for uploads, does the same rate limitation apply? David
1
0
562
Aug ’20
URLSession has many scheduled tasks, in what order do they execute?
URLSession (background, if it matters), is configured to only allow two connections to a host. Say a dozen are created, and after each is created it's told to "resume". The first two should start immediately, since the session is allowed two, and there are 0 or 1 when the task is resumed. But how about the other 10 that were told to resume too - is the order they get scheduled in random, or deterministic? David
1
0
447
Aug ’20
How to transition file upload when App backgrounded?
Situation: App has several huge files to upload to a server. User starts upload in foreground, get tired watching the slow progress, and backgrounds the app do web surf. I've been looking at "tus" (resumable uploads) and coming up with all kinds of crazy schemes, and sitting back and rethinking this, I'm now wondering if I have overcomplicated the solution. What appears now to be the simple and easiest solution is to create a background URL Session while in the foreground, set "isDiscretionary" to false (want uploads to start immediately), then create some upload tasks and using the session delegate, watch the progress. If the app backgrounds, then iOS will continue them with "isDiscretionary" still true (subject to internal constraints). Obviously no more progress delegate calls (no delegate!) When upload tasks finished, the system will message me. I can even add more tasks at that point if I want. If the task comes back into the foreground during the upload, I can reconstitute the session config, add myself back as a delegate and then I'll start seeing the delegate session messages again. The above may sound simple and self apparent, but really, I've read many articles on using background sessions and haven't seen the use case of initiating them in the foreground and having the app switch back and forth between foreground and background. Would really appreciate knowing if what I postulated above is correct or not. As an aside, I was going to use the "tus" Concatenation API, break the big file into chunks, start sending the chunks in foreground, if moved to the back, cancel any partial uploads, then re-submit uploads to a background task. Complex and if the above works, totally unneeded. David
1
0
932
Aug ’20
Document's folder data backed up to iCloud, why and how to view?
Started working on a five year old app, and iCloud backup concerns suddenly came into focus. This app creates huge image files, which appear are saved directly in the Documents folder with no apparent ExcludedFromBackup attribute (just searched the code base). 1) Benefits Suppose the iOS device with a large number of images on it gets dropped in a pail of water and dies. Then the owner buys a new device, and does a restore. I believe any files in the Document folder that are NOT excluded will now exist on any restore to a new device. This would appear to be the core benefit of letting iOS backup those images. 2) How to view? Without writing code to examine all files in the Documents folder, it would be really nice to determine what files, and their sizes, exist in iCloud for the app under question. I'll guess this just isn't possible - but asking in case there is some way, I'd love to know it (and I searched google a long time before posting this question). David PS: iCloud Drive my only option for a related Tag
0
0
370
Aug ’20
Indicate offset to Background URL file upload session?
I'm looking at using "tus" to upload large files. This protocol allows for pause and resume. My thought is to start the upload in the foreground while the app is running. But its going to take 10 minutes and the user is bored, so they background the app. At this point, the app has sent say 100M of data (using fileUpload with a normal URLSession). I have 30 seconds to get some background task going, so what I'd like to do is submit the file upload to a URL Session, and indicate (through some magic property) that I want the upload task to use a Range of data in the file, not the whole file. Is this possible? The problem is that otherwise, I have to just send the whole file, or duplicate the file more or less with the first 100M not duplicated. These are close to 1G file so prefer not to do that. Ideas most welcome!
3
0
707
Aug ’20
Will new SwiftUI features back port to iOS13?
I really really really want to write some new features for my company's app using SwiftUI. If I develop features using SwiftUI in Xcode 12, when iOS 14 is released, will that code be deployable to iOS13? If no, what won't back port? Would it just be the same as if I used Xcode 11? I can probably nudge my company to require iOS13 in the fall, but no way can I get them to require iOS14. David
1
0
713
Jun ’20
Possible to change a class name in framework binary?
My company's app is using the Objective C GVRSDK framework in their app (Google). This framework is no longer supported. It has a lot of classes, and one of them links to UIWebView, meaning in December we cannot submit new versions of our app. We don't use the UIWebView.Wondering if we can just "patch" the binary somehow, and change UIWebView to XXWebView, and provide our own class for that (which does nothing) so that the linker is happy.Is this possible, and if so, any tips on how we might do it?Thanks!David
1
0
781
Jun ’20
Instruments kills my App on device after 30 seconds
Xcode 11.4, iPad 9.7", latest iOSI have a memory leak. So I launch my app on my iPhone and if I do a set of operations the leak shows. Great.So I launch the app - its just sitting at the first screen. Nothing apparently is going on. I'm in the mini Memory view in Xcode. I tap the button to transfer it to Instruments, which is running already. It opens, and all looks good. Instruements starts updating everything.Thirty seconds later, boom, the app stops. The white box in Xcode is now gray. But when I go on the iPhone, it seems the app is still running - I can select its view in that app chooser, and its there. But Instruments has stopped.What am I doing wrong???I screen shot Instruments and my Scheme if it will help can put on dropbox etc.
3
0
729
Apr ’20
Please clarify Combine Demand usage
Combine has two related functions that support "demand", where Subscribers inform Publishers on the desired number of elements passed to them in a "receive" function. The below ignores infinite demand.1) func request(_ demand: Subscribers.Demand)Subscriptions provide this function, and as the Apple Docs say:"Tells a publisher that it may send more values to the subscriber."Matt Gallagher supposes in his excellent 22 Combine Tests article that each of these demands should be additive, and when the Subscription sends elements to the Subscriber, it decrements the count.2) func receive(_ input: Self.Input) -> Subscribers.DemandWhen a Subscriber receives data, it returns another demand, which the Apple docs state is:"A Subscribers.Demand instance indicating how many more elements the subscriber expects to receive."I have seen various interpretations on how these numbers relate, and I of course have my own that I'll postulate here.---A Publisher has a one element, and it gets a 'request(.max(10))' When it sends that to the Subscriber, and the return demand should be '.max(9)', a reminder to the Publisher (actually a Subscription created by the Publisher) that its expecting 9 more elements.If for some reason the Subscriber decides to send in another request for .max(10), and the Publisher gets one more element, and messages the Subscriber with that one element, the return will then be .max(18), meaning, Subscriber wanted 10, then it wanted 10 more, but it has only received 2.Alternate interpretations seem to be that the return from receive is additive to the running total. So any number other than 0 will increase what the Publisher can send.Would be super if anyone in the know could help clarify!!!
5
0
2.2k
Apr ’20
xcframework: how to wrap a static library?
This topic was touched on in the notes for the WWDC 2019 session on Binary Frameworks - I even watched the whole video but it wasn't covered there.It appears I should be able to wrap a static library - one that is created by its own (complex) build scripts - and have iOS, iOS Simulator and macOS versions. Also, that the header files can be included as well.I have been unable to find any information googling around on how one might do this. I would greatly appreciate any pointers to some blog/post that covers this.Thanks!
9
1
13k
Mar ’20
Swift Package Unit Test "Button" not working
I have a Swift Package, all Swift. I have a unit text file (XCTestCase). If I select "Test" using the button in the Window Title Bar, it works fine.If I select the diamond shaped button under the "Test Navigator", either the File Name itself, or a test within the file, Xcode acts like it ran the test, but there is no test console output - just this:Test Suite 'Selected tests' started at 2020-02-20 16:52:03.828 Test Suite 'SAX-CSV-ParserTests.xctest' started at 2020-02-20 16:52:03.829 Test Suite 'SAX-CSV-ParserTests.xctest' passed at 2020-02-20 16:52:03.829. Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds Test Suite 'Selected tests' passed at 2020-02-20 16:52:03.829. Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds Program ended with exit code: 0Is this a known problem with Swift Packages? Tried this with Xcode 11.3.1 and 11.4-beta2 - no difference.
0
0
608
Feb ’20