Search code examples
xcodec++17macos-mojavemacos-catalinastd-filesystem

Does use of C++17 std::filesystem REQUIRE MacOS 10.15? (Xcode 11.1)


Using Xcode 11.1, building on MacOS 10.14.6 (Mojave), the following lines:

#include <filesystem>
typedef std::filesystem::path my_path;

...generate this compiler error:

'path' is unavailable: introduced in macOS 10.15

Does this mean I can't build for earlier versions of MacOS (10.13, 10.14) FROM 10.14, or that I can't generate an executable from 10.15 that can target/run on versions of MacOS that are EARLIER than 10.15?


Solution

  • It means that (using Apple's tools/libraries), you cannot use std::filesystem in a project targeting a version of Mac OS before 10.15.

    If you have a new enough Xcode, etc. you should be able to build a project on 10.14 (say) that targets 10.15 and uses filesystem types and calls. But it won't run on 10.14.