[swift-users] Serious Issue with Project Preprocessor Build Setting, Xcode 7.3 and Swift.

James Campbell james at supmenow.com
Thu Mar 24 12:25:04 CDT 2016


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.

Is there a way we could bring this back for a Swift 2.2.1 ? It eased our
migration from Objective-C.

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 :)

*___________________________________*

*James⎥Head Of CEO*

*james at supmenow.com <james at supmenow.com>⎥supmenow.com <http://supmenow.com>*

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On Thu, Mar 24, 2016 at 5:06 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> 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.
>
> Jordan
>
> On Mar 24, 2016, at 10:05 , Jordan Rose <jordan_rose at apple.com> wrote:
>
> 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!
>
> Doug, we saw a similar issue with macros in bridging headers, right? Do
> you remember which that was? Do you have an opinion here?
>
> Jordan
>
>
> On Mar 24, 2016, at 9:06 , Daniel Dunbar <daniel_dunbar at apple.com> wrote:
>
> (+Jordan)
>
> Jordan, did something change here? Were we previously getting these via
> the Clang importer in a way we aren't anymore?
>
>  - Daniel
>
> On Mar 24, 2016, at 9:02 AM, James Campbell <james at supmenow.com> wrote:
>
> I've just attached one now. The preprocessor macro is specified in the
> build settings.
>
> 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
>
> In Xcode 7.3 it broke.
>
> *___________________________________*
>
> *James⎥Head Of CEO*
>
> *james at supmenow.com <james at supmenow.com>⎥supmenow.com
> <http://supmenow.com/>*
>
> *Sup*
>
> *Runway East *
>
> *10 Finsbury Square*
>
> *London*
>
> * EC2A 1AF *
>
> On Thu, Mar 24, 2016 at 3:54 PM, Daniel Dunbar <daniel_dunbar at apple.com>
> wrote:
>
>> 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.
>>
>> Can you please attach a complete project showing something which worked
>> in 7.2 and does not work now to the bug you filed?
>>
>>  - Daniel
>>
>> On Mar 24, 2016, at 8:50 AM, James Campbell <james at supmenow.com> wrote:
>>
>> To hold keys and api endpoints.
>>
>> In the past for Objective-C I would have used it like this:
>>
>> request.api_endpoint = MY_MACRO_ENDPOINT
>>
>> And then when Swift was released I was able to do it in Xcode 7.2:
>>
>> request.api_endpoint = MY_MACRO_ENDPOINT
>>
>> But when using Xocde 7.3 I get this:
>>
>> request.api_endpoint = MY_MACRO_ENDPOINT //MY_MACRO_ENDPOINT not defined.
>>
>>
>> *___________________________________*
>>
>> *James⎥Head Of CEO*
>>
>> *james at supmenow.com <james at supmenow.com>⎥supmenow.com
>> <http://supmenow.com/>*
>>
>> *Sup*
>>
>> *Runway East *
>>
>> *10 Finsbury Square*
>>
>> *London*
>>
>> * EC2A 1AF *
>>
>> On Thu, Mar 24, 2016 at 3:40 PM, Daniel Dunbar <daniel_dunbar at apple.com>
>> wrote:
>>
>>>
>>> On Mar 24, 2016, at 5:21 AM, James Campbell <james at supmenow.com> wrote:
>>>
>>> This is the "GCC_PREPROCESSOR_DEFINITIONS" build setting. This
>>> previously imported into swift. But in Xcode 7.3 it no longer does this.
>>>
>>>
>>> Ok, and exactly how are you trying to use them? Via an #if in C or via
>>> an #if in Swift?
>>>
>>>  - Daniel
>>>
>>>
>>> If I write the Macros in the bridging header they are imported but I
>>> would ideally like to keep them in a build setting.
>>>
>>> *___________________________________*
>>>
>>> *James⎥Head Of CEO*
>>>
>>> *james at supmenow.com <james at supmenow.com>⎥supmenow.com
>>> <http://supmenow.com/>*
>>>
>>> *Sup*
>>>
>>> *Runway East *
>>>
>>> *10 Finsbury Square*
>>>
>>> *London*
>>>
>>> * EC2A 1AF *
>>>
>>> On Wed, Mar 23, 2016 at 11:23 PM, Daniel Dunbar <daniel_dunbar at apple.com
>>> > wrote:
>>>
>>>> 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.
>>>>
>>>> Thanks,
>>>>  - Daniel
>>>>
>>>> > On Mar 23, 2016, at 3:59 PM, Joe Groff via swift-users <
>>>> swift-users at swift.org> wrote:
>>>> >
>>>> >
>>>> >> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <
>>>> swift-users at swift.org> wrote:
>>>> >>
>>>> >> We are experiencing an issue when compiling swift code under Xcode
>>>> 7.3.
>>>> >>
>>>> >> Preprocessor macros specified in the Xcode Project aren't imported
>>>> into swift. Ones manually declared in code are imported fine.
>>>> >>
>>>> >> Specifying Xcode 7.3 to use the Xcode 7.2 toolchain (Swift 2.1 etc)
>>>> has no effect on this.
>>>> >>
>>>> >> This is preventing us from using Xcode 7.3 and being able to test
>>>> for 9.3. Anybody else getting this issue?
>>>> >
>>>> > 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.
>>>> >
>>>> > -Joe
>>>> >
>>>> > _______________________________________________
>>>> > swift-users mailing list
>>>> > swift-users at swift.org
>>>> > https://lists.swift.org/mailman/listinfo/swift-users
>>>>
>>>>
>>>
>>>
>>
>>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160324/a7ba89a4/attachment.html>


More information about the swift-users mailing list