<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Yes, with a type. So either</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">static NSString * const kAPI_ENDPOINT = @ API_ENDPOINT;</div></blockquote><div class=""><br class=""></div>or<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">static const char *kAPI_ENDPOINT = API_ENDPOINT;</div></blockquote><div class=""><br class=""></div>Jordan<br class=""><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 10:55, James Campbell &lt;<a href="mailto:james@supmenow.com" class="">james@supmenow.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Okay that helps, in my case the macros contain mostly strings. API Keys, Endpoints and secrets. So something like this should work ?<div class=""><br class=""></div><div class="">static const kAPI_ENDPOINT = API_ENDPOINT&nbsp;</div><div class=""><br class=""></div><div class="">which will then be imported into Swift as:</div><div class=""><br class=""></div><div class="">let endpoint = kAPI_ENDPOINT</div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Head Of CEO</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Mar 24, 2016 at 5:46 PM, Jordan Rose <span dir="ltr" class="">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank" class="">jordan_rose@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">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 class=""><br class=""></div><div class="">The "2.2 is a minor update and shouldn't have changed behavior here" is a fair point.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Jordan</div></font></span><div class=""><div class="h5"><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 10:25, James Campbell &lt;<a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">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 class=""><br class=""></div><div class="">Is there a way we could bring this back for a Swift 2.2.1 ? It eased our migration from Objective-C.</div><div class=""><br class=""></div><div class="">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" class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Head Of CEO</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Mar 24, 2016 at 5:06 PM, Jordan Rose <span dir="ltr" class="">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank" class="">jordan_rose@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">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 class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">Jordan</div></font></span><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 10:05 , Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" target="_blank" class="">jordan_rose@apple.com</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 9:06 , Daniel Dunbar &lt;<a href="mailto:daniel_dunbar@apple.com" target="_blank" class="">daniel_dunbar@apple.com</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">(+Jordan)<div class=""><br class=""></div><div class="">Jordan, did something change here? Were we previously getting these via the Clang importer in a way we aren't anymore?</div><div class=""><br class=""></div><div class="">&nbsp;- Daniel</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 9:02 AM, James Campbell &lt;<a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">I've just attached one now. The preprocessor macro is specified in the build settings.<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">In Xcode 7.3 it broke.</div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Head Of CEO</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Mar 24, 2016 at 3:54 PM, Daniel Dunbar <span dir="ltr" class="">&lt;<a href="mailto:daniel_dunbar@apple.com" target="_blank" class="">daniel_dunbar@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">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 class=""><div class=""><br class=""></div><div class="">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 class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">&nbsp;- Daniel</div></font></span><div class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 8:50 AM, James Campbell &lt;<a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">To hold keys and api endpoints.<div class=""><br class=""></div><div class="">In the past for Objective-C I would have used it like this:</div><div class=""><br class=""></div><div class="">request.api_endpoint = MY_MACRO_ENDPOINT</div><div class=""><br class=""></div><div class="">And then when Swift was released I was able to do it in Xcode 7.2:</div><div class=""><br class=""></div><div class="">request.api_endpoint = MY_MACRO_ENDPOINT<br class=""></div><div class=""><br class=""></div><div class="">But when using Xocde 7.3 I get this:</div><div class=""><br class=""></div><div class="">request.api_endpoint = MY_MACRO_ENDPOINT //MY_MACRO_ENDPOINT not defined.<br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Head Of CEO</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Mar 24, 2016 at 3:40 PM, Daniel Dunbar <span dir="ltr" class="">&lt;<a href="mailto:daniel_dunbar@apple.com" target="_blank" class="">daniel_dunbar@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 5:21 AM, James Campbell &lt;<a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">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 class=""><br class=""></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 class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">&nbsp;- Daniel</div></font></span><div class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">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" class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Head Of CEO</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Wed, Mar 23, 2016 at 11:23 PM, Daniel Dunbar <span dir="ltr" class="">&lt;<a href="mailto:daniel_dunbar@apple.com" target="_blank" class="">daniel_dunbar@apple.com</a>&gt;</span> wrote:<br class=""><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 class="">
<br class="">
Thanks,<br class="">
&nbsp;- Daniel<br class="">
<div class=""><div class=""><br class="">
&gt; On Mar 23, 2016, at 3:59 PM, Joe Groff via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt;<br class="">
&gt;&gt; On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
&gt;&gt;<br class="">
&gt;&gt; We are experiencing an issue when compiling swift code under Xcode 7.3.<br class="">
&gt;&gt;<br class="">
&gt;&gt; Preprocessor macros specified in the Xcode Project aren't imported into swift. Ones manually declared in code are imported fine.<br class="">
&gt;&gt;<br class="">
&gt;&gt; Specifying Xcode 7.3 to use the Xcode 7.2 toolchain (Swift 2.1 etc) has no effect on this.<br class="">
&gt;&gt;<br class="">
&gt;&gt; This is preventing us from using Xcode 7.3 and being able to test for 9.3. Anybody else getting this issue?<br class="">
&gt;<br class="">
&gt; 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 class="">
&gt;<br class="">
&gt; -Joe<br class="">
&gt;<br class="">
</div></div>&gt; _______________________________________________<br class="">
&gt; swift-users mailing list<br class="">
&gt; <a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>