Serious Issue with Project Preprocessor Build Setting, Xcode 7.3 and Swift.


(James Campbell) #1

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?

···

*___________________________________*

*James⎥Lead Engineer*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *


(Joe Groff) #2

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

···

On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@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?


(Daniel Dunbar) #3

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@swift.org> wrote:

On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Jan Neumüller) #4

What macros? Swift doesn’t have macros - thanks the lord...

Jan Neumüller

···

--
GPG/PGP-Key: http://www.slayers.de/transfer/Jan_GPG_pub.asc

On 23.03.2016, at 17:43, James Campbell via swift-users <swift-users@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?
___________________________________

James⎥Lead Engineer

james@supmenow.com <mailto:james@supmenow.com>⎥supmenow.com <http://supmenow.com/>
Sup

Runway East >

10 Finsbury Square

London

> EC2A 1AF

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(James Campbell) #5

Fixed this issue.

https://openradar.appspot.com/radar?id=6116002660089856

···

*___________________________________*

*James⎥Head Of CEO*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On Wed, Mar 23, 2016 at 4:43 PM, James Campbell <james@supmenow.com> 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?

*___________________________________*

*James⎥Lead Engineer*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *


(James Campbell) #6

This is the "GCC_PREPROCESSOR_DEFINITIONS" build setting. This previously
imported into swift. But in Xcode 7.3 it no longer does this.

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@supmenow.com <james@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@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@swift.org> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users < > swift-users@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@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users


(James Campbell) #7

Sorry reported it rather.

···

*___________________________________*

*James⎥Head Of CEO*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On Wed, Mar 23, 2016 at 8:41 PM, James Campbell <james@supmenow.com> wrote:

Fixed this issue.

https://openradar.appspot.com/radar?id=6116002660089856

*___________________________________*

*James⎥Head Of CEO*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On Wed, Mar 23, 2016 at 4:43 PM, James Campbell <james@supmenow.com> > 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?

*___________________________________*

*James⎥Lead Engineer*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *


(Daniel Dunbar) #8

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

···

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com> wrote:

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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


(James Campbell) #9

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@supmenow.com <james@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@apple.com> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@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@supmenow.com <james@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@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@swift.org> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users < >> swift-users@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@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users


(James Campbell) #10

Explained in rest of the thread. It seems that in Xcode 7.2 if you
specified a C Macro in the build settings it was imported (i.e
API_VERSION=2). However in Xcode 7.3, only ones specified in code are
imported *not* ones specified in a build setting.

···

*___________________________________*

*James⎥Head Of CEO*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On Wed, Mar 23, 2016 at 5:27 PM, Jan Neumüller <swift-users@swift.org> wrote:

What macros? Swift doesn’t have macros - thanks the lord...

Jan Neumüller
--
GPG/PGP-Key: http://www.slayers.de/transfer/Jan_GPG_pub.asc

On 23.03.2016, at 17:43, James Campbell via swift-users < > swift-users@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?

*___________________________________*

*James⎥Lead Engineer*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Daniel Dunbar) #11

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@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@apple.com>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


(James Campbell) #12

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@supmenow.com <james@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@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@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@supmenow.com <james@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@apple.com> > wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@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@supmenow.com <james@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@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@swift.org> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users < >>> swift-users@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@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users


(Daniel Dunbar) #13

(+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@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@apple.com>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


(Jordan Rose) #14

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@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@apple.com>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


(Jordan Rose) #15

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@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@apple.com>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


(Rainer Brockerhoff) #16

I'm not following the macro issue as closely as I maybe should, but in
my current ObjC apps I depend on GCC_PREPROCESSOR_DEFINITIONS to
conditionally include sections of code (or not). (I don't however use it
to directly expand as a macro value.)

This is typically to accomodate differences between Mac App Store and
Developer ID builds, by defining these values in .xcconfig files.

Hopefully some mechanism like this will be available in Swift #if ?

···

On 3/24/16 14:05, Jordan Rose via swift-users 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.

--
Rainer Brockerhoff <rainer@brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/


(James Campbell) #17

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

···

*___________________________________*

*James⎥Head Of CEO*

*james@supmenow.com <james@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@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@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@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@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@supmenow.com <james@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@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@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@supmenow.com <james@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@apple.com> >> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@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@supmenow.com <james@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@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@swift.org> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users < >>>> swift-users@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@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users


(Jordan Rose) #18

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.

The "2.2 is a minor update and shouldn't have changed behavior here" is a fair point.

Jordan

···

On Mar 24, 2016, at 10:25, James Campbell <james@supmenow.com> wrote:

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

___________________________________

James⎥Head Of CEO

james@supmenow.com <mailto:james@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@apple.com <mailto:jordan_rose@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@apple.com <mailto:jordan_rose@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@apple.com>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


(James Campbell) #19

Okay that helps, in my case the macros contain mostly strings. API Keys,
Endpoints and secrets. So something like this should work ?

static const kAPI_ENDPOINT = API_ENDPOINT

which will then be imported into Swift as:

let endpoint = kAPI_ENDPOINT

···

*___________________________________*

*James⎥Head Of CEO*

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

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

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

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.

The "2.2 is a minor update and shouldn't have changed behavior here" is a
fair point.

Jordan

On Mar 24, 2016, at 10:25, James Campbell <james@supmenow.com> wrote:

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

*___________________________________*

*James⎥Head Of CEO*

*james@supmenow.com <james@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@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@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@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@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@supmenow.com <james@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@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@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@supmenow.com <james@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@apple.com> >>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@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@supmenow.com <james@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@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@swift.org> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users < >>>>> swift-users@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@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users


(Jordan Rose) #20

Yes, with a type. So either

static NSString * const kAPI_ENDPOINT = @ API_ENDPOINT;

or

static const char *kAPI_ENDPOINT = API_ENDPOINT;

Jordan

···

On Mar 24, 2016, at 10:55, James Campbell <james@supmenow.com> wrote:

Okay that helps, in my case the macros contain mostly strings. API Keys, Endpoints and secrets. So something like this should work ?

static const kAPI_ENDPOINT = API_ENDPOINT

which will then be imported into Swift as:

let endpoint = kAPI_ENDPOINT

___________________________________

James⎥Head Of CEO

james@supmenow.com <mailto:james@supmenow.com>⎥supmenow.com <http://supmenow.com/>
Sup

Runway East >

10 Finsbury Square

London

> EC2A 1AF

On Thu, Mar 24, 2016 at 5:46 PM, Jordan Rose <jordan_rose@apple.com <mailto:jordan_rose@apple.com>> wrote:
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.

The "2.2 is a minor update and shouldn't have changed behavior here" is a fair point.

Jordan

On Mar 24, 2016, at 10:25, James Campbell <james@supmenow.com <mailto:james@supmenow.com>> wrote:

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

___________________________________

James⎥Head Of CEO

james@supmenow.com <mailto:james@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@apple.com <mailto:jordan_rose@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@apple.com <mailto:jordan_rose@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@apple.com>> wrote:

On Mar 24, 2016, at 5:21 AM, James Campbell <james@supmenow.com <mailto:james@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@supmenow.com <mailto:james@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@apple.com <mailto:daniel_dunbar@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@swift.org <mailto:swift-users@swift.org>> wrote:
>
>
>> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users <swift-users@swift.org <mailto:swift-users@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@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users