var serverUrl: String = ""if let filePath = NSBundle.mainBundle().pathForResource("Settings", ofType: "plist") { let contentsOfFile = NSDictionary(contentsOfFile: filePath) serverUrl = contentsOfFile?.objectForKey("ServerUrl") as! String } else { // no settings! }8.接下来设置应用构建时的配置环境,点击菜单栏中的Product -> Scheme -> Edit Scheme,选中左侧Action列表栏中的"Run",然后在右侧选择Development或Production配置
9.同样,你需要为其他的Action,如Test,Profile,Analyze和Archive选择构建配置。比如,你对Production进行运行/测试时,请确保在将其打包上传至TestFlight前,把"Archive"Action的构建配置设为"Production"! CocoaPods注意事项:
如果在添加新的Devlopment和Production配置之前,你已经在项目中使用了CocoaPods,那么就可能会遇到错误,比如,“[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target … in your build configuration”,或者与pods相关的链接器错误。
要解决这些问题,你需要到Project setting区域的info栏(和步骤1相同位置),将所有新增配置的"Based on Configuration File" 设置为 "None",然后运行"pod install",强制pod工具为新创建的配置重新生成配置文件。同样如果后面你又添加了新的配置,你需要重复上面操作。