Swift 2.2:不再导入 GCC_PREPROCESSOR_DEFINITIONS 常量 [英] Swift 2.2: GCC_PREPROCESSOR_DEFINITIONS constants no longer imported

查看:41
本文介绍了Swift 2.2:不再导入 GCC_PREPROCESSOR_DEFINITIONS 常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此答案中描述的 xcconfig 文件中分离 API 密钥的技术不适用于 Swift 2.2 由于错误 (SR-909).

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

有什么解决办法吗?

推荐答案

感谢您指出错误,一时之间不会想到这个问题.如果有任何帮助,我最终会向 Swift 添加一个额外的 objc 常量桥并使用 swift 中的桥常量:

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"

然后在 Swift 中使用桥接密钥

Then use the bridged key in Swift

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

这篇关于Swift 2.2:不再导入 GCC_PREPROCESSOR_DEFINITIONS 常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆