schmidt9 schmidt9 - 2 months ago 14x
iOS Question

Create directory/file in iOS using C++

Is it possible to create in app's home dir (Documents or Library) dir/file using C++ code? I tried

, which work on Simulator, but fail or real device (eg. running
). Core Foundation methods seem to give only read, not write possibility too.


You can get the home directory using the Core Foundation library's CFCopyHomeDirectoryURL() function. (This is a C function, no Objective-C required.) Using the CFURL accessors, you can pull the path from that and use it with standard C++ or C/POSIX file I/O functions. Or you can use Core Foundation for I/O directly.

You can't used posix_spawn or system or fork/exec* in iOS due to sandboxing. No shell scripts either.