I have a C library I’m modifying, as little as possible, to add a feature and get that to run properly on iOS. It is working fine on iOS 5.1, but breaking on iOS 6 because it’s required to write a small temporary file, and I think there is an issue w/ Entitlements with where it used to write (/tmp/some.file).
I know that NSHomeDirectory() will give me the sandbox root from objectiveC, but it requires objectiveC / Foundation to run. How can I get the sandbox root using only C / CoreFoundation calls?
The CoreFoundation equivalent of
NSHomeDirectory()isCFCopyHomeDirectoryURL(). It is available since iOS 5 and the only place where it is “documented” is in the iOS 4.3 to iOS 5.0 API Differences.If you want the temporary directory without hardcoding the
tmpstring, then you may want to useconfstrwith the_CS_DARWIN_USER_TEMP_DIRconstant and fallback to theTMPDIRenvironment variable if the confstr call fails: