-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS build broken due to std::system usage #2248
Comments
Thanks for reporting. Does 553022d fix the problem? |
Ugh... so, I've managed to make two mistakes in my attempt to guide you with "the correct check" :(.
I've tested that this patch works: diff --git a/include/fmt/os.h b/include/fmt/os.h
index 70c465b5..5955339e 100644
--- a/include/fmt/os.h
+++ b/include/fmt/os.h
@@ -14,6 +14,10 @@
#include <cstdio>
#include <cstdlib> // for strtod_l
+#if defined __APPLE__
+# include <TargetConditionals.h>
+#endif
+
#if defined __APPLE__ || defined(__FreeBSD__)
# include <xlocale.h> // for LC_NUMERIC_MASK on OS X
#endif
@@ -201,7 +205,7 @@ FMT_API void report_windows_error(int error_code,
#endif // _WIN32
// std::system is not available on iOS (#2248).
-#ifndef TARGET_OS_IPHONE
+#if !TARGET_OS_IPHONE
template <typename S, typename... Args, typename Char = char_t<S>>
void say(const S& format_str, Args&&... args) {
std::system(format("say \"{}\"", format(format_str, args...)).c_str()); Another option is to use __IPHONE_OS_VERSION_MIN_REQUIRED, which is defined by the compiler itself, but the problem is that tvOS and watchOS are going to have the same issue and while those platforms usually also have the __IPHONE_OS_VERSION_MIN_REQUIRED set, I believe that is just some backwards-compatibility in AvailabilityInternal.h and I have no clue if Apple intends to maintain that... |
Thinking more of it, it's better to opt in instead of opt out platforms, so here's another tentative fix: ce67532. |
Ah, of course: since that say command only exists on macOS in the first place. (Why, BTW, is fmt providing an OSX-specific text-to-speech function?... it isn't even "safe": if the string contains a quotation mark it can terminate the command and obtain arbitrary shell execution :(.) FWIW, this patch at least made fmt compile on iOS, if it is working for your use cases! |
"lol" :( |
Fixed in 69bdc20. |
In 15c10b0, a new function was added--say--which runs std::system... a function which is "unavailable" on iOS, breaking the build of this library on that platform.
I believe the correct check to remove this would be
#ifndef TARGET_OS_IPHONE
.The text was updated successfully, but these errors were encountered: