Uniform Type Identifiers

RSS for tag

The Uniform Type Identifiers framework provides a collection of common types, and maps them to MIME and file types.

Posts under Uniform Type Identifiers tag

11 Posts

Post

Replies

Boosts

Views

Activity

Unexpected bundle class 16 declaring type public.gpx
I have a minimal macOS document based app written in SwiftUI in Xcode 16.3. It is created from the standard template replacing all occurences of 'com.example.plain-text' with 'com.topografix.gpx' and changing the file extension in info.plist from 'exampletext' to 'gpx'. Those changes are sufficient to allow opening, editing and saving of .gpx files. However, when opening, editing or saving, the following message is written to the console 6 times. Unexpected bundle class 16 declaring type public.gpx While this is not preventing the app from working, I would like to understand the origin of the message and fix the underlying problem.
1
0
178
Aug ’25
UIDocumentPickerViewController in Audiounit Extension unable to receive touches
Hello, I have an existing AUv3 instrument plugin. In the plug in, users can access files (audio files, song projects) via a UIDocumentPickerViewController In Logic Pro, (and some other hosts, but not all), the document picker is unable to receive touches, while a keyboard case is attached to the iPad. Removing the case (this is an Apple brand iPad case) allows the interactions to resume and allows me to pick files in the usual way. One of my users reports this non-responsive behavior occurs even after disconnecting their keyboard. I have fiddled with entitlements all day, and have determined that is not the issue, since the keyboard disconnection appears to fix it every time for me. Here is my, very boilerplate, presentation code : guard let type = UTType("com.my.type") else { return } let fileBrowser = UIDocumentPickerViewController(forOpeningContentTypes: [type]) fileBrowser.overrideUserInterfaceStyle = .dark fileBrowser.delegate = self fileBrowser.directoryURL = myFileFolderURL() self.present(fileBrowser, animated: true) {
2
0
482
Jul ’25
MIDI Drag-and-drop to Logic Pro via NSItemProvider
Logic Pro recently changed the way it accepts drag and drop. If the ItemProvider contains UTType.midi, then Logic Pro shows visual feedback for the drop operation, but when the item is dropped, nothing happens. In the past, drag-and-drop used to work. With today's version (Logic Pro 11.2), the only way I was able to successfully drop MIDI was to provide UTType.fileURL and no other data types. But that's not a viable solution; I need other data types to be included too. As a side note, I tested with Ableton Live 12 and it works with no issue. Is this a bug in Logic Pro? What ItemProvider structure does Logic Pro expect to correctly receive the MIDI data?
3
0
89
Jul ’25
Defining custom file types
On iOS:When one receives a file of type .pages by email, Mail displays a large Pages icon and tapping on it opens Pages. (A long-press brings up the more complicated Actions screen).When one receives a file of type .vcf by email, Mail displays a large Contacts icon and tapping on it opens Contacts. (A long-press brings up the more complicated Actions screen).I have my own custom file type, .ripf, and I want to have the same behaviour because that is what my users will expect. Accordingly, in my app's Info.plist I have a CFBundleDocumentTypes dictionary providing a one-element LSItemContentTypes array referring to the name 'com.universalis.ripcard', and a UTExportedTypeDeclarations dictionary associating the UTTypeIdentifier 'com.universalis.ripcard' with a public.filename-extension 'ripf' and a public.mime-type 'text/vnd.universalis.ripcard'. All the other entries in those two dictionaries are present and correct as far as I can tell. Both CFBundleDocumentTypes[0].CFBundleTypeIconFiles and UTExportedTypeDeclarations[0].UTTypeIconFiles contain a list of icon files for the file type.(That rather long paragraph is to avoid boring people by including the entire Info.plist!)Some things do work..ripf files received via AirDrop bring up a suitable "Open with..." message which mentions my app, and tapping the message opens the app..ripf files received as an email attachment display as an icon. But it is the app's icon and not the icon of the file type.BUTTapping on a received file's icon does not open the app, but only opens the generic Actions screen, offering Message, Mail, WhatsApp, Notes, and only then (after the user has scrolled sideways) "Copy to..." my app.Now, the whole apparatus of CFBundleDocumentTypes and UTExportedTypeDeclarations is obscure and under-documented, and indeed the main documenation for the latter has a big warning at the top saying that it is obsolete and not being updated. That doesn't matter so much. What I need to know is:(Less important): How do I get the right file icon?(More important): How do I get my app to open when the icon is tapped, as Pages and Contacts do? There must be a way – unless special cases for those two apps are wired into iOS itself.
10
0
6.4k
Apr ’25
Can't open p12 file inside my application
I need to open p12 file from other iOS applications to import private key to my application. My app is set up to be able to open nay file with following plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>Files</string> <key>LSHandlerRank</key> <string>Default</string> <key>LSItemContentTypes</key> <array> <string>public.item</string> <string>public.data</string> <string>public.content</string> </array> </dict> </array> </dict> </plist> But my don't appear in share dialog from Files or Mail app for example. There are however other third party apps that can accept this file. Some of them use Share extension which I don't have, but some of them don't have it as far as I can understand. At least they don't present any UI and open apps directly. Also I've tried to specify com.rsa.pkcs-12 UTI directly but it didn't help. Also noticed that *.crt files have similar behaviour. Am I missing something about this specific file type?
1
0
69
Apr ’25
Troubles with CFBundleDocumentTypes and photos
I'm working on adding CFBundleDocumentTypes to my Info.plist so that a user can share an image from other apps on their device and have it open inside my iPhone app. I seem to be able to get this to work for sharing a single photo from the Photos app, but not for (1) multiple photos from the Photos app or (2) images from Safari. One thing that makes this difficult is that my changes to Info.plist sometimes have no effect. I can remove CFBundleDocumentTypes and still see the icon, for example. Or I can add a new accepted UTI, but it has no effect. I've tried cleaning and rebuilding, deleting and reinstalling the app...no success. I tried in the simulator, too, and even Erase Content and Settings didn't force changes to be applied. I'm not sure what else to try here. Anyway, I'd like my app to appear in the Share sheet for photo(s) from the Photos app, Mail and Safari, in particular, but really from any app that supports sharing photos. I can share the config that seemed to work, but since changing it doesn't always have an effect, I can't guarantee that this was the one that worked. At the moment, it doesn't work, but I'm not sure why. Here it is: <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array/> <key>CFBundleTypeName</key> <string>Image</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>public.data</string> <string>public.jpeg</string> <string>public.png</string> <string>public.image</string> <string>public.gif</string> <string>public.url</string> <string>public.content</string> </array> </dict> </array> <key>LSSupportsOpeningDocumentsInPlace</key> <true/> In my code, I also defined the following method in my SceneDelegate (though I think the problem is just with Info.plist): func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { Here are my questions: How do I make sure that my changes to Info.plist apply? Is there a cache somewhere that I have to force to clear? This is the trickiest part of this, because I can't reliably try an experiment and see if it worked. Adding the specific image UTI’s (public.jpeg, public.png) seemed to help, even though those types should conform to public.image, which conforms to public.data and public.content. Is it actually necessary to specify those? If the user selects multiple photos in the Photos app, my app doesn’t appear, but other third-party apps on my phone do. How can I support multiple photos? This configuration doesn't reliably show my app for Safari images - what do I need to do to make that happen? I had to use “public.data” when I briefly had Safari sharing working, but there doesn't seem to be a way to get a UTI from UIOpenURLContext. Right now, my code just tries to load the data as an image and aborts if UIImage(data:) returns nil. Is this a safe way of doing this? Is there a way to get the UTI for the data?
2
0
663
Jan ’25
transferRepresentation for AppEntity containing parameters of multiple types
I have an App Intent that returns a MyEntity value with the following properties: struct MyEntity: AppEntity { @Property(title: "Title") var title: String? @Property(title: "Image") var image: IntentFile? } I created a Shortcut that takes the output value of this intent and passes it as the input to the Send Message action. When I tap the MyEntity parameter in the message action, it shows to be of Type MyEntity. Below that, I can select 1 of 3 options: MyEntity, Title, or Image. When I run the shortcut, a new message compose window appears with the following behavior depending on the selected option: MyEntity - the message draft is empty Title - the message draft shows the title string Image - the message draft shows the image My expected and desired result when MyEntity is selected would be a message draft populated with the image and the title string as text. How would I achieve this? Is it possible? I've experimented with conforming MyEntity to Transferable. That's enabled use cases such as passing the MyEntity input as Type Image for example. Do I need to create a custom UTType to represent MyEntity, or is that unrelated to my issue? I haven't explored this yet but seems potentially related!
0
0
380
Jan ’25
How to save/share an iOS system screenshot to the active app?
I have my app accepting images shared from Photos but from the screenshot editor, my app icon does not show as a destination for the screenshot. Do I have to build an app extension or app intent catcher to then pass along the screenshot? It the problem that the screenshot editor is a modal sheet holding my app interface. I want to catch the screenshot in background for processing.
2
0
490
Dec ’24
Bug with Transferable + AppEntity
Hello all, I'm finding myself with a compile error when trying to use a defined UTType for Transferable conformance when the type is also an AppEntity. The compiler error is Could not determine the identifier of `.todo`. Please use a UTType defined by the UniformTypeIdentifiers framework However, said compiler error only shows up after adding AppEntity conformance. So, in order to reproduce: Create any type, conform to Codable struct Todo: Codable { var id: UUID var title: String var completed: Bool } Create a UTType extension for the new type extension UTType { public static let todo: UTType = UTType(exportedAs: "org.nameghino.types.todo") } Add Transferable conformance extension Todo: Transferable { static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .todo) ProxyRepresentation(exporting: \.title) } } At this point, the code compiles correctly on Xcode 16.2 beta 2 (16C5013f) Add AppEntity conformance extension Todo: AppEntity { static var typeDisplayRepresentation: TypeDisplayRepresentation = "todo_title" static var defaultQuery = Todo.Query() var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(title)") } struct Query: EntityQuery { typealias Entity = Todo init() {} func entities(for identifiers: [UUID]) async throws -> [Todo] { return [] } func suggestedEntities() async throws -> [Entity] { return [] } } } Now the code is not compiling with the aforementioned error.
3
1
610
Dec ’24
`SwiftUI.FileExportOperation.Error error 0` with `fileExporter` and `NSImage`
You'll have to forgive me, I am still pretty new to Swift, but I'm really struggling to figure out what I'm doing wrong or how I can fix it. I'm working on an app that generates an image from some views and then exports that image, but it always returns this very vague error: The operation couldn’t be completed. (SwiftUI.FileExportOperation.Error error 0.) Here's most of the program: import SwiftUI import UniformTypeIdentifiers struct ContentView: View { @State private var backgroundColor = Color.black @State private var fileExporterIsPresented = false @State private var image: NSImage? @State private var fileExporterErrorAlertIsPresented = false @State private var fileExporterErrorDescription: String? var body: some View { let wallpaper = Rectangle() .foregroundStyle(backgroundColor) .aspectRatio(16 / 9, contentMode: .fit) VStack { wallpaper .clipShape(.rect(cornerRadius: 10)) .overlay { RoundedRectangle(cornerRadius: 10) .strokeBorder(.separator, lineWidth: 5) } ColorPicker("Background Color", selection: $backgroundColor, supportsOpacity: false) Button("Generate Wallpaper") { let renderer = ImageRenderer(content: wallpaper.frame(width: 3840, height: 2160)) image = renderer.nsImage fileExporterIsPresented = true } .fileExporter( isPresented: $fileExporterIsPresented, item: image, contentTypes: [UTType.heic, UTType.png] ) { result in if case .failure(let error) = result { fileExporterErrorDescription = error.localizedDescription fileExporterErrorAlertIsPresented = true } } .alert("File Exporter Failure", isPresented: $fileExporterErrorAlertIsPresented, actions: { Button("OK") {} }, message: { if let fileExporterErrorDescription { Text(fileExporterErrorDescription) } }) .dialogSeverity(.critical) } .padding() } } #Preview { ContentView() }
1
0
660
Nov ’24