Referring to Environment Variables in Swift

后端 未结 4 1291
野的像风
野的像风 2020-12-08 13:00

Does anybody know how I can grab an environment variable in Swift?

4条回答
  •  囚心锁ツ
    2020-12-08 13:34

    Yes it is possible. Use ProcessInfo for that.

    Simple example :

    let dic = ProcessInfo.processInfo.environment
    if dic["VAR"] != nil {
    
    }
    

提交回复
热议问题