<div dir="ltr">Awesome, many thanks :) </div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">
<p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head Of CEO</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Mar 24, 2016 at 6:00 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Yes, with a type. So either</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>static NSString * const kAPI_ENDPOINT = @ API_ENDPOINT;</div></blockquote><div><br></div>or<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>static const char *kAPI_ENDPOINT = API_ENDPOINT;</div></blockquote><div><br></div>Jordan<div><div class="h5"><br><div><div><br><div><blockquote type="cite"><div>On Mar 24, 2016, at 10:55, James Campbell <<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>> wrote:</div><br><div><div dir="ltr">Okay that helps, in my case the macros contain mostly strings. API Keys, Endpoints and secrets. So something like this should work ?<div><br></div><div>static const kAPI_ENDPOINT = API_ENDPOINT </div><div><br></div><div>which will then be imported into Swift as:</div><div><br></div><div>let endpoint = kAPI_ENDPOINT</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head Of CEO</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Mar 24, 2016 at 5:46 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I'm not sure what I would recommend; it depends what you're using this for. If it's C-style conditional compilation, Swift's own similar-but-more-limited #if and -D flags are more powerful…but then you need to maintain two sets of flags. If it's constant integer values, typed constants (using 'static const' in C) are pretty much always better, even if you initialize them with a macro value. Constant strings don't really gain any benefit from 'static const' today, but it'll work.</div><div><br></div><div>The "2.2 is a minor update and shouldn't have changed behavior here" is a fair point.</div><span><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div><div><br></div><br><div><blockquote type="cite"><div>On Mar 24, 2016, at 10:25, James Campbell <<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>> wrote:</div><br><div><div dir="ltr">Yeah I noticed that it only works in Xcode 7.2 when you have a bridging header and in Xcode 7.3 if it's explicitly declared in code and you have a bridging header.<div><br></div><div>Is there a way we could bring this back for a Swift 2.2.1 ? It eased our migration from Objective-C.</div><div><br></div><div>If the recommended path is to have swift constants and #if statements, then we could remove this again in Swift 3 since there are already a lot of things breaking in that version I would expect something like this to happen :)</div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head Of CEO</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Mar 24, 2016 at 5:06 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>The reason this wouldn't have been considered intentional is because it only works for targets with bridging headers. Frameworks? Nope. Pure Swift targets? Nope.</div><span><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div><br><div><blockquote type="cite"><div>On Mar 24, 2016, at 10:05 , Jordan Rose <<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>> wrote:</div><br><div><div style="word-wrap:break-word"><div>Ahh. Yes, we were. We would define the macro in Clang, then when we do a lookup we'd get it back out in Swift. I, um, wouldn't have considered that intentional, but clearly people are depending on it. Sorry, James!</div><div><br></div><div>Doug, we saw a similar issue with macros in bridging headers, right? Do you remember which that was? Do you have an opinion here?</div><div><br></div><div>Jordan</div><div><br></div><br><div><blockquote type="cite"><div>On Mar 24, 2016, at 9:06 , Daniel Dunbar <<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>> wrote:</div><br><div><div style="word-wrap:break-word">(+Jordan)<div><br></div><div>Jordan, did something change here? Were we previously getting these via the Clang importer in a way we aren't anymore?</div><div><br></div><div> - Daniel</div><div><br><div><blockquote type="cite"><div>On Mar 24, 2016, at 9:02 AM, James Campbell <<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>> wrote:</div><br><div><div dir="ltr">I've just attached one now. The preprocessor macro is specified in the build settings.<div><br></div><div>In Xcode 7.2 these were imported and worked like they did in C i.e API_VERSION=2 would be imported as a constant named API_VERSION and would be a 2</div><div><br></div><div>In Xcode 7.3 it broke.</div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head Of CEO</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Mar 24, 2016 at 3:54 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Swift has never supported referring directly to macros, it only supports "build configurations". I'm still not sure exactly what you have that could have worked previously.<div><div><br></div><div>Can you please attach a complete project showing something which worked in 7.2 and does not work now to the bug you filed?</div><span><font color="#888888"><div><br></div><div> - Daniel</div></font></span><div><div><div><br><div><blockquote type="cite"><div>On Mar 24, 2016, at 8:50 AM, James Campbell <<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>> wrote:</div><br><div><div dir="ltr">To hold keys and api endpoints.<div><br></div><div>In the past for Objective-C I would have used it like this:</div><div><br></div><div>request.api_endpoint = MY_MACRO_ENDPOINT</div><div><br></div><div>And then when Swift was released I was able to do it in Xcode 7.2:</div><div><br></div><div>request.api_endpoint = MY_MACRO_ENDPOINT<br></div><div><br></div><div>But when using Xocde 7.3 I get this:</div><div><br></div><div>request.api_endpoint = MY_MACRO_ENDPOINT //MY_MACRO_ENDPOINT not defined.<br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head Of CEO</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Mar 24, 2016 at 3:40 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Mar 24, 2016, at 5:21 AM, James Campbell <<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>> wrote:</div><br><div><div dir="ltr">This is the "GCC_PREPROCESSOR_DEFINITIONS" build setting. This previously imported into swift. But in Xcode 7.3 it no longer does this.</div></div></blockquote><div><br></div></span>Ok, and exactly how are you trying to use them? Via an #if in C or via an #if in Swift?</div><span><font color="#888888"><div><br></div><div> - Daniel</div></font></span><div><div><div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>If I write the Macros in the bridging header they are imported but I would ideally like to keep them in a build setting.</div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head Of CEO</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Mar 23, 2016 at 11:23 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To follow on to what Joe said, can you provide more info about the exact problem. Is this a C preprocessor definition that you expect to be available in code imported by the Clang importer (i.e., bridging header files, etc.), or is a a macro you are expecting to use within Swift itself? And please let us know exactly which build setting you are referring to.<br>
<br>
Thanks,<br>
- Daniel<br>
<div><div><br>
> On Mar 23, 2016, at 3:59 PM, Joe Groff via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br>
><br>
><br>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br>
>><br>
>> We are experiencing an issue when compiling swift code under Xcode 7.3.<br>
>><br>
>> Preprocessor macros specified in the Xcode Project aren't imported into swift. Ones manually declared in code are imported fine.<br>
>><br>
>> Specifying Xcode 7.3 to use the Xcode 7.2 toolchain (Swift 2.1 etc) has no effect on this.<br>
>><br>
>> This is preventing us from using Xcode 7.3 and being able to test for 9.3. Anybody else getting this issue?<br>
><br>
> The Swift and C family build settings in Xcode are distinct. Are you sure you set the -D flags in "Other Swift Flags" and not in the C build settings? Swift doesn't have preprocessor macros.<br>
><br>
> -Joe<br>
><br>
</div></div>> _______________________________________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br>
</blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>