From 1e4ad0b1084ce6aa1716ab2edf0b879df7fa846a Mon Sep 17 00:00:00 2001 From: qinyuhang Date: Tue, 10 Jan 2017 15:02:54 +0800 Subject: [PATCH] add examplejson to Xcode project file add examplejson to Xcode project file fix resource method --- ShadowsocksX-NG.xcodeproj/project.pbxproj | 17 ++++------------- ShadowsocksX-NG/ServerProfileManager.swift | 6 +++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/ShadowsocksX-NG.xcodeproj/project.pbxproj b/ShadowsocksX-NG.xcodeproj/project.pbxproj index 2afa29a..1de1a92 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 */; }; @@ -96,18 +97,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 083BF8311D82731900831C68 /* SimplePing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimplePing.h; sourceTree = ""; }; - 083BF8321D82731900831C68 /* SimplePing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimplePing.m; sourceTree = ""; }; - 083BF8341D82742200831C68 /* NetWorkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetWorkMonitor.swift; sourceTree = ""; }; - 083BF8351D82742200831C68 /* PingClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PingClient.swift; sourceTree = ""; }; - 083BF8381D82759600831C68 /* StatusItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusItemView.swift; sourceTree = ""; }; - 083BF83A1D8275A800831C68 /* SystemThemeChangeHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemThemeChangeHelper.swift; sourceTree = ""; }; - 085641E91D7188C400116B27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; - 08805F181D878CA5009B53E7 /* PingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PingTest.swift; sourceTree = ""; }; - 0880CE3F1D6FE6D900BD39E2 /* example-gui-config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "example-gui-config.json"; sourceTree = ""; }; - 088EC3961D5F5B8600E40791 /* whitelist.pac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = whitelist.pac; sourceTree = ""; }; - 088EC3981D5F5BA300E40791 /* whiteiplist.pac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = whiteiplist.pac; sourceTree = ""; }; - 08AF56C01D6AFA7C00DC4F46 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/PreferencesWindowController.strings"; sourceTree = ""; }; + 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; }; @@ -245,6 +235,7 @@ 9B07EFB01D048E900052D9DF /* Support Files */ = { isa = PBXGroup; children = ( + 08FCA0FE1E24BE1A0070984F /* example-gui-config.json */, C6D4298E1DA75988002A5711 /* install_privoxy.sh */, C6D4298F1DA75988002A5711 /* privoxy */, C6D429901DA75988002A5711 /* reload_conf_privoxy.sh */, @@ -505,7 +496,6 @@ 9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */, C6D429941DA75988002A5711 /* privoxy in Resources */, C6D429991DA76FBC002A5711 /* privoxy.config.example in Resources */, - 0880CE401D6FE6D900BD39E2 /* example-gui-config.json in Resources */, 9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */, 9B3FFF341D08CEF70019A709 /* SWBQRCodeWindowController.xib in Resources */, 9BEEF06C1D04D4D500FC52B3 /* reload_conf_ss_local.sh in Resources */, @@ -514,6 +504,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 */, 9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */, 9B3FFF271D0898EB0019A709 /* gfwlist.txt in Resources */, C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */, diff --git a/ShadowsocksX-NG/ServerProfileManager.swift b/ShadowsocksX-NG/ServerProfileManager.swift index 900503e..cc3ee82 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"