swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.27k stars 10.33k forks source link

[SR-1045] Serious Issue with unable to use Macros defined in Project Preprocessor Build Setting With Xcode 7.3 and Swift. #43657

Open swift-ci opened 8 years ago

swift-ci commented 8 years ago
Previous ID SR-1045
Radar https://openradar.appspot.com/25322018
Original Reporter jscampbell05 (JIRA User)
Type Bug

Attachment: Download

Environment Xcode 7.3, OS X 10.11, Swift 2.2
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, ClangImporter | |Assignee | None | |Priority | Medium | md5: 2f6f4152186372585254b5d992921f7c

Issue Description:

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?

belkadan commented 8 years ago

Please attach a self-contained test case, so that we know we're seeing the same issue. (It's very possible this is an Xcode issue rather than a Swift issue, in which case this would not be the right place to file it.)

swift-ci commented 8 years ago

Comment by James Campbell (JIRA)

I've attached a project. This works in Xcode 7.2 but not Xcode 7.3.

swift-ci commented 8 years ago

Comment by Joaquin (JIRA)

Is there any updates on this? I'm facing the same problem with Xcode 7.3

swift-ci commented 8 years ago

Comment by James Campbell (JIRA)

Patrono (JIRA User) The compiler team said that this was unintended behaviour in earlier version of Swift.

To still use it you have to bridge the macros in like so:

Macros.h (Included in the bridging header):

static NSString * const kENDPOINT_MACRO = ENDPOINT_MACRO;

Code.swift:

print(kENDPOINT_MACRO)

swift-ci commented 8 years ago

Comment by Joaquin (JIRA)

jscampbell05 (JIRA User) thanks for that solution!

ec882e32-f2b6-4d2a-849c-98d6c7df0cfb commented 7 years ago

If this is the desired behavior, should this task be closed as invalid?