diff --git a/ShadowsocksX-NG.xcodeproj/project.pbxproj b/ShadowsocksX-NG.xcodeproj/project.pbxproj index 937e6ec..d4d9ac0 100644 --- a/ShadowsocksX-NG.xcodeproj/project.pbxproj +++ b/ShadowsocksX-NG.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ 9B3FFF4C1D09D8F70019A709 /* install_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */; }; 9B3FFF4F1D09D9D50019A709 /* ProxyConfHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF4E1D09D9D50019A709 /* ProxyConfHelper.m */; }; 9B3FFF541D09E2D10019A709 /* proxy_conf_helper in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF441D09CD3B0019A709 /* proxy_conf_helper */; }; + 9BE8FBBF1D0B211600CAFD01 /* libcrypto.1.0.0.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */; }; 9BEEF0691D04D4D500FC52B3 /* install_ss_local.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9BEEF0651D04CB8500FC52B3 /* install_ss_local.sh */; }; 9BEEF06A1D04D4D500FC52B3 /* start_ss_local.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9BEEF0661D04CE8D00FC52B3 /* start_ss_local.sh */; }; 9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9BEEF0671D04CE9A00FC52B3 /* stop_ss_local.sh */; }; @@ -148,6 +149,7 @@ 9B3FFF4E1D09D9D50019A709 /* ProxyConfHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProxyConfHelper.m; sourceTree = ""; }; 9B3FFF501D09DAEA0019A709 /* proxy_conf_helper_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = proxy_conf_helper_version.h; sourceTree = ""; }; 9B3FFF511D09DBA20019A709 /* ShadowsocksX-NG-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ShadowsocksX-NG-Bridging-Header.h"; sourceTree = ""; }; + 9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcrypto.1.0.0.dylib; sourceTree = ""; }; 9BEEF0651D04CB8500FC52B3 /* install_ss_local.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = install_ss_local.sh; sourceTree = ""; }; 9BEEF0661D04CE8D00FC52B3 /* start_ss_local.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = start_ss_local.sh; sourceTree = ""; }; 9BEEF0671D04CE9A00FC52B3 /* stop_ss_local.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stop_ss_local.sh; sourceTree = ""; }; @@ -217,6 +219,7 @@ 9B07EFB01D048E900052D9DF /* Support Files */ = { isa = PBXGroup; children = ( + 9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */, 9B172A6C1D0ADDDD00B87B9A /* Localizable.strings */, 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */, 9B3FFF351D08CF110019A709 /* jquery.min.js */, @@ -480,6 +483,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9BE8FBBF1D0B211600CAFD01 /* libcrypto.1.0.0.dylib in Resources */, 9B3FFF541D09E2D10019A709 /* proxy_conf_helper in Resources */, 9BEEF0691D04D4D500FC52B3 /* install_ss_local.sh in Resources */, 9B172A6A1D0ADDDD00B87B9A /* Localizable.strings in Resources */, @@ -878,6 +882,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SDKROOT)/usr/lib/system", + "$(PROJECT_DIR)/ShadowsocksX-NG", ); MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "com.qiuyuzhou.ShadowsocksX-NG"; @@ -903,6 +908,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SDKROOT)/usr/lib/system", + "$(PROJECT_DIR)/ShadowsocksX-NG", ); MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "com.qiuyuzhou.ShadowsocksX-NG"; diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 1a1865a..a71c3db 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -125,6 +125,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele ProxyConfHelper.install() applyConfig() + SyncSSLocal() } func applicationWillTerminate(aNotification: NSNotification) { diff --git a/ShadowsocksX-NG/LaunchAgentUtils.swift b/ShadowsocksX-NG/LaunchAgentUtils.swift index b2df3e4..5ea5554 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -21,7 +21,8 @@ func getFileSHA1Sum(filepath: String) -> String { return "" } - +// Ref: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html +// Genarate the mac launch agent service plist func generateSSLocalLauchAgentPlist() -> Bool { let sslocalPath = NSHomeDirectory() + APP_SUPPORT_DIR + "ss-local" let logFilePath = NSHomeDirectory() + "/Library/Logs/ss-local.log" @@ -42,13 +43,15 @@ func generateSSLocalLauchAgentPlist() -> Bool { } } + // For a complete listing of the keys, see the launchd.plist manual page. let dict: NSMutableDictionary = [ "Label": "com.qiuyuzhou.shadowsocksX-NE.local", "WorkingDirectory": NSHomeDirectory() + APP_SUPPORT_DIR, "KeepAlive": true, "StandardOutPath": logFilePath, "StandardErrorPath": logFilePath, - "ProgramArguments": arguments + "ProgramArguments": arguments, + "EnvironmentVariables": ["DYLD_LIBRARY_PATH": NSHomeDirectory() + APP_SUPPORT_DIR] ] dict.writeToFile(plistFilepath, atomically: true) let Sha1Sum = getFileSHA1Sum(plistFilepath) @@ -98,7 +101,9 @@ func StopSSLocal() { func InstallSSLocal() { let fileMgr = NSFileManager.defaultManager() let homeDir = NSHomeDirectory() - if !fileMgr.fileExistsAtPath(homeDir+APP_SUPPORT_DIR+SS_LOCAL_VERSION+"/ss-local") { + let appSupportDir = homeDir+APP_SUPPORT_DIR + if !fileMgr.fileExistsAtPath(appSupportDir + SS_LOCAL_VERSION + "/ss-local") + || !fileMgr.fileExistsAtPath(appSupportDir + "libcrypto.1.0.0.dylib") { let bundle = NSBundle.mainBundle() let installerPath = bundle.pathForResource("install_ss_local.sh", ofType: nil) let task = NSTask.launchedTaskWithLaunchPath(installerPath!, arguments: [""]) diff --git a/ShadowsocksX-NG/install_ss_local.sh b/ShadowsocksX-NG/install_ss_local.sh index 0540660..a0b6dcd 100755 --- a/ShadowsocksX-NG/install_ss_local.sh +++ b/ShadowsocksX-NG/install_ss_local.sh @@ -12,6 +12,7 @@ mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NE/ss-local-2.4.6" cp -f ss-local "$HOME/Library/Application Support/ShadowsocksX-NE/ss-local-2.4.6/" rm -f "$HOME/Library/Application Support/ShadowsocksX-NE/ss-local" ln -s "$HOME/Library/Application Support/ShadowsocksX-NE/ss-local-2.4.6/ss-local" "$HOME/Library/Application Support/ShadowsocksX-NE/ss-local" -#cp -f "com.qiuyuzhou.shadowsocksX-NE.local.plist" "$HOME/Library/LaunchAgents/" + +cp -f libcrypto.1.0.0.dylib "$HOME/Library/Application Support/ShadowsocksX-NE/" echo done \ No newline at end of file diff --git a/ShadowsocksX-NG/libcrypto.1.0.0.dylib b/ShadowsocksX-NG/libcrypto.1.0.0.dylib new file mode 100644 index 0000000..1c5325d Binary files /dev/null and b/ShadowsocksX-NG/libcrypto.1.0.0.dylib differ