I’m trying to get my iOS app to load files with a custom extension.
I have the following CMake settings:
DOCUMENT_BROWSER_ENABLED TRUE
DOCUMENT_EXTENSIONS mycustomtype
I can save the files fine, but when I try to load them, they’re greyed out and disabled.
Do I need to set anything up in Xcode, or am I missing some other CMake settings?
This is where I was at this morning, so am very interested in any solutions. If I use the native browser on IOS the file is created with a zero size, and the stream fails to open for writing, If I use the juce browser I can both save and load. If I revert to the iOS browser to load, the files have a size but appear greyed out.
I tried setting the filePatternsAllowed
to an empty string, which seems to work.
I also had to remove the following flags, so it only has juce::FileBrowserComponent::openMode
:
juce::FileBrowserComponent::canSelectFiles
juce::FileBrowserComponent::canSelectDirectories
juce::FileBrowserComponent::canSelectMultipleItems
I’ll see if I can get it to read only the file extension I want within the Xcode / Plist settings…
Ok so the answer is in some extra settings in Xcode, as well as the above re: flags.
After setting up in the Xcode UI I copied and pasted the relevant parts of the info.plist
file.
This is what it looks like in CMake:
if (IOS)
set(CUSTOM_PLIST "<plist>
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>myfileext</string>
<string>myotherfileext</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>Icon</string>
<key>CFBundleTypeName</key>
<string>myfileext</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>NSPersistentStoreTypeKey</key>
<string>XML</string>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>My File</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.yourcompany.MyFile</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>myfileext</string>
</array>
</dict>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>My File</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.yourcompany.MyFile</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>myfileext</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>")
endif ()
Followed by
PLIST_TO_MERGE ${CUSTOM_PLIST}
In your juce_add_plugin
section.
1 Like
This is working fine, with my initial tests, thanks for posting your findings. My observation, which I was expecting, is the requirement to set the flags on a per OS basis.