'allowedFileTypes' was deprecated in macOS 12.0: Use -allowedContentTypes instead

9 min read

Starting from macOS 12.0, the 'allowedFileTypes' property has been deprecated and replaced with the 'allowedContentTypes' property.

The 'allowedFileTypes' property was used to specify the file types that an application could open or save. However, it has now been deprecated in favor of the 'allowedContentTypes' property, which provides a more flexible and comprehensive way to specify acceptable content types.

To update your code, you should replace the usage of 'allowedFileTypes' with 'allowedContentTypes' in any relevant APIs or methods. For example, if you were using the NSOpenPanel class to open files, you would replace:

panel.allowedFileTypes = ["jpg", "png"]

with:

panel.allowedContentTypes = ["public.image"]

In this case, we are using the Uniform Type Identifier (UTI) 'public.image' to represent image files.

By using 'allowedContentTypes', you can specify a wide range of content types using UTIs or MIME types, allowing for more fine-grained control over the accepted file types.

Make sure to check the Apple Documentation for the specific APIs you are using to determine if 'allowedFileTypes' has been deprecated and replaced with 'allowedContentTypes' to ensure compatibility with macOS 12.0 and above.