diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d3b5a311..5c1dfd8de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -548,6 +548,10 @@ set(libdevilutionx_SRCS
Source/storm/storm_svid.cpp
Source/miniwin/misc_msg.cpp)
+if(IOS)
+ list(APPEND libdevilutionx_SRCS Source/platform/ios/ios_paths.m)
+endif()
+
if(USE_SDL1)
list(APPEND libdevilutionx_SRCS Source/utils/sdl2_to_1_2_backports.cpp)
endif()
diff --git a/Packaging/apple/Info.plist b/Packaging/apple/Info.plist
index 1257bedaf..d642ee57d 100644
--- a/Packaging/apple/Info.plist
+++ b/Packaging/apple/Info.plist
@@ -44,5 +44,9 @@
UIApplicationSupportsIndirectInputEvents
+ LSSupportsOpeningDocumentsInPlace
+
+ UIFileSharingEnabled
+
diff --git a/Source/platform/ios/ios_paths.h b/Source/platform/ios/ios_paths.h
new file mode 100644
index 000000000..d8bcf04e1
--- /dev/null
+++ b/Source/platform/ios/ios_paths.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char *IOSGetPrefPath();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Source/platform/ios/ios_paths.m b/Source/platform/ios/ios_paths.m
new file mode 100644
index 000000000..a848cfcc5
--- /dev/null
+++ b/Source/platform/ios/ios_paths.m
@@ -0,0 +1,30 @@
+#import
+
+#include "ios_paths.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *IOSGetPrefPath()
+{
+ @autoreleasepool {
+ NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+
+ if ([array count] > 0) {
+ NSString *str = [array objectAtIndex:0];
+ str = [str stringByAppendingString:@"/"];
+ const char *base = [str fileSystemRepresentation];
+
+ char *copy = malloc(strlen(base) + 1);
+ strcpy(copy, base);
+ return copy;
+ }
+
+ return "";
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Source/utils/paths.cpp b/Source/utils/paths.cpp
index db8429c4e..5041f3751 100644
--- a/Source/utils/paths.cpp
+++ b/Source/utils/paths.cpp
@@ -6,6 +6,10 @@
#include "utils/log.hpp"
#include "utils/sdl_ptrs.h"
+#ifdef __IPHONEOS__
+#include "platform/ios/ios_paths.h"
+#endif
+
#ifdef USE_SDL1
#include "utils/sdl2_to_1_2_backports.h"
#endif
@@ -66,10 +70,14 @@ const std::string &BasePath()
const std::string &PrefPath()
{
if (!prefPath) {
+#ifndef __IPHONEOS__
prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
if (FileExistsAndIsWriteable("diablo.ini")) {
prefPath = std::string("./");
}
+#else
+ prefPath = FromSDL(IOSGetPrefPath());
+#endif
}
return *prefPath;
}
@@ -77,10 +85,14 @@ const std::string &PrefPath()
const std::string &ConfigPath()
{
if (!configPath) {
+#ifndef __IPHONEOS__
configPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
if (FileExistsAndIsWriteable("diablo.ini")) {
configPath = std::string("./");
}
+#else
+ configPath = FromSDL(IOSGetPrefPath());
+#endif
}
return *configPath;
}