Posts

Post not yet marked as solved
0 Replies
285 Views
Most users of my app should be creating new documents in my app by importing existing files from an open-source file format through a conversion process into my proprietary format. While they could create files new from scratch in my app, that will cost $4M, and my customers are funded by donations. My app can read the open-source file format, but not write to it because it can't represent some of the information my customers need. I can also open read / write my own proprietary format. With my UIDocumentBrowserViewController-based MacCatalyst app it was possible to do an "import" from the open-source format, I would auto-run the conversion process, and the user could then immediately "save" the newly created file. Unfortunately, UIDocumentBrowserViewController has never worked correctly in MacCatalyst, and the Apple engineers know it and won't fix it. (I've demoed the problem to DTS 2 years ago, they had a bug fix in beta versions of macOS 12 which I'd been waiting for for 2 years, and I spent a month nights and weekends building my app to get it ready for release, but Apple removed the bug fix shortly before final release.) Users just think my app is broken. SwiftUI DocumentGroups with MacCatalyst don't seem to have the ui document browser bugs, so I'd like to re-write the top-level of the app with SwiftUI document groups. But how do I get the doc opened in the new format after export? I can't replace or delete the original open-source files, they have to remain unaltered in place. Help?! Also, one more thing. Because the open-source file format doesn't actually contain all the information my app needs (which is why I need the proprietary format in the first place), for 2/3 of the files files I'll need to get a second file in yet a second open-source file format and combine the data with the first open-source file in my initial conversion process to write out my proprietary file. This turns the $4M content-conversion problem into a $4k problem. This second file is optional for the user to pick, so I'll want to be able to proceed if they skip it. It took months to figure out how to get one .fileImporter to get used twice with different allowed file formats. (because you can't have 2 fileImporters......????.....) and now also I don't know how I'd capture that cancellation on the second import and proceed any way with the export. since the cancellation seems to just go into the ether. Workarounds I don't want you to offer me: Re-write everything in AppKit I don't want to write an AppKit version of my app, because of how text fields and scroll views work inside collection cells with drag & drop. UIKit makes it "just work". AppKit makes the UX a finicky nightmare people can take months to figure out how to use, and then feel frustrated with how hard it is once they do figure it out. And the issue goes all the way down into how events are assigned to views by the os. Be iPad-only Yes, my uidocumentbrowserviewcontroller code works perfectly well on iPads, and always has. I don't want to be iPad-only. Yes, I see iPads as better experiences for editing and content creation than a Mac, especially with an Apple Pencil with my painstakingly-crafted UIKit WYSWIG GUI editor. But for now, most of my customers have these files on Macs not iPads and they're probably not tech savvy enough to figure out how to move a complex file / folder structure of categorized files over from one to the other, so we work with what we got. Create a new document before beginning the import process What if users "open with..." one of the open-source files and pick my app? What if the file they pick to open in the doc browser is in the other format? I can't display the contents of the open-source file without first converting it into my format.
Posted Last updated
.
Post not yet marked as solved
1 Replies
790 Views
I thought it would be an easy way to add a custom mouse icon. I didn't see anything that said it wouldn't work. I followed the instructions to create a UIPointerInteraction for a custom view and set the delegate, add it to the view (which has other working interactions, including a hover gesture recognizer), return a region from the delegate method, and return a UIPointerStyle with a UIPointerShape with the +beamWithPreferredLength, but I saw nothing. My delegate methods weren't called. I tried disabling the hover recognizer, still nothing. The view's other interactions include drag, drop, and context menus. Xcode 12.5.1, mac os 11.6
Posted Last updated
.
Post marked as solved
9 Replies
1.9k Views
I've spent the last 1.5 years of my life trying to figure out how to make a uidocument-based app work with UIScene for MacCatalyst. Has anyone succeeded? Are there examples anywhere? Any guides or tutorials? Apple doesn't even have a template in Xcode! Apple's documentation is either fractured, missing or inaccurate. I always get crazy errors. The #1 problem I have is auto-re-opening a doc after the app quits. I get blank windows where the doc used to be, but on top of that I get an open-dialog box. Debugging says the os sees my sessions, but then throws them away and doesn't tell me why... When I quit the app, saving fails in sceneWillResignActive (with no explanation I can find), closing the document fails in sceneDidDisconnect(...) (with no explanation I can find), after the app quits the debugger stays running while profiler says my app is in the background, and then the watch dog timer expires and kills my app. I'm not doing any background work... I don't have any crazy long-running processes. At first I thought "oh, let's not write new features in AppKit, UIKit is soooo much easier, I'll just re-write the whole darn thing in MacCatalyst and then I can write new features for both Mac & iPad", but noooo. It's the fundamentals I can't get to work in MacCatalyst. The drag & dropping? works perfectly. But docs don't save - sometimes, and they don't reopen, but it all works perfectly on an iPad. :Picard facepalm:. I'm about to just give up trying to make apps entirely - and I've been doing it for 14 years!
Posted Last updated
.
Post not yet marked as solved
1 Replies
695 Views
My app imports files from a particular open standard that has a published Uniform Type Identifier (UTI). Recently, another mac app store app added some erroneous UTI declarations for files with the standard file extension for that file type. Using yet another app (non-app-store) to save data off in this common open file format, the system picked one of the erroneous UTI's from the app store app, and now my app and another (major gold-standard) app cannot open the file. Running mdls on the file reveals the kMDItemContentType is a wrong value, and of the 6 apps on my machine that can open and save that format, only the app from the store app is declaring the erroneous UTI value the system picked. Changing the file extension to something else and back to the right thing doesn't work. Changing the default app to open the file didn't work. How do I change the system's incorrect inference of the kMDItemContentType? How can my users do so? My app can't open the file (it's grayed-out in the file browser), but it can open other apps with the same file extension (which perhaps had their content-types set before the app store app with the erroneous definitions was updated to include erroneous definitions). Would merely deleting the offending app fix, or are these files permanently unopenable?
Posted Last updated
.
Post not yet marked as solved
1 Replies
962 Views
My app would significantly benefit from being able to identify sentences in text. So I'm trying NLTokenizer, since the api makes it looks like it could do that. I'm not able to obtain sentences as tokens. However, if I change the unit to words or paragraphs, I do get words and paragraphs respectively. Am I missing something or is this a bug? Here's some small example code: let source = "It was many and many a year ago, in a kingdom by the sea. \"Quiet\", said the raven." let tokenizer = NLTokenizer(unit: .sentence) tokenizer.string = source tokenizer.setLanguage(.english) print("begin") let tokens = tokenizer.tokens(for: source.startIndex..<source.endIndex).map({ range in return source[range] }) print(tokens) print("end") I expected to get: begin  ["It was many and many a year ago, in a kingdom by the sea.", "\"Quiet\", said the raven."] end But what I actually get is: begin [] end I found a blog where someone had claimed they had iterated the sentences using NLTokenizer, but when I examined his output, he had actually enumerated the words. macOS 10.15.6 beta 1
Posted Last updated
.
Post not yet marked as solved
0 Replies
495 Views
I'm hosting a booth at a few conferences this summer with demos of my mac app. I'd like to offer a small number of promo codes to people who visit the booth, fill out an application and meet some requirements that I think make them shoe-ins for being influencers, maybe 3 per conference. I'd announce it kind of like a contest, but the idea is they are people who are very interested and would promote the use of my app. I'd like to offer them something substantial to take with them that has the promo code on it, kind of like a gift card, so they don't forget "this is valuable". My first thought was actually give them a gift card, but that's silly because the whole point is no real money needs to get involved, and a real gift card could be used for things other them the in-app purchases in my app. Getting custom-printed plastic cards is the easy part. The hard part is what I put on it. Is there a way to display promo codes so that the gift card code scanner in the mac app store can read the promo code? Is all I have to do position the human-readable code in a mono spaced font in a box along the top edge like a gift card and it'll be recognized? Do we know what font the gift cards use? / Does it matter?
Posted Last updated
.
Post not yet marked as solved
1 Replies
978 Views
There is no documentation for Progress.estimatedTimeRemaining. I want to get an estimated time to completion from my Progress object, but in my experiments on macOS, it's always nil. What do I need to do to get a non-nil result?In my case, my progress var is periodically (once per second) updated from the var progress:Float field of a AVAssetExportSession.Here's what I've got now that's not working: (the progressIndicator is correctly updating) @IBOutlet weak var timeRemainingLabel:NSTextField? lazy var nsProgress:Progress = { ()-&gt;Progress in let prog = Progress(totalUnitCount: 100) return prog }() var progress:Float = 0.0 { didSet { progressIndicator?.doubleValue = Double(progress) nsProgress.completedUnitCount = Int64((progress*100.0).rounded()) if let time = nsProgress.estimatedTimeRemaining { timeRemainingLabel?.stringValue = timeFormatter.string(from: time) ?? "" } } } lazy var timeFormatter:DateComponentsFormatter = SongTitledFormSectionsTableCell.newDurationFormatter() static func newDurationFormatter()-&gt;DateComponentsFormatter { let formatter = DateComponentsFormatter() formatter.allowedUnits = [.second, .minute] return formatter }
Posted Last updated
.
Post not yet marked as solved
4 Replies
3.7k Views
In my app, users will usually want automatic syncing of a set of many hundreds of files with several members of a team, so mere personal iCloud just won't cut it. In my soon-to-be-released Mac app, that was easy. I just let the user pick a directory and use bookmarked security scoped urls, and if they pick a dropbox or google drive -synch'ed folder, fine; it just works. It even detects changes and animates my summary details of the set of files in my UI live.However, on iOS, I'm not sure whether UIDocumentPickerViewController can do what I want. When I initialize it like so:UIDocumentPickerViewController(documentTypes: [kUTTypeFolder as String, kUTTypeDirectory as String], in:.open)and run it, but when I delect a directory, the button isn't enabled to proceed.Can someone tell me IF UIDocumentPickerViewController is suppossed to be able to handle getting a book-markable url to a directory outside my sandbox?
Posted Last updated
.
Post not yet marked as solved
1 Replies
612 Views
My new macOS app will export large files. Often users like to export these files to the same directory. It's standard practice to set the directoryUrl on an NSSavePanel to the directory the user last used. That's different from suggesting the user export precisly the same file path as before, which is what Adobe Illustrator now does, and it drives me nuts.I could save the security scoped bookmark data to the final output url, and I do that for other purposes for other files. But that doesn't feel like the goal here. I tried the same thing on the parent dir of the output file, and it failed, which I expect is as intended, obviously, since the user did not provide access to the entire directory my app should not be able to access it.So my backup plan is to save merely the string of the directory, and create the URL for the save panel from that, ignoring everything around secuiryt and bookmarks, assuming the NSSavePanel will do something responsible and intelligent given the input.Does that seem like the right thing to do, or is the NSSavePanel perhaps already doing a better job of tracking directories that are useful to the user?
Posted Last updated
.
Post not yet marked as solved
0 Replies
582 Views
When testing on device with ios 13 beta 4 on an ipad.I obtained a URL for application support using:fileManager.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)which looks like/var/mobile/Containers/Data/Application/&lt;UUID&gt;/Library/Application%20Support/then, I append my main bundle identifier and a path component for my feature.I then use the file manager to iterate the contents of the directory.fileManager.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil, options: [.skipsHiddenFiles, .skipsPackageDescendants, .skipsSubdirectoryDescendants]however, the urls in the directory come out like/private/var/mobile/Containers/Data/Application/&lt;UUID&gt;/Library/Application%20Support/bundleid/feature/filename(with the extra /private in the front)Due to this, my code that extracts the relative path to the file from the directory fails.Why is this extra /private in the front? How do I get it to not be there, or be in the original dir?Is there a more reliable way to get a relative url knowing the container &amp; path?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
In the WWDC videos, they keep saying use `requestSceneSessionActivation` to activate a scene, and I have a scene configuration listed in my info.plist I'd like to activate, but I don't understand how to tell the method which scene to activate.Specifically, for a multi-document app, I'd need to activate scenes from "New" and "Open" menu commands in UIKitForMac. This would involve a UIDocumentBrowserViewController-based scene. In these cases, I can't just supply a file path in the activity, because the file path isn't known yet. Is there a way to specify the NSUserActivity type in the scene configuration in the Info.plist that i missed? Or maybe a way to invlude the scene configuration name in the user activity?It sure would be nice if they updated the document-based app templates to use scenes, you know, since it's a big deal and all.
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.6k Views
I am about to release a Mac app which (among other things) uses AVAssetExportSession to export a (potentially) massive video file after the user selects a URL from an NSSavePanel. These videos can take minutes to render, and take gigabytes of file space, so it needs to be asynchronus, and AVAssetExportSession demands a url to write to which does not already exist.I'd love to build an iOS version as long as it also runs on the Mac, i.e. UIKitForMac. Now that the iPad will support attached USB drives, it's more likely that someone could use the ipad app to import massive video files that could be used in my app &amp; then export the results back to the drive to share with another computer. Opening the existing video files in place seems doable with UIDocumentPickerViewController, but I'm unsure of how to properly export potentially massive files.Looking at the UIDocumentPickerViewController API, it looks like I can't export a file to outside the app sandbox unless the file already exists in the sandbox. This is a bad experience for the person who renders a 5 minute 4K video and won't know until after several minutes of rendering that they can't find where they need to save it (which is what normally happens to me when I use a UIDocumentPickerViewController!).It looks like I can save like a 1-byte file to a local url and retain security-scoped access to the exported URL and perhaps write more data to it. But AVAssetExportSession "just doesn't work" with pre-existing urls. So I'd have to render the entire video before picking where to save it, and potentially, there's not enough room on the ipad's internal storage for the original anyway. (Unless someone can tell me how to make AVAssetExportSession ok with overwriting an existing file.)The WWDC 2010 session 407 says "Well, an AVAssetExportSession will not let you overwrite an existing file, and attempting to do so will cause your handlerBlock to be called with a failed status. If you'd like to overwrite an existing file, you should remove the old one first. Perhaps you already know this, AVAssetExportSession will also not let you write two files outside of your application sandbox."So that looks hopeless. Or does a security-scoped url count as in my sandbox from the session's perspective? Does deleting the file still give me access to it a moment later?The other major option I see is UIActivityViewController, which seems like a good idea, since it might not only save as a file, but serve directly to other apps that might handle videos specifically. It supports UIActivityItemProvider, which lets me pick the export service first, and says it can do things asynchronously, but again, I'd have to write the file inside my sandbox with the AVAssetExportSession and then move it out. (boo). What I don't understand is how much fidelity do I need to put into the placeholder file? Does it only need the right file type (file extension), or do I need to write out a real movie in the same format as my final file in order for the system to understand what activities can share it?So.... What's the best practice on iOS to export potentially-massive videos files writing once to external storage, with the intention of replacing my Mac app which has no problem doing this with a UIKitforMac app?
Posted Last updated
.
Post not yet marked as solved
0 Replies
524 Views
Since Feedback Assistant is broken in Catalina beta 2, I'll drop this here.Setup:I'm about to release an AppKit app for Mac, but the vast majority of my code was written to be compatible with UIKit also (CoreGraphics, CoreText, AVFoundation, etc...), and since UIKit dev is so much easier, I'm beginning to convert my view/controller layer over to UIKitForMac.Specifically, while migrating my NSDocument subclass to become a UIDocument subclass instead, and had to adjust a couple of overrides to be a little different...I ran into an issue at run time where the log reported that +[MyTargetName.MyUIDocumentSubclassName readableTypes]: unrecognized selector sent to class 0x######### (4 times). Of course, +readableTypes is an NSDocument class property, not a UIDocument method. So I searched my entire project for any readableTypes calls, and there were none. The stack trace indicated it may be the system machinery calling this on the document subclasses it got from my info.plist document type declarations, which I had copy/pasted from the old AppKit version of the app. (I haven't checked to see if those need to change, so maybe you're assuming it should be an NSDocument based on the layout of those entries? I dunno.). As I understand it, AppKit would call an unrecognized selector a few times hoping someone might add it... so I don't know if this is actually causing a problem I haven't found yet. Certainly, it made determining that or why the UIDocumentBrowserViewController isn't working in beta 2 harder to track down.After I added a readableTypes method to my UIDocument subclass, I started getting another unrecognizer selector, something like _is_java_subclass? or I dunno, I'm back to running beta 1 now (so I can get stuff done) so I can't reproduce that.I don't know if this also happened in the beta 1 of catalina, since I had not finished migrating my NSDocument subclass to become a UIDocument subclass before I upgraded my mac to beta 2.
Posted Last updated
.
Post not yet marked as solved
5 Replies
1.6k Views
Since feedback assitant does not allow bug reports in beta-2, I'll drop this here.Howdy, I just installed Xcode 11 beta 2, and ran my slightly modified version of the UIDocumentBrowserViewController-based template app, which was working the last time I tried it. However, in Xcode 11 beta 2, in the iPad simulator, it no longer works. I have another app which uses the same template, but had been modified to click the checkbox and run for Mac, and it has the same trouble.Here are the error logs[DocumentManager] Failed to get the remote browser View Controller with error (Error Domain=NSCocoaErrorDomain Code=4097 "connection on anonymousListener or serviceListener from pid ####" UserInfo={NSDebugDescription=connection on anonymousListener or serviceListener from pid ####})[DocumentManager] Remote view controller crashed with error: Error Domain=NSCocoaErrorDomain Code=4097 "connection on anonymousListener or serviceListener from pid ####" UserInfo={NSDebugDescription=connection on anonymousListener or serviceListener from pid ####}. Trying to relaunch.Where #### is a pid which changes on each attempt (obviously).These error messages show up a few times in the logs, and then:[DocumentManager] The UIDocumentBrowserViewController view service crashed for too many times in a row.A search on the web indicates these are normally XPC related, and since the doc browser is "out of process" (I assume), I suspect that's the connection.When I re-open my projects in beta 1 and run in the beta 2 simulator, I get the same error. However, when I run in the beta 1 simulator, they work correctly.
Posted Last updated
.