4 ms·
I don't quite understand why they are putting specifics like detecting the iOS simulator in the core language.
by tinus_hn 9y ago
I don't quite understand why they are putting specifics like detecting the iOS simulator in the core language.
- yoz-y 9y agoProbably because "how do I detect simulator" is one of the most asked questions about swift. So Apple uses the leverage they have over the language. I hope though that the way the targetEnvironment condition is implemented is that the 'simulator' exists only in the iOS library.
- Someone 9y agoThey want functionality that is similar to the C preprocessor’s #if, but different in that they want to require both branches to syntax check. They also want to locally evaluate the equivalent of such #if expressions (in contrast, in C, #if X requires preprocessing the file. That can mean reading dozens of header files, and is dependent on compiler flags) I think this is a pragmatic way to accomplish that. It restricts you to conditions that Apple has deemed useful, but makes it easier to write good tooling.
- pjmlp 9y agoBecause in the context of conditional compilation it is just yet another target.