# iOS Garageband and native FileChooser loadFileAsString returns empty string

**URL:** <https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255>\
**Category:** Audio Plugins\
**Created:** [March 25, 2020, 8:02am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255 "2020-03-25T08:02:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 25, 2020, 8:02am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/1 "2020-03-25T08:02:46Z")

</div>

I can’t figure out how file access on iOS works. When i access the document folder i’m getting following path by JUCE:

`/var/mobile/Containers/Data/PluginKitPlugin/15769554-7F73-4847-ADB8-F94F51302981/Documents/PLUGIN_NAME/presets/FMR Presets Bank/Arp/ARP Bass Arpeggio FMR.pjunoxl`

All works with this path. I can write and read files and my internal preset browser works also in GarageBand. `loadFileAsString` returns the text contained in the file.

When i pass exactly the same document folder and open the native FileChooser in GarageBand (it works in the standalone version). The file chooser returns a slightly different path after selecting the same file:

`/private/var/mobile/Containers/Data/Application/C40884E9-EDF5-4F01-99C0-EBDB0325FD77/Documents/PLUGIN_NAME/presets/FMR Presets Bank/Arp/ARP Bass Arpeggio FMR.pjunoxl`

`loadFileAsString` always returns an empty string in this case for that path, but `existsAsFile` returns true. The file is 1Kb, so i don’t think it’s empty. I can imagine that it has something to do with sandboxing.

Would be great if someone can give me some information how this works. What happens here?

My new question is, how can i manage presets iOS? I want to use the same folder for the standalone and the Auv3 from inside garage band.

Any input welcome.

---

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 25, 2020, 11:43am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/2 "2020-03-25T11:43:30Z")

</div>

I have found this thread about the issue:

> [@App Group Folder Access](https://forum.juce.com/t/app-group-folder-access/23102):
>
> I’m about to spend the next several days beating my head against the wall as I roll in my own App Group functionality for our iOS AUv3 releases; I just wanted to see if there’s any movement on the Roli front in this regard, because I would be sad to do it then find it in the next JUCE update. And I don’t want to be sad. I want to be glad. In related news, has anyone else done this and wants to share a bit of code? I am wading in to waters that I’m not familiar with here, and don’t want to reall…

Is this still not supported by juce directly and is it still not possible to write the preset into the shared document folder?

---

<div class="post-metadata">

**Author:** ![crandall1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/crandall1/32/157_2.png) [@crandall1](https://forum.juce.com/u/crandall1)\
**Post date:** [March 25, 2020, 11:58am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/3 "2020-03-25T11:58:46Z")

</div>

My original thread on the subject is still the way to do it.

1. The AUv3 is sandboxed. It has its own /Documents folder. This is different than the standalone one.

2. The AUv3 can see the standalone’s folder tree (per Tom’s comments in that thread) but can not write to it.

3. The only way the AUv3 and Standalone can share write access to the same folder is to use the Security Group.

4. The Security Group is owned by the standalone/AUv3 pair and nothing else can see it or write to it.

5. This all has to be hand-rolled (per my instructions, with some Obj-C++ coding) as there is no facility for this in JUCE as of yet.

---

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 25, 2020, 6:53pm UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/4 "2020-03-25T18:53:57Z")

</div>

I will look at it as soon as i can access my apple developer account again 😬

---

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 26, 2020, 9:24am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/5 "2020-03-26T09:24:51Z")

</div>

Hi Chris, thanks for your help. I’m a iOS beginner and it’s a real pain to get this working. I get an empty string when i request the path with the obj c code and the group identifier.

```
File result = File();
NSFileManager* fm = [NSFileManager defaultManager];
NSURL *containerURL = [fm containerURLForSecurityApplicationGroupIdentifier:@"group.ch.toguaudioline.talunolxv2"];
String tmp = ([containerURL.relativeString UTF8String]);
return tmp.substring(6);

```

What i did:

- I added an app group in the developer portal. For AUv3 and Standalone, assigned the same app group.
- Downloaded the profiles and added them to the device in XCode.
- Checked the App Group feature in ProJucer.
- Added the obj code and access it with the app group identifier.  
–\> i’m getting an empty string NSURL is nil.

Is there something i miss? Do i need to define the resource path somewhere or should i receive one with a somehow auto generated name?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 26, 2020, 9:39am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/6 "2020-03-26T09:39:51Z")

</div>

Did you see the [RuntimePermissions](https://docs.juce.com/develop/classRuntimePermissions.html) class? AFAIK you need to request externalStorage permission:

```auto
RuntimePermissions::request (
    RuntimePermissions::readExternalStorage,
    [this] (bool wasGranted)
    {
         if (! wasGranted)
         {
             // ...

```

---

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 26, 2020, 9:48am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/7 "2020-03-26T09:48:40Z")

</div>

No, i didn’t that as far as i know. After some more tries i had to check a specific app group name in the XCode capabilities. After that it worked:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/b/bd8b56f02f379eac0b339935f9d596ba069a9b27.png)

I just wonder if there is a way to configure this in projucer. I checked the app group in projucer, but didn’t found a way to enter the group identifier. Can this be done or do i have to set it manually always when i save the project with projucer?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 26, 2020, 9:52am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/8 "2020-03-26T09:52:34Z")

</div>

Cool, I always forget on which platform RuntimePermissions is needed. Seems to be android then. I always add it just in case, maybe one day audio becomes usable on android. And it is cancelled out on iOS, so no harm.

Don’t know about app groups, I am following, hoping to use it later myself 😉

---

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 26, 2020, 10:20am UTC](https://forum.juce.com/t/ios-garageband-and-native-filechooser-loadfileasstring-returns-empty-string/38255/9 "2020-03-26T10:20:25Z")

</div>

Just to be sure. Is it right that the native file browser can’t access the app group shared folder?
