use Documents folder visible from Files app for save data

This commit is contained in:
leo60228 2024-01-23 19:19:54 -05:00
parent 5cf4303fa2
commit 51d6a1d90f
No known key found for this signature in database
GPG Key ID: 6F3EB461799AD95E
3 changed files with 23 additions and 1 deletions

View File

@ -145,7 +145,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
XCODE_ATTRIBUTE_MARKETING_VERSION "2.4"
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon
XCODE_ATTRIBUTE_GENERATE_INFOPLIST_FILE YES
XCODE_ATTRIBUTE_INFOPLIST_FILE ""
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
XCODE_ATTRIBUTE_INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace YES
RESOURCE "${DATA_ZIP};AppIcon.xcassets"
)

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIFileSharingEnabled</key>
<true/>
</dict>
</plist>

View File

@ -1330,6 +1330,19 @@ static int PLATFORM_getOSDirectory(char* output, const size_t output_size)
}
SDL_snprintf(output, output_size, "%s/", externalStoragePath);
return 1;
#elif defined(TARGET_OS_IPHONE)
// (ab)use SDL APIs to get the path to the Documents folder without needing Objective-C
const char* prefsPath = SDL_GetPrefPath("", "");
if (prefsPath == NULL)
{
vlog_error(
"Could not get OS directory: %s",
SDL_GetError()
);
return 0;
}
SDL_snprintf(output, output_size, "%s/../../Documents/", prefsPath);
return 1;
#else
const char* prefDir = PHYSFS_getPrefDir("distractionware", "VVVVVV");
if (prefDir == NULL)