danomatika / ofxPd

(maintained) a Pure Data addon for OpenFrameworks using libpd
Other
202 stars 45 forks source link

writesf~ file doesn't get created on iOS 15 #85

Closed Miles-Tone closed 2 years ago

Miles-Tone commented 2 years ago

End up with this error coming from writesf~ error: dsp: /var/mobile/Containers/Data/Application/F124CCC4-63FB-4276-AA63-EA00C0DA24D1/Documents/shapes/2021-10-12-16-39-13-715.wav: No such file or directory it works as expected within standalone pd, and this approach has worked on previous iOSs, but it's not creating the file or directory, this could be something to do with directories and permissions? Xcode iOS15 SDK on iPad Air 2 running iOS14

danomatika commented 2 years ago

I haven't built anything with the iOS 15 SDK yet. It may be a permissions issue as you say, but more likely you need to add some sort of key and string to the Info.plist like with camera and microphone permissions.

Miles-Tone commented 2 years ago

yeah that's where I've been fishing around, haven't found anything yet though. this might be an issue that has come up in a previous SDK, as I haven't used writesf~ on iOS in a few years

Miles-Tone commented 2 years ago

ok, Solved! needed to create the directories that it would sit in, for some reason you can't create into the app's root directory but can inside a folder, so I did this before going ahead and saving: void ofApp::createDirectory(string _directory){ NSString *directory =ofxiOSStringToNSString(_directory); BOOL isDir; NSFileManager *fileManager= [NSFileManager defaultManager]; if(![fileManager fileExistsAtPath:directory isDirectory:&isDir]) if(![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:NULL]) NSLog(@"Error: Create folder failed %@", directory); }

danomatika commented 2 years ago

That’s correct. There are only a few folders within the app sandbox which are writable. The app docs have a list but what I remember are Documents & tmp for sure. The app root is not writable.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Oct 12, 2021, at 6:57 PM, Miles-Tone @.***> wrote:

 ok, Solved! needed to create the directories that it would sit in, for some reason you can't create into the app's root directory but can inside a folder, so I did this before going ahead and saving: void ofApp::createDirectory(string _directory){ NSString directory =ofxiOSStringToNSString(_directory); BOOL isDir; NSFileManager fileManager= [NSFileManager defaultManager]; if(![fileManager fileExistsAtPath:directory isDirectory:&isDir]) if(![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:NULL]) NSLog(@"Error: Create folder failed %@", directory); }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Miles-Tone commented 2 years ago

Yeah the weird thing is that I couldn’t write from writesf into documents/ first I had to use obj-c to create a directory within the documents folder, writesf could then write into that folder fine - documents/sounds/sound.wav

danomatika commented 2 years ago

Hmm. Documents should be ok. I have an app which uses libpd to write qlists into Document without an issue.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Oct 13, 2021, at 11:24 AM, Miles-Tone @.***> wrote:

 Yeah the weird thing is that I couldn’t write from writesf into documents/ first I had to use obj-c to create a directory within the documents folder, writesf could then write into that folder fine - documents/sounds/sound.wav

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Miles-Tone commented 2 years ago

Yeah I wonder if it’s an issue just for writesf, it might be that writesf doesn’t have the ability to create into the documents directory without the documents directory already being populated by something else. It might be that it “doesn’t exist” as a directory until it has something in it. When looking at it within the Files app, only apps that have put something inside the documents folder of their app appear over there. I wonder if there is something like that happening