From 31bffbf09e9e6809266a33216b845070533d9573 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Thu, 26 Jun 2025 16:32:15 -0400 Subject: [PATCH] ENH: Add support to find Headers in Apple Frameworks The header locations in apple frameworks require manipulation of the directory name in a '' include defintion. The header file is located at in a framework. --- simplecpp.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/simplecpp.cpp b/simplecpp.cpp index 599ffdf..a6b2a62 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -3212,6 +3212,22 @@ static std::string getIncludePathFileName(const std::string &includePath, const return isAbsolutePath(includePath) ? absoluteSimplifiedHeaderPath : extractRelativePathFromAbsolute(absoluteSimplifiedHeaderPath); } +#ifdef __APPLE__ +static std::string get_apple_framework_relative_path(const std::string& header) +{ + std::string appleFrameworkHeader = {header}; + // try the Framework path on Mac, if there is a path in front + // ### what about escaped slashes? + size_t slashPos = appleFrameworkHeader.find('/'); + if (slashPos != std::string::npos) + { + constexpr auto framework_separator{ ".framework/Headers" }; + appleFrameworkHeader.insert(slashPos, framework_separator); + } + return appleFrameworkHeader; +} +#endif // __APPLE__ + static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header) { for (std::list::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) { @@ -3219,6 +3235,17 @@ static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI if (!path.empty()) return path; } +#ifdef __APPLE__ + std::string appleFrameworkHeader = get_apple_framework_relative_path(header); + if (appleFrameworkHeader != header) + { + for (std::list::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) { + std::string simplePath = openHeader(f, getIncludePathFileName(*it, appleFrameworkHeader)); + if (!simplePath.empty()) + return simplePath; + } + } +#endif // __APPLE__ return ""; }