From 51d6a1d90fc0da9ad42e07c9215768130233bcf6 Mon Sep 17 00:00:00 2001 From: leo60228 Date: Tue, 23 Jan 2024 19:19:54 -0500 Subject: [PATCH] use Documents folder visible from Files app for save data --- desktop_version/CMakeLists.txt | 3 ++- desktop_version/Info.plist | 8 ++++++++ desktop_version/src/FileSystemUtils.cpp | 13 +++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 desktop_version/Info.plist diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 68264713..4d6e9e04 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -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" ) diff --git a/desktop_version/Info.plist b/desktop_version/Info.plist new file mode 100644 index 00000000..ff579a6c --- /dev/null +++ b/desktop_version/Info.plist @@ -0,0 +1,8 @@ + + + + + UIFileSharingEnabled + + + diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 5643182d..71556cd4 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -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)