【发布时间】:2018-12-13 00:24:06
【问题描述】:
说明
我的环境变量有问题。当我构建我的应用程序并运行时,一切正常,但是当我按下“停止”或将其归档到应用商店时,环境变量返回 nil(或空字符串,我还不太确定)。
如何重现:
- 构建应用程序
- 在模拟器上运行(会出现“Hello world”)
- 停止应用
- 在模拟器中,返回应用程序(“Hello word”不会出现)
最小复制:
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
label.text = ProcessInfo.processInfo.environment["testVariable"]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
标签 Outlet 引用了一个简单的故事板
这是我的环境变量的配置
最后,这里是 github repo 上问题的最小再现 https://github.com/MasterBroki/test-environment-variable
感谢您的回答!
【问题讨论】:
标签: swift environment-variables tvos