0
A
回答
1
我建議設立兩個模式。
第一個:開發 - >設置與Debug
構建配置。 您可以在開發應用時使用此功能。這會給你日誌記錄,調試容易等。
第二個:配置 - >設置與Release
構建配置。 日誌記錄不會發生在這個模式上,調試也將不可用,因爲構建沒有爲此優化。
當您準備向App Store提交資料時,請使用Release
構建配置來歸檔Distribution模式。
有關Debug
和Release
構建配置之間的區別的更多詳細說明here。
0
這將深入探討您的問題。我使用了構建配置環境,以便在發佈配置中進行構建。您的自動值將根據發佈版本進行調整。您還可以從下面的鏈接下載示例代碼,以實際瞭解更改方案時會發生什麼情況。
第一步。
在info.plist中添加變量「Configuration」,並在其中添加值「$(CONFIGURATION)」。
製作一個Config.swift文件並複製粘貼下面的代碼。
`
import Foundation
private let configManagerSharedInstance = ConfigManager()
class Config {
class var sharedInstance: ConfigManager {
return configManagerSharedInstance
}
}
// You can put as much Environment as you need but you make sure you also put these environment in the config.plist file.
enum Environment: String {
case Debug = "Debug"
case Production = "Release"
}
class ConfigManager: NSObject {
private var environment: Environment?
var config: NSDictionary?
override init() {
super.init()
// Retrieve the current evironment from the main bundle
if let currentEnvironment = Bundle.main.infoDictionary?["Configuration"] as? String {
// Store the current environment for later use
environment = Environment(rawValue: currentEnvironment)
if let projectConfigPath = Bundle.main.path(forResource: "Config", ofType: "plist") {
if let projectConfigContents = NSDictionary(contentsOfFile: projectConfigPath) as? Dictionary<String, AnyObject> {
config = projectConfigContents[currentEnvironment] as? Dictionary<String, AnyObject> as NSDictionary?
}
} else {
print("config file not found")
}
}
}
func getCurrentEnvironment() -> Environment? {
return self.environment
}
func configForKey(key: String) -> String {
return config?[key] as! String
}
//It will use to get sub dictionary and their values.
func configForCategory(category: String, andKey: String) -> String {
let configuration = config?.value(forKeyPath: category) as! NSDictionary
return configuration.value(forKeyPath: andKey) as! String
}
}
`
我也取得了文件Constants.swift在我所使用上述代碼設定的可變因素。 `
//
// Constants.swift
// BuildConfiguration
//
// Created by Ourangzaib khan on 4/6/17.
// Copyright © 2017 Ourangzaib khan. All rights reserved.
//
let kBASE_URL : String = {
print(Config.sharedInstance.configForKey(key: "kBASE_URL"));
return Config.sharedInstance.configForKey(key: "kBASE_URL")
}()
let STRIPEKEY : String = {
return Config.sharedInstance.configForCategory(category: "Stripe", andKey: "Publishable Key")
}()
let PUBNUBKEYSUBSCRIBE : String = {
return Config.sharedInstance.configForCategory(category: "PubNub", andKey: "Publish Key")
}()
let PUBNUBKEYPUBLISH : String = {
return Config.sharedInstance.configForCategory(category: "PubNub", andKey: "Subscribe Key")
}()
let WOWZAKEY : String = {
return Config.sharedInstance.configForKey(key: "Wowza");
}()
`
現在你只需要使用編輯sceme進入編輯方案來選擇環境和選擇構建配置現在,當你運行該項目,你會看到這樣的輸出WRT在下面的圖像中構建配置。
相關問題
- 1. 我應該創建一個構造函數與設置器
- 2. 我應該使用在Xcode
- 3. 我應該創建類還是創建?
- 4. 在設置應用程序中創建應用程序設置
- 5. 我應該設置AssemblyConfigurationAttribute嗎?
- 6. 我應該設置爲_ITERATOR_DEBUG_LEVEL
- 7. 我應該使用哪些Xcode設置來支持armv6和armv7?
- 8. 我應該爲Pods.xcproj「更新爲推薦設置」,Xcode 9
- 9. 我應該在JSF應用程序中創建我的ConnectionPool?
- 10. 我應該在我的應用中默認設置Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture?
- 11. 我應該在哪裏創建pthread
- 12. 當我應該創建在C#
- 13. 我應該在運行時創建
- 14. 在其列,我應該創建索引
- 15. 我應該在類中創建單獨的屬性還是僅創建一個設置值的方法?
- 16. 在Xcode中使用設備UDID在Xcode中創建.app文件
- 17. 在xcode 4中編輯構建設置
- 18. 設置Xcode項目來輕鬆創建「子應用程序」
- 19. 我應該如何創建我的GUID?
- 20. 閱讀用戶定義在Xcode中創建設置
- 21. 在Xcode 4中,如何創建多共享項目設置?
- 22. 我應該如何設置我的DATABASE_URL?
- 23. 我應該如何使用MySQL構建我的設置表?
- 24. 我無法在XCode中創建插座
- 25. 我應該在哪裏在Xcode
- 26. 我應該在django 1.4中創建django應用程序?
- 27. 我應該在iOS中創建我的ivars屬性嗎?
- 28. 我應該如何在nodejs應用程序中設置auth?
- 29. 我應該在asp.net應用程序中將generatePublisherEvidence設置爲false?
- 30. 如果我要在java中創建應用程序配置xml文件,我應該在哪裏放置它?
如果你是指打印()日誌記錄,將在發佈發生還建立,如果你不積極鎮壓。 – shallowThought