diff --git a/ShadowsocksX-NG.xcodeproj/project.pbxproj b/ShadowsocksX-NG.xcodeproj/project.pbxproj index 042788d..4ae0950 100755 --- a/ShadowsocksX-NG.xcodeproj/project.pbxproj +++ b/ShadowsocksX-NG.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 08FCA0FF1E24BE1A0070984F /* example-gui-config.json in Resources */ = {isa = PBXBuildFile; fileRef = 08FCA0FE1E24BE1A0070984F /* example-gui-config.json */; }; 258E511BA910B0521B24DAB8 /* Pods_ShadowsocksX_NG.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 283ED1A8E9B711AC65670031 /* Pods_ShadowsocksX_NG.framework */; }; 9B07EFA71D048BBB0052D9DF /* ss-local in Resources */ = {isa = PBXBuildFile; fileRef = 9B07EFA61D048BBB0052D9DF /* ss-local */; }; 9B07EFAC1D048E880052D9DF /* menu_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B07EFA81D048E880052D9DF /* menu_icon@2x.png */; }; @@ -94,6 +95,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 08FCA0FE1E24BE1A0070984F /* example-gui-config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "example-gui-config.json"; sourceTree = ""; }; 19083CFCED87354F006967FF /* Pods_ShadowsocksX_NGUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ShadowsocksX_NGUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1E7783AEDB4A3BDDC9FF16AC /* libPods-proxy_conf_helper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-proxy_conf_helper.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 283ED1A8E9B711AC65670031 /* Pods_ShadowsocksX_NG.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ShadowsocksX_NG.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -229,6 +231,7 @@ 9B07EFB01D048E900052D9DF /* Support Files */ = { isa = PBXGroup; children = ( + 08FCA0FE1E24BE1A0070984F /* example-gui-config.json */, C6D4298E1DA75988002A5711 /* install_privoxy.sh */, C6D4298F1DA75988002A5711 /* privoxy */, C6D429901DA75988002A5711 /* reload_conf_privoxy.sh */, @@ -493,6 +496,7 @@ C6D429951DA75988002A5711 /* reload_conf_privoxy.sh in Resources */, 9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */, 9B2491B71D0ACC3E003BBECC /* AdvPreferencesWindowController.xib in Resources */, + 08FCA0FF1E24BE1A0070984F /* example-gui-config.json in Resources */, 9B3FFF271D0898EB0019A709 /* gfwlist.txt in Resources */, C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */, 9BC70EDC1D2E3E3100EDA4CA /* Localizable.strings in Resources */, diff --git a/ShadowsocksX-NG/ServerProfileManager.swift b/ShadowsocksX-NG/ServerProfileManager.swift index 82448f6..92df92c 100644 --- a/ShadowsocksX-NG/ServerProfileManager.swift +++ b/ShadowsocksX-NG/ServerProfileManager.swift @@ -99,8 +99,8 @@ class ServerProfileManager: NSObject { profile.remark = item["remarks"] as! String self.profiles.append(profile) self.save() - NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil) } + NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil) let configsCount = (jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]).count let notification = NSUserNotification() notification.title = "Import Server Profile succeed!".localized @@ -123,7 +123,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) @@ -168,7 +168,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"