Swift 2.2: GCC_PREPROCESSOR_DEFINITIONS constants no longer imported

swift, xcode

Solution

Thanks for pointing to the bug, would not have figured this one out in a while. If it's any help I ended up adding an additional objc constants bridge to Swift and using the bridge constants from swift:

// Constants.h
extern NSString *const kDropBoxAPIKey;

// Constants.m
NSString *const kDropBoxAPIKey = DROPBOX_API_KEY;

// xxx-Bridging-Header.h
#import "Constants.h"

Then use the bridged key in Swift

// xx.swift
...
// let auth = DropboxAuth(appKey: DROPBOX_API_KEY) 
let auth = DropboxAuth(appKey: kDropBoxAPIKey)
...

Problem

The technique to separate API keys in a xcconfig file described in this answer doesn't work with Swift 2.2 due to a bug (SR-909). Is there any workaround?

Original source

Related problems