From cfdae6569722c9054fa0faef01a659090ec410dc Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 10 Sep 2023 14:42:53 +0200 Subject: [PATCH] Fix building for ios --- src/futils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/futils.cpp b/src/futils.cpp index eae19558fb..26a028355b 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -369,6 +369,14 @@ std::string getProcessPath() { auto path = fs::read_symlink(Internal::stringFormat("/proc/%d/path/a.out", getpid())); #elif defined(__unix__) auto path = fs::read_symlink("/proc/self/exe"); +#elif defined(__APPLE__) + // For apple systems other than macOS, e.g. iOS. + char pathbuf[2048]; + uint32_t size = sizeof(pathbuf); + const int get_exec_path_failure = _NSGetExecutablePath(pathbuf, &size); + if (get_exec_path_failure) + return "unknown"; // pathbuf not big enough + auto path = fs::path(pathbuf); #endif return path.parent_path().string(); } catch (const fs::filesystem_error&) {