Native iOS/Android file choosers


#84

Fabian, You are a GENIUS!!! Now I can load files inside an AU host AND I can load files in general without needing to have iCloud drive enabled! Now I am much closer to having a fully functioning AUv3 app thanks to this.

Thank you thank you thank you thank you thank you thank you thank you thank you


#85

I’ve been testing on the latest develop branch in which the following issue has been fixed: when using multiple AU instances, the file chooser always appears in the first AU instance. I pass the ‘this’ pointer of the editor as the last argument to the filechooser. That works.
However, I have the following crash when the AU instance window is closed whilst the file chooser is still open.

  1. load AU instance
  2. open file chooser but don’t select a file or press cancel
  3. close AU window whilst file chooser is still visible
  4. open AU window again (file chooser is still visible)
  5. select the file this time (file does not load)
  6. try to load another file --> crashes

#86

OK I’ve tested this and seems to be working for my test AUv3 (however, I don’t have a real iDevice to test right now so I can’t test GarageBand or other major iOS DAWs :frowning: ). Be sure to only store a safe pointer to your editor (or component) in your callback’s lambda. It could be that your component will be deleted before the native file chooser finishes. Something like this should work:

if (fileChooser == nullptr)
{
    fileChooser.reset (new FileChooser ("Untitled", File(), String(), true, false, this));
    
    SafePointer<AUv3SynthEditor> weakRef (this);
    fileChooser->launchAsync (FileBrowserComponent::canSelectFiles | FileBrowserComponent::openMode,
                              [weakRef] (const FileChooser& fc) mutable
                              {
                                  if (weakRef != nullptr)
                                  {
                                      weakRef->fileChooser = nullptr;
                                  }
                              });
}

#87

This all seems to be working, but as far as I can tell, we can’t select files that have an extension that isn’t “understood” by iOS natively. Is this correct?

(For instance, we load tuning tables with an extension .tun and our presets have an extension of .adpreset)


#88

Have you looked at putting UTExportedTypeDeclarations in your app’s plist?


#89

There we go. For future users that are confused, here is the bit I dropped in info.plist to get it to see .adpreset files in the browser. Adjust where appropriate:

<key>UTExportedTypeDeclarations</key>
	<array>
		<dict>
			<key>UTTypeConformsTo</key>
			<array>
				<string>public.data</string>
			</array>
			<key>UTTypeIdentifier</key>
			<string>com.audiodamage.quanta.adpreset</string>
			<key>UTTypeTagSpecification</key>
			<dict>
				<key>public.filename-extension</key>
				<string>adpreset</string>
				<key>public.mime-type</key>
				<string>applications/adpreset</string>
			</dict>
		</dict>
	</array>