Posts

Post not yet marked as solved
1 Replies
436 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.2k 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
359 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
678 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
348 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
713 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
2.8k 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
394 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
363 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.1k 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
1k 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
337 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.1k 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
.
Post not yet marked as solved
2 Replies
732 Views
My document format will include many media files, images, audio, &amp; videos. With simple data model changes, I just store my data for the undo stack in the closures that I store in the NSUndoManager. When we're talking about kilobytes, that's not an issue, even for 1000's of changes. But for media files, I don't want them stored in RAM because they're too big, but I'm not sure whether NSFileWrapper can handle undo automatically some how, or if I should manually throw them in a temp dir, or put them in an NSCache so old ones can be deleted or what?And since I'm going to need URL's to make the videos work (with AVFoundation, etc...) it seems like NSFileWrapper isn't a great way to move forward.What's the easiest to implement solution for package document with interal multimedia files with standard expected behavior here?
Posted Last updated
.
Post not yet marked as solved
6 Replies
8.3k Views
I have a growing collection of iOS crash reports (3 to 4 per day) which crash inside calloc or malloc, saying "EXC_BAD_ACCESS KERN_INVALID_ADDRESS" and then listing a pointer address which either looks like a tagged pointer, like0x0000000000000026, 0x000000000000001c, 0x000000000000005aor pointers that look suspiciously low, like0x0000000000000010, 0x0000000000000020, 0x0000000000000030.Stats say it's happening for 5% of users, we've only been able to trigger it in the office once, and the debugger wasn't attached. So I haven't been able to trap it with zombies, or address sanitizer.So my questions are:1) Are the 0x10, 0x20, 0x30 also tagged pointers? or just really low value real pointers, and thus likely a different problem?2) What could cause tagged pointers to actually get free'd so that they'd ever end up available for malloc or calloc? We do use both Obj-c and swift, but I thought the compiler would handle conversions between obj-c tagged objects like NSNumber's and NSDate's and swift types. Could a lack of @objc on an extension's override of a protocol method cause the conversion to not happen? Should I be looking into code that accidently calls CFRelease on an NSNumber or NSDate? I don't have any -f-no-arc files in the project, but I do have a few pre-compiled 3rd party libraries in the app.2b) Which other NSObject subclasses can be tagged pointers?3) How do I discover where the instance was allocated, or where it was free'd without either releasing the modified app to production and without having it hooked up to the debugger? I can have our qa person tap the app incessantly, but it would work better if we had a way to capture the addresss sanitizer or zombie output and send it up via fabric crash reports? Can I catch the contents that zombies or address sanitizer would normally print to the console and include it in the crash report? I have a synchronous way to add arbitrary lines of text to the crash report if I can intercept it before crashlytics gets it, but my experience with that is limited to intercepting NSExceptions, and this is way deeper than NSException.3b) Is there maybe a way to get it to crash when the bad value is free'd instead or reused so our internal qa builds can at least narrow down the scope of what got released wrong, instead of "literally maybe anything"?
Posted Last updated
.