From 6fc13af5fe080971de736c22ff502e8c96e924b9 Mon Sep 17 00:00:00 2001 From: qinyuhang Date: Tue, 10 Jan 2017 14:49:26 +0800 Subject: [PATCH] Fix Bundle Path logic --- ShadowsocksX-NG/ServerProfileManager.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ShadowsocksX-NG/ServerProfileManager.swift b/ShadowsocksX-NG/ServerProfileManager.swift index b562b94..9293dfc 100644 --- a/ShadowsocksX-NG/ServerProfileManager.swift +++ b/ShadowsocksX-NG/ServerProfileManager.swift @@ -137,7 +137,7 @@ class ServerProfileManager: NSObject { //读取example文件,删掉configs里面的配置,再用NSDictionary填充到configs里面 let fileManager = FileManager.default - let filePath:String = Bundle.main.bundlePath + "/Contents/Resources/example-gui-config.json" + let filePath:String = Bundle.main.path(forResource: "example-gui-config", ofType: "json")! let data = fileManager.contents(atPath: filePath) let readString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)! let readStringData = readString.data(using: String.Encoding.utf8.rawValue) @@ -196,7 +196,7 @@ class ServerProfileManager: NSObject { class func showExampleConfigFile() { //copy file to ~/Downloads folder - let filePath:String = Bundle.main.bundlePath + "/Contents/Resources/example-gui-config.json" + let filePath:String = Bundle.main.path(forResource: "example-gui-config", ofType: "json")! let fileMgr = FileManager.default let dataPath = NSHomeDirectory() + "/Downloads" let destPath = dataPath + "/example-gui-config.json"