From 34c5f4e439672b1a0d19bc7a697454a48746a2d0 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Mon, 22 Oct 2018 21:41:07 -0400 Subject: [PATCH 01/15] working on install --- Speculid-Mac-Installer/Info.plist | 31 ++++ .../Speculid_Mac_Installer.h | 14 ++ .../Speculid_Mac_Installer.m | 19 +++ .../Speculid_Mac_InstallerProtocol.h | 36 +++++ Speculid-Mac-Installer/main.m | 49 ++++++ Speculid.xcodeproj/project.pbxproj | 146 ++++++++++++++++++ .../xcschemes/Speculid-Mac-App.xcscheme | 4 + applications/command/main.swift | 22 ++- applications/mac/Application.swift | 3 +- .../Controllers/CairoConversionSet.swift | 3 +- .../Controllers/CommandLineInstaller.swift | 23 +++ .../Controllers/CommandLineRunner.swift | 9 +- .../RemoteObjectInterfaceProvider.swift | 3 +- .../SpeculidApplicationModeParser.swift | 2 + .../speculid/Models/AssetSpecification.swift | 3 +- frameworks/speculid/Models/InstallType.swift | 13 ++ .../speculid/Models/RegularExpressions.swift | 6 +- .../Models/SpeculidCommandArgumentSet.swift | 1 + .../Protocols/AnalyticsTrackerProtocol.swift | 3 +- .../Protocols/SpeculidArgumentsProtocol.swift | 3 +- 20 files changed, 362 insertions(+), 31 deletions(-) create mode 100644 Speculid-Mac-Installer/Info.plist create mode 100644 Speculid-Mac-Installer/Speculid_Mac_Installer.h create mode 100644 Speculid-Mac-Installer/Speculid_Mac_Installer.m create mode 100644 Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h create mode 100644 Speculid-Mac-Installer/main.m create mode 100644 frameworks/speculid/Controllers/CommandLineInstaller.swift create mode 100644 frameworks/speculid/Models/InstallType.swift diff --git a/Speculid-Mac-Installer/Info.plist b/Speculid-Mac-Installer/Info.plist new file mode 100644 index 00000000..f6df5ea1 --- /dev/null +++ b/Speculid-Mac-Installer/Info.plist @@ -0,0 +1,31 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Speculid-Mac-Installer + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright © 2018 Bright Digit, LLC. All rights reserved. + XPCService + + ServiceType + Application + + + diff --git a/Speculid-Mac-Installer/Speculid_Mac_Installer.h b/Speculid-Mac-Installer/Speculid_Mac_Installer.h new file mode 100644 index 00000000..c457615c --- /dev/null +++ b/Speculid-Mac-Installer/Speculid_Mac_Installer.h @@ -0,0 +1,14 @@ +// +// Speculid_Mac_Installer.h +// Speculid-Mac-Installer +// +// Created by Leo Dion on 10/22/18. +// Copyright © 2018 Bright Digit, LLC. All rights reserved. +// + +#import +#import "Speculid_Mac_InstallerProtocol.h" + +// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection. +@interface Speculid_Mac_Installer : NSObject +@end diff --git a/Speculid-Mac-Installer/Speculid_Mac_Installer.m b/Speculid-Mac-Installer/Speculid_Mac_Installer.m new file mode 100644 index 00000000..370e48fc --- /dev/null +++ b/Speculid-Mac-Installer/Speculid_Mac_Installer.m @@ -0,0 +1,19 @@ +// +// Speculid_Mac_Installer.m +// Speculid-Mac-Installer +// +// Created by Leo Dion on 10/22/18. +// Copyright © 2018 Bright Digit, LLC. All rights reserved. +// + +#import "Speculid_Mac_Installer.h" + +@implementation Speculid_Mac_Installer + +// This implements the example protocol. Replace the body of this class with the implementation of this service's protocol. +- (void)upperCaseString:(NSString *)aString withReply:(void (^)(NSString *))reply { + NSString *response = [aString uppercaseString]; + reply(response); +} + +@end diff --git a/Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h b/Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h new file mode 100644 index 00000000..20655806 --- /dev/null +++ b/Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h @@ -0,0 +1,36 @@ +// +// Speculid_Mac_InstallerProtocol.h +// Speculid-Mac-Installer +// +// Created by Leo Dion on 10/22/18. +// Copyright © 2018 Bright Digit, LLC. All rights reserved. +// + +#import + +// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service. +@protocol Speculid_Mac_InstallerProtocol + +// Replace the API of this protocol with an API appropriate to the service you are vending. +- (void)upperCaseString:(NSString *)aString withReply:(void (^)(NSString *))reply; + +@end + +/* + To use the service from an application or other process, use NSXPCConnection to establish a connection to the service by doing something like this: + + _connectionToService = [[NSXPCConnection alloc] initWithServiceName:@"com.brightdigit.Speculid-Mac-Installer"]; + _connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(Speculid_Mac_InstallerProtocol)]; + [_connectionToService resume]; + +Once you have a connection to the service, you can use it like this: + + [[_connectionToService remoteObjectProxy] upperCaseString:@"hello" withReply:^(NSString *aString) { + // We have received a response. Update our text field, but do it on the main thread. + NSLog(@"Result string was: %@", aString); + }]; + + And, when you are finished with the service, clean up the connection like this: + + [_connectionToService invalidate]; +*/ diff --git a/Speculid-Mac-Installer/main.m b/Speculid-Mac-Installer/main.m new file mode 100644 index 00000000..f673bb3c --- /dev/null +++ b/Speculid-Mac-Installer/main.m @@ -0,0 +1,49 @@ +// +// main.m +// Speculid-Mac-Installer +// +// Created by Leo Dion on 10/22/18. +// Copyright © 2018 Bright Digit, LLC. All rights reserved. +// + +#import +#import "Speculid_Mac_Installer.h" + +@interface ServiceDelegate : NSObject +@end + +@implementation ServiceDelegate + +- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection { + // This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection. + + // Configure the connection. + // First, set the interface that the exported object implements. + newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(Speculid_Mac_InstallerProtocol)]; + + // Next, set the object that the connection exports. All messages sent on the connection to this service will be sent to the exported object to handle. The connection retains the exported object. + Speculid_Mac_Installer *exportedObject = [Speculid_Mac_Installer new]; + newConnection.exportedObject = exportedObject; + + // Resuming the connection allows the system to deliver more incoming messages. + [newConnection resume]; + + // Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO. + return YES; +} + +@end + +int main(int argc, const char *argv[]) +{ + // Create the delegate for the service. + ServiceDelegate *delegate = [ServiceDelegate new]; + + // Set up the one NSXPCListener for this service. It will handle all incoming connections. + NSXPCListener *listener = [NSXPCListener serviceListener]; + listener.delegate = delegate; + + // Resuming the serviceListener starts this service. This method does not return. + [listener resume]; + return 0; +} diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 4a06dc14..c59fe94a 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -306,6 +306,12 @@ B341888A1F9A44A700C5F356 /* CommandLineArgumentProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34188891F9A44A700C5F356 /* CommandLineArgumentProviderProtocol.swift */; }; B341888E1F9A460300C5F356 /* CommandLineArgumentProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B341888D1F9A460300C5F356 /* CommandLineArgumentProvider.swift */; }; B34188911F9A479900C5F356 /* SpeculidApplicationModeParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34188901F9A479900C5F356 /* SpeculidApplicationModeParserTest.swift */; }; + B34B52C8217E5D700080E6DC /* InstallType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34B52C7217E5D700080E6DC /* InstallType.swift */; }; + B34B52CA217E5FC40080E6DC /* CommandLineInstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34B52C9217E5FC40080E6DC /* CommandLineInstaller.swift */; }; + B34B52D4217E69CE0080E6DC /* Speculid_Mac_Installer.m in Sources */ = {isa = PBXBuildFile; fileRef = B34B52D3217E69CE0080E6DC /* Speculid_Mac_Installer.m */; }; + B34B52D6217E69CE0080E6DC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B34B52D5217E69CE0080E6DC /* main.m */; }; + B34B52DA217E69CE0080E6DC /* Speculid-Mac-Installer.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + B34B52DF217EB2670080E6DC /* Speculid-Mac-Installer.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; B34E82FB1F8FD4EF0032268F /* ImageFileFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = B34E82FA1F8FD4EF0032268F /* ImageFileFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; B34E82FF1F8FD6860032268F /* ImageFileProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B34E82FE1F8FD6860032268F /* ImageFileProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; B34E83041F8FD90C0032268F /* GlibError.h in Headers */ = {isa = PBXBuildFile; fileRef = B34E83021F8FD90C0032268F /* GlibError.h */; }; @@ -1010,6 +1016,13 @@ remoteGlobalIDString = B37C74881F8C5B5C00DF505B; remoteInfo = CairoSVG; }; + B34B52D8217E69CE0080E6DC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B37C74361F8C58F300DF505B /* Project object */; + proxyType = 1; + remoteGlobalIDString = B34B52CE217E69CE0080E6DC; + remoteInfo = "Speculid-Mac-Installer"; + }; B37C745C1F8C590D00DF505B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B37C74361F8C58F300DF505B /* Project object */; @@ -1052,6 +1065,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B34B52DE217EB2530080E6DC /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 1; + files = ( + B34B52DF217EB2670080E6DC /* Speculid-Mac-Installer.xpc in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B37C74621F8C590D00DF505B /* Embed XPC Services */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1059,6 +1082,7 @@ dstSubfolderSpec = 16; files = ( B37C745E1F8C590D00DF505B /* Speculid-Mac-XPC.xpc in Embed XPC Services */, + B34B52DA217E69CE0080E6DC /* Speculid-Mac-Installer.xpc in Embed XPC Services */, ); name = "Embed XPC Services"; runOnlyForDeploymentPostprocessing = 0; @@ -1537,6 +1561,14 @@ B34188891F9A44A700C5F356 /* CommandLineArgumentProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandLineArgumentProviderProtocol.swift; sourceTree = ""; }; B341888D1F9A460300C5F356 /* CommandLineArgumentProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandLineArgumentProvider.swift; sourceTree = ""; }; B34188901F9A479900C5F356 /* SpeculidApplicationModeParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeculidApplicationModeParserTest.swift; sourceTree = ""; }; + B34B52C7217E5D700080E6DC /* InstallType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallType.swift; sourceTree = ""; }; + B34B52C9217E5FC40080E6DC /* CommandLineInstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandLineInstaller.swift; sourceTree = ""; }; + B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "Speculid-Mac-Installer.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; + B34B52D1217E69CE0080E6DC /* Speculid_Mac_InstallerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_Mac_InstallerProtocol.h; sourceTree = ""; }; + B34B52D2217E69CE0080E6DC /* Speculid_Mac_Installer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_Mac_Installer.h; sourceTree = ""; }; + B34B52D3217E69CE0080E6DC /* Speculid_Mac_Installer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Speculid_Mac_Installer.m; sourceTree = ""; }; + B34B52D5217E69CE0080E6DC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + B34B52D7217E69CE0080E6DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B34E82FA1F8FD4EF0032268F /* ImageFileFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageFileFormat.h; sourceTree = ""; }; B34E82FE1F8FD6860032268F /* ImageFileProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageFileProtocol.h; sourceTree = ""; }; B34E83021F8FD90C0032268F /* GlibError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlibError.h; sourceTree = ""; }; @@ -3963,6 +3995,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B34B52CC217E69CE0080E6DC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; B37C743B1F8C58F300DF505B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -4187,6 +4226,7 @@ B3F0ECF11F9E6AAD0078690E /* SpeculidImageSpecificationBuilder.swift */, B33F0BBA1F9586A9004A87DD /* StatusItemProvider.swift */, B3FAD3EA1FA564D0004381A7 /* VersionMenuItem.swift */, + B34B52C9217E5FC40080E6DC /* CommandLineInstaller.swift */, ); path = Controllers; sourceTree = ""; @@ -4228,6 +4268,7 @@ B3B5E9DD1F96C2A2004A6BEB /* SpeculidConfiguration.swift */, B3136E011F90F73A0002B7AB /* SpeculidDocument.swift */, B3136DFC1F90F73A0002B7AB /* SpeculidSpecificationsFile.swift */, + B34B52C7217E5D700080E6DC /* InstallType.swift */, ); path = Models; sourceTree = ""; @@ -4760,6 +4801,18 @@ path = Controllers; sourceTree = ""; }; + B34B52D0217E69CE0080E6DC /* Speculid-Mac-Installer */ = { + isa = PBXGroup; + children = ( + B34B52D1217E69CE0080E6DC /* Speculid_Mac_InstallerProtocol.h */, + B34B52D2217E69CE0080E6DC /* Speculid_Mac_Installer.h */, + B34B52D3217E69CE0080E6DC /* Speculid_Mac_Installer.m */, + B34B52D5217E69CE0080E6DC /* main.m */, + B34B52D7217E69CE0080E6DC /* Info.plist */, + ); + path = "Speculid-Mac-Installer"; + sourceTree = ""; + }; B37C74351F8C58F300DF505B = { isa = PBXGroup; children = ( @@ -4772,6 +4825,7 @@ B3136E6A1F90FCD90002B7AB /* tests */, B37C74401F8C58F300DF505B /* applications */, B3136DB51F90E23E0002B7AB /* frameworks */, + B34B52D0217E69CE0080E6DC /* Speculid-Mac-Installer */, B37C743F1F8C58F300DF505B /* Products */, B37C74801F8C5AE200DF505B /* Frameworks */, ACD4DBE14098687CAAFBB2FA /* Pods */, @@ -4789,6 +4843,7 @@ B3136E7E1F90FD2E0002B7AB /* SpeculidTests.xctest */, B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */, B3242E97213DBE6C0063037C /* speculid */, + B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */, ); name = Products; sourceTree = ""; @@ -14046,6 +14101,23 @@ productReference = B3242E97213DBE6C0063037C /* speculid */; productType = "com.apple.product-type.tool"; }; + B34B52CE217E69CE0080E6DC /* Speculid-Mac-Installer */ = { + isa = PBXNativeTarget; + buildConfigurationList = B34B52DB217E69CE0080E6DC /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; + buildPhases = ( + B34B52CB217E69CE0080E6DC /* Sources */, + B34B52CC217E69CE0080E6DC /* Frameworks */, + B34B52CD217E69CE0080E6DC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Speculid-Mac-Installer"; + productName = "Speculid-Mac-Installer"; + productReference = B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */; + productType = "com.apple.product-type.xpc-service"; + }; B37C743D1F8C58F300DF505B /* Speculid-Mac-App */ = { isa = PBXNativeTarget; buildConfigurationList = B37C744C1F8C58F300DF505B /* Build configuration list for PBXNativeTarget "Speculid-Mac-App" */; @@ -14060,6 +14132,7 @@ F11FED44F4FDA27EB1AD0F15 /* [CP] Embed Pods Frameworks */, B32D69ED1F9ED4A600C21C8C /* Codesign Dynamic Libraries */, B3A2BCF8213F25F4005FC8A1 /* CopyFiles */, + B34B52DE217EB2530080E6DC /* CopyFiles */, ); buildRules = ( ); @@ -14067,6 +14140,7 @@ B37C745D1F8C590D00DF505B /* PBXTargetDependency */, B37C74791F8C5ADA00DF505B /* PBXTargetDependency */, B37C748F1F8C5B5C00DF505B /* PBXTargetDependency */, + B34B52D9217E69CE0080E6DC /* PBXTargetDependency */, ); name = "Speculid-Mac-App"; productName = "Speculid-Mac-App"; @@ -14163,6 +14237,10 @@ CreatedOnToolsVersion = 10.0; ProvisioningStyle = Automatic; }; + B34B52CE217E69CE0080E6DC = { + CreatedOnToolsVersion = 10.0; + ProvisioningStyle = Automatic; + }; B37C743D1F8C58F300DF505B = { CreatedOnToolsVersion = 9.0; ProvisioningStyle = Automatic; @@ -14210,6 +14288,7 @@ B3136E7D1F90FD2E0002B7AB /* SpeculidTests */, B3136E8C1F90FD3D0002B7AB /* CairoSVGTests */, B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */, + B34B52CE217E69CE0080E6DC /* Speculid-Mac-Installer */, ); }; /* End PBXProject section */ @@ -14237,6 +14316,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B34B52CD217E69CE0080E6DC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; B37C743C1F8C58F300DF505B /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -14585,6 +14671,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B34B52CB217E69CE0080E6DC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B34B52D6217E69CE0080E6DC /* main.m in Sources */, + B34B52D4217E69CE0080E6DC /* Speculid_Mac_Installer.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B37C743A1F8C58F300DF505B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -14625,6 +14720,7 @@ B3B5E9E21F96C44D004A6BEB /* SpeculidCommandArgumentSet.swift in Sources */, B33F0BB91F958695004A87DD /* RemoteObjectInterfaceProvider.swift in Sources */, B33F0BB61F958640004A87DD /* StatusItemProviderProtocol.swift in Sources */, + B34B52C8217E5D700080E6DC /* InstallType.swift in Sources */, B3136E4E1F90F73B0002B7AB /* AssetSpecificationProtocol.swift in Sources */, B3136DCF1F90E45F0002B7AB /* FileFormat.swift in Sources */, B317B0D11FA560EE00BB5E57 /* QuitMenuItem.swift in Sources */, @@ -14676,6 +14772,7 @@ B3136E541F90F73B0002B7AB /* ApplicationProtocol.swift in Sources */, B3CB15702113AA8C00A6DC5C /* VersionProvider.swift in Sources */, B3B5E9DA1F96C1C1004A6BEB /* SpeculidConfigurationBuilder.swift in Sources */, + B34B52CA217E5FC40080E6DC /* CommandLineInstaller.swift in Sources */, B341888A1F9A44A700C5F356 /* CommandLineArgumentProviderProtocol.swift in Sources */, B33A533E1F954FF800E74800 /* Result.swift in Sources */, B3136E591F90F73B0002B7AB /* ArrayError.swift in Sources */, @@ -14725,6 +14822,11 @@ target = B37C74881F8C5B5C00DF505B /* CairoSVG */; targetProxy = B3136E931F90FD3D0002B7AB /* PBXContainerItemProxy */; }; + B34B52D9217E69CE0080E6DC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = B34B52CE217E69CE0080E6DC /* Speculid-Mac-Installer */; + targetProxy = B34B52D8217E69CE0080E6DC /* PBXContainerItemProxy */; + }; B37C745D1F8C590D00DF505B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B37C74521F8C590D00DF505B /* Speculid-Mac-XPC */; @@ -14882,6 +14984,41 @@ }; name = Release; }; + B34B52DC217E69CE0080E6DC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = MLT7M394S7; + INFOPLIST_FILE = "Speculid-Mac-Installer/Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + B34B52DD217E69CE0080E6DC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = MLT7M394S7; + INFOPLIST_FILE = "Speculid-Mac-Installer/Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; B37C744A1F8C58F300DF505B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -15284,6 +15421,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + B34B52DB217E69CE0080E6DC /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B34B52DC217E69CE0080E6DC /* Debug */, + B34B52DD217E69CE0080E6DC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; B37C74391F8C58F300DF505B /* Build configuration list for PBXProject "Speculid" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme index fcd40b16..dc1e0e17 100644 --- a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme +++ b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme @@ -114,6 +114,10 @@ + + diff --git a/applications/command/main.swift b/applications/command/main.swift index 1bbde1d6..601657c6 100644 --- a/applications/command/main.swift +++ b/applications/command/main.swift @@ -49,14 +49,12 @@ func findApplicationBundle(withIdentifier identifer: String, _ callback: @escapi query.start() } -func runApplication(fromBundle bundle: Bundle, withArguments arguments: [String]?, completion: @escaping (Error?) -> Void) { - +func runApplication(fromBundle bundle: Bundle, withArguments arguments: [String]?, completion: @escaping (Error?) -> Void) { guard let executableURL = bundle.executableURL else { completion(BundleNotFoundError(identifier: bundle.bundleIdentifier!)) return } - - + let arguments = [String](CommandLine.arguments[1...]) let sourceApplicationName = URL(fileURLWithPath: CommandLine.arguments[0]).lastPathComponent let environment = ProcessInfo.processInfo.environment.merging(["sourceApplicationName": sourceApplicationName], uniquingKeysWith: { $1 }) @@ -71,7 +69,7 @@ func runApplication(fromBundle bundle: Bundle, withArguments arguments: [String process.standardError = FileHandle.standardError process.launch() } -func runApplication(withBundleIdentifier identifier: String, fromApplicationPathURL applicationPathURL: URL?, withArguments arguments: [String]?, completion: @escaping (Error?) -> Void) { +func runApplication(withBundleIdentifier identifier: String, fromApplicationPathURL applicationPathURL: URL?, withArguments arguments: [String]?, completion: @escaping (Error?) -> Void) { if let applicationPathURL = applicationPathURL { if let bundle = Bundle(url: applicationPathURL) { if bundle.bundleIdentifier == identifier { @@ -82,30 +80,28 @@ func runApplication(withBundleIdentifier identifier: String, fromApplicationPath } findApplicationBundle(withIdentifier: speculidMacAppBundleIdentifier) { bundle in - guard let bundle = bundle else { completion(BundleNotFoundError(identifier: identifier)) return } runApplication(fromBundle: bundle, withArguments: nil, completion: completion) - } } DispatchQueue.main.async { - let arguments : [String]? - let applicationPathURL : URL? + let arguments: [String]? + let applicationPathURL: URL? if let index = CommandLine.arguments.firstIndex(of: "--useLocation") { var tempArguments = CommandLine.arguments - applicationPathURL = URL(fileURLWithPath: CommandLine.arguments[index+1]) - tempArguments.removeSubrange((index...index+1)) + applicationPathURL = URL(fileURLWithPath: CommandLine.arguments[index + 1]) + tempArguments.removeSubrange((index ... index + 1)) arguments = tempArguments } else { applicationPathURL = nil arguments = nil } - - runApplication(withBundleIdentifier: speculidMacAppBundleIdentifier, fromApplicationPathURL: applicationPathURL, withArguments: arguments , completion: { error in + + runApplication(withBundleIdentifier: speculidMacAppBundleIdentifier, fromApplicationPathURL: applicationPathURL, withArguments: arguments, completion: { error in if (error as? BundleNotFoundError) != nil { #warning("TODO: Handle If Speculid Bundle Isn't Installed") print("It doesn't look like Speculid is installed.") diff --git a/applications/mac/Application.swift b/applications/mac/Application.swift index 7d1986fe..285e0315 100644 --- a/applications/mac/Application.swift +++ b/applications/mac/Application.swift @@ -1,5 +1,4 @@ import Cocoa import SpeculidKit -open class Application: SpeculidKit.Application { -} +open class Application: SpeculidKit.Application {} diff --git a/frameworks/speculid/Controllers/CairoConversionSet.swift b/frameworks/speculid/Controllers/CairoConversionSet.swift index 5ce75f7b..a2e0d497 100644 --- a/frameworks/speculid/Controllers/CairoConversionSet.swift +++ b/frameworks/speculid/Controllers/CairoConversionSet.swift @@ -2,6 +2,5 @@ import CairoSVG import Foundation public struct CairoConversionSet: ImageConversionSetProtocol { - public func run(_: @escaping (Error?) -> Void) { - } + public func run(_: @escaping (Error?) -> Void) {} } diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift new file mode 100644 index 00000000..00568260 --- /dev/null +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -0,0 +1,23 @@ +import Foundation +import Security +import ServiceManagement + +public struct CommandLineInstaller { + public static func start(_ completed: () -> Void) { + var authorizationRef: AuthorizationRef? + + let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) + var items = AuthorizationItem(name: kAuthorizationRightExecute, valueLength: 0, value: nil, flags: 0) + + var rights = AuthorizationRights(count: 1, items: &items) + let flags: AuthorizationFlags = [.interactionAllowed, .extendRights, .preAuthorize] + + let err = AuthorizationCopyRights(authorizationRef!, &rights, nil, flags, nil) + + var cfError: Unmanaged? + let result = SMJobBless(kSMDomainSystemLaunchd, "com.brightdigit.Speculid-Mac-Installer" as CFString, authorizationRef, &cfError) + debugPrint(result) + debugPrint(cfError?.takeRetainedValue()) + completed() + } +} diff --git a/frameworks/speculid/Controllers/CommandLineRunner.swift b/frameworks/speculid/Controllers/CommandLineRunner.swift index 645f6ba3..7de80ccd 100644 --- a/frameworks/speculid/Controllers/CommandLineRunner.swift +++ b/frameworks/speculid/Controllers/CommandLineRunner.swift @@ -3,8 +3,7 @@ import Foundation public struct InvalidDocumentURL: Error { public let url: URL } -extension Operation: CommandLineActivityProtocol { -} +extension Operation: CommandLineActivityProtocol {} public struct UnknownArgumentsError: Error { public let arguments: [String] @@ -62,6 +61,12 @@ public class CommandLineRunner: CommandLineRunnerProtocol { case .debugLocation: self.outputStream.write(Bundle.main.bundleURL.absoluteString) return completed() + case let .install(type): + if type.contains(.command) { + CommandLineInstaller.start(completed) + } else { + return completed() + } } } operation.completionBlock = { diff --git a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift index e6c98e17..652a2f2f 100644 --- a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift +++ b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift @@ -1,7 +1,6 @@ import Foundation -public struct NoServiceReturnedError: Error { -} +public struct NoServiceReturnedError: Error {} public struct RemoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol { public func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) { diff --git a/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift b/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift index 9af76d6e..2ed8ec66 100644 --- a/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift +++ b/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift @@ -29,6 +29,8 @@ public struct SpeculidApplicationModeParser: SpeculidApplicationModeParserProtoc } } else if arguments.contains("--debugLocation") { return .command(.debugLocation) + } else if arguments.contains("--install") { + return .command(.install(.all)) } else { return .command(.unknown(arguments)) } diff --git a/frameworks/speculid/Models/AssetSpecification.swift b/frameworks/speculid/Models/AssetSpecification.swift index 2c6b4789..9c6db396 100644 --- a/frameworks/speculid/Models/AssetSpecification.swift +++ b/frameworks/speculid/Models/AssetSpecification.swift @@ -73,6 +73,5 @@ public struct AssetSpecification: AssetSpecificationProtocol, Codable { // } } - public func encode(to _: Encoder) throws { - } + public func encode(to _: Encoder) throws {} } diff --git a/frameworks/speculid/Models/InstallType.swift b/frameworks/speculid/Models/InstallType.swift new file mode 100644 index 00000000..069ec8a4 --- /dev/null +++ b/frameworks/speculid/Models/InstallType.swift @@ -0,0 +1,13 @@ +import Foundation + +public struct InstallType: OptionSet { + public let rawValue: UInt8 + + public static let command = InstallType(rawValue: 1 << 0) + + public init(rawValue: UInt8) { + self.rawValue = rawValue + } + + public static let all: InstallType = [.command] +} diff --git a/frameworks/speculid/Models/RegularExpressions.swift b/frameworks/speculid/Models/RegularExpressions.swift index cff4119f..4ca613d5 100644 --- a/frameworks/speculid/Models/RegularExpressions.swift +++ b/frameworks/speculid/Models/RegularExpressions.swift @@ -1,13 +1,11 @@ import Foundation -public enum RegularExpressionKey { -} +public enum RegularExpressionKey {} public typealias RegularExpressionParameters = (String, NSRegularExpression.Options) public struct RegularExpressions { public let dictionary: [RegularExpressionKey: NSRegularExpression] - public init(dictionary _: [RegularExpressionKey: RegularExpressionParameters]) { - } + public init(dictionary _: [RegularExpressionKey: RegularExpressionParameters]) {} } diff --git a/frameworks/speculid/Models/SpeculidCommandArgumentSet.swift b/frameworks/speculid/Models/SpeculidCommandArgumentSet.swift index de69439f..d797c1a0 100644 --- a/frameworks/speculid/Models/SpeculidCommandArgumentSet.swift +++ b/frameworks/speculid/Models/SpeculidCommandArgumentSet.swift @@ -15,5 +15,6 @@ public enum SpeculidCommandArgumentSet: Equatable { case unknown([String]) case version case process(URL) + case install(InstallType) case debugLocation } diff --git a/frameworks/speculid/Protocols/AnalyticsTrackerProtocol.swift b/frameworks/speculid/Protocols/AnalyticsTrackerProtocol.swift index dddc145e..2f38b537 100644 --- a/frameworks/speculid/Protocols/AnalyticsTrackerProtocol.swift +++ b/frameworks/speculid/Protocols/AnalyticsTrackerProtocol.swift @@ -14,5 +14,4 @@ public extension AnalyticsTrackerProtocol { } } -extension NSException: Error { -} +extension NSException: Error {} diff --git a/frameworks/speculid/Protocols/SpeculidArgumentsProtocol.swift b/frameworks/speculid/Protocols/SpeculidArgumentsProtocol.swift index 1c3c1b62..79782731 100644 --- a/frameworks/speculid/Protocols/SpeculidArgumentsProtocol.swift +++ b/frameworks/speculid/Protocols/SpeculidArgumentsProtocol.swift @@ -1,4 +1,3 @@ import Foundation -public protocol SpeculidArgumentsProtocol { -} +public protocol SpeculidArgumentsProtocol {} From f56b9dd4ae29a2b052186c61e904d6d70d988289 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Tue, 23 Oct 2018 15:41:52 -0400 Subject: [PATCH 02/15] removed installer --- Speculid-Mac-Installer/Info.plist | 31 ----- .../Speculid_Mac_Installer.h | 14 -- .../Speculid_Mac_Installer.m | 19 --- .../Speculid_Mac_InstallerProtocol.h | 36 ----- Speculid-Mac-Installer/main.m | 49 ------- Speculid.xcodeproj/project.pbxproj | 130 +----------------- 6 files changed, 1 insertion(+), 278 deletions(-) delete mode 100644 Speculid-Mac-Installer/Info.plist delete mode 100644 Speculid-Mac-Installer/Speculid_Mac_Installer.h delete mode 100644 Speculid-Mac-Installer/Speculid_Mac_Installer.m delete mode 100644 Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h delete mode 100644 Speculid-Mac-Installer/main.m diff --git a/Speculid-Mac-Installer/Info.plist b/Speculid-Mac-Installer/Info.plist deleted file mode 100644 index f6df5ea1..00000000 --- a/Speculid-Mac-Installer/Info.plist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Speculid-Mac-Installer - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - XPC! - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - NSHumanReadableCopyright - Copyright © 2018 Bright Digit, LLC. All rights reserved. - XPCService - - ServiceType - Application - - - diff --git a/Speculid-Mac-Installer/Speculid_Mac_Installer.h b/Speculid-Mac-Installer/Speculid_Mac_Installer.h deleted file mode 100644 index c457615c..00000000 --- a/Speculid-Mac-Installer/Speculid_Mac_Installer.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Speculid_Mac_Installer.h -// Speculid-Mac-Installer -// -// Created by Leo Dion on 10/22/18. -// Copyright © 2018 Bright Digit, LLC. All rights reserved. -// - -#import -#import "Speculid_Mac_InstallerProtocol.h" - -// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection. -@interface Speculid_Mac_Installer : NSObject -@end diff --git a/Speculid-Mac-Installer/Speculid_Mac_Installer.m b/Speculid-Mac-Installer/Speculid_Mac_Installer.m deleted file mode 100644 index 370e48fc..00000000 --- a/Speculid-Mac-Installer/Speculid_Mac_Installer.m +++ /dev/null @@ -1,19 +0,0 @@ -// -// Speculid_Mac_Installer.m -// Speculid-Mac-Installer -// -// Created by Leo Dion on 10/22/18. -// Copyright © 2018 Bright Digit, LLC. All rights reserved. -// - -#import "Speculid_Mac_Installer.h" - -@implementation Speculid_Mac_Installer - -// This implements the example protocol. Replace the body of this class with the implementation of this service's protocol. -- (void)upperCaseString:(NSString *)aString withReply:(void (^)(NSString *))reply { - NSString *response = [aString uppercaseString]; - reply(response); -} - -@end diff --git a/Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h b/Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h deleted file mode 100644 index 20655806..00000000 --- a/Speculid-Mac-Installer/Speculid_Mac_InstallerProtocol.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// Speculid_Mac_InstallerProtocol.h -// Speculid-Mac-Installer -// -// Created by Leo Dion on 10/22/18. -// Copyright © 2018 Bright Digit, LLC. All rights reserved. -// - -#import - -// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service. -@protocol Speculid_Mac_InstallerProtocol - -// Replace the API of this protocol with an API appropriate to the service you are vending. -- (void)upperCaseString:(NSString *)aString withReply:(void (^)(NSString *))reply; - -@end - -/* - To use the service from an application or other process, use NSXPCConnection to establish a connection to the service by doing something like this: - - _connectionToService = [[NSXPCConnection alloc] initWithServiceName:@"com.brightdigit.Speculid-Mac-Installer"]; - _connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(Speculid_Mac_InstallerProtocol)]; - [_connectionToService resume]; - -Once you have a connection to the service, you can use it like this: - - [[_connectionToService remoteObjectProxy] upperCaseString:@"hello" withReply:^(NSString *aString) { - // We have received a response. Update our text field, but do it on the main thread. - NSLog(@"Result string was: %@", aString); - }]; - - And, when you are finished with the service, clean up the connection like this: - - [_connectionToService invalidate]; -*/ diff --git a/Speculid-Mac-Installer/main.m b/Speculid-Mac-Installer/main.m deleted file mode 100644 index f673bb3c..00000000 --- a/Speculid-Mac-Installer/main.m +++ /dev/null @@ -1,49 +0,0 @@ -// -// main.m -// Speculid-Mac-Installer -// -// Created by Leo Dion on 10/22/18. -// Copyright © 2018 Bright Digit, LLC. All rights reserved. -// - -#import -#import "Speculid_Mac_Installer.h" - -@interface ServiceDelegate : NSObject -@end - -@implementation ServiceDelegate - -- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection { - // This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection. - - // Configure the connection. - // First, set the interface that the exported object implements. - newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(Speculid_Mac_InstallerProtocol)]; - - // Next, set the object that the connection exports. All messages sent on the connection to this service will be sent to the exported object to handle. The connection retains the exported object. - Speculid_Mac_Installer *exportedObject = [Speculid_Mac_Installer new]; - newConnection.exportedObject = exportedObject; - - // Resuming the connection allows the system to deliver more incoming messages. - [newConnection resume]; - - // Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO. - return YES; -} - -@end - -int main(int argc, const char *argv[]) -{ - // Create the delegate for the service. - ServiceDelegate *delegate = [ServiceDelegate new]; - - // Set up the one NSXPCListener for this service. It will handle all incoming connections. - NSXPCListener *listener = [NSXPCListener serviceListener]; - listener.delegate = delegate; - - // Resuming the serviceListener starts this service. This method does not return. - [listener resume]; - return 0; -} diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index c59fe94a..e5b233ed 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -308,10 +308,6 @@ B34188911F9A479900C5F356 /* SpeculidApplicationModeParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34188901F9A479900C5F356 /* SpeculidApplicationModeParserTest.swift */; }; B34B52C8217E5D700080E6DC /* InstallType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34B52C7217E5D700080E6DC /* InstallType.swift */; }; B34B52CA217E5FC40080E6DC /* CommandLineInstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34B52C9217E5FC40080E6DC /* CommandLineInstaller.swift */; }; - B34B52D4217E69CE0080E6DC /* Speculid_Mac_Installer.m in Sources */ = {isa = PBXBuildFile; fileRef = B34B52D3217E69CE0080E6DC /* Speculid_Mac_Installer.m */; }; - B34B52D6217E69CE0080E6DC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B34B52D5217E69CE0080E6DC /* main.m */; }; - B34B52DA217E69CE0080E6DC /* Speculid-Mac-Installer.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - B34B52DF217EB2670080E6DC /* Speculid-Mac-Installer.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; B34E82FB1F8FD4EF0032268F /* ImageFileFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = B34E82FA1F8FD4EF0032268F /* ImageFileFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; B34E82FF1F8FD6860032268F /* ImageFileProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B34E82FE1F8FD6860032268F /* ImageFileProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; B34E83041F8FD90C0032268F /* GlibError.h in Headers */ = {isa = PBXBuildFile; fileRef = B34E83021F8FD90C0032268F /* GlibError.h */; }; @@ -1016,13 +1012,6 @@ remoteGlobalIDString = B37C74881F8C5B5C00DF505B; remoteInfo = CairoSVG; }; - B34B52D8217E69CE0080E6DC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = B37C74361F8C58F300DF505B /* Project object */; - proxyType = 1; - remoteGlobalIDString = B34B52CE217E69CE0080E6DC; - remoteInfo = "Speculid-Mac-Installer"; - }; B37C745C1F8C590D00DF505B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B37C74361F8C58F300DF505B /* Project object */; @@ -1068,10 +1057,9 @@ B34B52DE217EB2530080E6DC /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; - dstPath = ""; + dstPath = Library/PrivilegedHelperTools; dstSubfolderSpec = 1; files = ( - B34B52DF217EB2670080E6DC /* Speculid-Mac-Installer.xpc in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1082,7 +1070,6 @@ dstSubfolderSpec = 16; files = ( B37C745E1F8C590D00DF505B /* Speculid-Mac-XPC.xpc in Embed XPC Services */, - B34B52DA217E69CE0080E6DC /* Speculid-Mac-Installer.xpc in Embed XPC Services */, ); name = "Embed XPC Services"; runOnlyForDeploymentPostprocessing = 0; @@ -1563,12 +1550,6 @@ B34188901F9A479900C5F356 /* SpeculidApplicationModeParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeculidApplicationModeParserTest.swift; sourceTree = ""; }; B34B52C7217E5D700080E6DC /* InstallType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallType.swift; sourceTree = ""; }; B34B52C9217E5FC40080E6DC /* CommandLineInstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandLineInstaller.swift; sourceTree = ""; }; - B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "Speculid-Mac-Installer.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; - B34B52D1217E69CE0080E6DC /* Speculid_Mac_InstallerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_Mac_InstallerProtocol.h; sourceTree = ""; }; - B34B52D2217E69CE0080E6DC /* Speculid_Mac_Installer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_Mac_Installer.h; sourceTree = ""; }; - B34B52D3217E69CE0080E6DC /* Speculid_Mac_Installer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Speculid_Mac_Installer.m; sourceTree = ""; }; - B34B52D5217E69CE0080E6DC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - B34B52D7217E69CE0080E6DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B34E82FA1F8FD4EF0032268F /* ImageFileFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageFileFormat.h; sourceTree = ""; }; B34E82FE1F8FD6860032268F /* ImageFileProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageFileProtocol.h; sourceTree = ""; }; B34E83021F8FD90C0032268F /* GlibError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlibError.h; sourceTree = ""; }; @@ -3995,13 +3976,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B34B52CC217E69CE0080E6DC /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; B37C743B1F8C58F300DF505B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -4801,18 +4775,6 @@ path = Controllers; sourceTree = ""; }; - B34B52D0217E69CE0080E6DC /* Speculid-Mac-Installer */ = { - isa = PBXGroup; - children = ( - B34B52D1217E69CE0080E6DC /* Speculid_Mac_InstallerProtocol.h */, - B34B52D2217E69CE0080E6DC /* Speculid_Mac_Installer.h */, - B34B52D3217E69CE0080E6DC /* Speculid_Mac_Installer.m */, - B34B52D5217E69CE0080E6DC /* main.m */, - B34B52D7217E69CE0080E6DC /* Info.plist */, - ); - path = "Speculid-Mac-Installer"; - sourceTree = ""; - }; B37C74351F8C58F300DF505B = { isa = PBXGroup; children = ( @@ -4825,7 +4787,6 @@ B3136E6A1F90FCD90002B7AB /* tests */, B37C74401F8C58F300DF505B /* applications */, B3136DB51F90E23E0002B7AB /* frameworks */, - B34B52D0217E69CE0080E6DC /* Speculid-Mac-Installer */, B37C743F1F8C58F300DF505B /* Products */, B37C74801F8C5AE200DF505B /* Frameworks */, ACD4DBE14098687CAAFBB2FA /* Pods */, @@ -4843,7 +4804,6 @@ B3136E7E1F90FD2E0002B7AB /* SpeculidTests.xctest */, B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */, B3242E97213DBE6C0063037C /* speculid */, - B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */, ); name = Products; sourceTree = ""; @@ -14101,23 +14061,6 @@ productReference = B3242E97213DBE6C0063037C /* speculid */; productType = "com.apple.product-type.tool"; }; - B34B52CE217E69CE0080E6DC /* Speculid-Mac-Installer */ = { - isa = PBXNativeTarget; - buildConfigurationList = B34B52DB217E69CE0080E6DC /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; - buildPhases = ( - B34B52CB217E69CE0080E6DC /* Sources */, - B34B52CC217E69CE0080E6DC /* Frameworks */, - B34B52CD217E69CE0080E6DC /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "Speculid-Mac-Installer"; - productName = "Speculid-Mac-Installer"; - productReference = B34B52CF217E69CE0080E6DC /* Speculid-Mac-Installer.xpc */; - productType = "com.apple.product-type.xpc-service"; - }; B37C743D1F8C58F300DF505B /* Speculid-Mac-App */ = { isa = PBXNativeTarget; buildConfigurationList = B37C744C1F8C58F300DF505B /* Build configuration list for PBXNativeTarget "Speculid-Mac-App" */; @@ -14140,7 +14083,6 @@ B37C745D1F8C590D00DF505B /* PBXTargetDependency */, B37C74791F8C5ADA00DF505B /* PBXTargetDependency */, B37C748F1F8C5B5C00DF505B /* PBXTargetDependency */, - B34B52D9217E69CE0080E6DC /* PBXTargetDependency */, ); name = "Speculid-Mac-App"; productName = "Speculid-Mac-App"; @@ -14237,10 +14179,6 @@ CreatedOnToolsVersion = 10.0; ProvisioningStyle = Automatic; }; - B34B52CE217E69CE0080E6DC = { - CreatedOnToolsVersion = 10.0; - ProvisioningStyle = Automatic; - }; B37C743D1F8C58F300DF505B = { CreatedOnToolsVersion = 9.0; ProvisioningStyle = Automatic; @@ -14288,7 +14226,6 @@ B3136E7D1F90FD2E0002B7AB /* SpeculidTests */, B3136E8C1F90FD3D0002B7AB /* CairoSVGTests */, B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */, - B34B52CE217E69CE0080E6DC /* Speculid-Mac-Installer */, ); }; /* End PBXProject section */ @@ -14316,13 +14253,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B34B52CD217E69CE0080E6DC /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; B37C743C1F8C58F300DF505B /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -14671,15 +14601,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B34B52CB217E69CE0080E6DC /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - B34B52D6217E69CE0080E6DC /* main.m in Sources */, - B34B52D4217E69CE0080E6DC /* Speculid_Mac_Installer.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; B37C743A1F8C58F300DF505B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -14822,11 +14743,6 @@ target = B37C74881F8C5B5C00DF505B /* CairoSVG */; targetProxy = B3136E931F90FD3D0002B7AB /* PBXContainerItemProxy */; }; - B34B52D9217E69CE0080E6DC /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B34B52CE217E69CE0080E6DC /* Speculid-Mac-Installer */; - targetProxy = B34B52D8217E69CE0080E6DC /* PBXContainerItemProxy */; - }; B37C745D1F8C590D00DF505B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B37C74521F8C590D00DF505B /* Speculid-Mac-XPC */; @@ -14984,41 +14900,6 @@ }; name = Release; }; - B34B52DC217E69CE0080E6DC /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = MLT7M394S7; - INFOPLIST_FILE = "Speculid-Mac-Installer/Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - B34B52DD217E69CE0080E6DC /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = MLT7M394S7; - INFOPLIST_FILE = "Speculid-Mac-Installer/Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; B37C744A1F8C58F300DF505B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -15421,15 +15302,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - B34B52DB217E69CE0080E6DC /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B34B52DC217E69CE0080E6DC /* Debug */, - B34B52DD217E69CE0080E6DC /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; B37C74391F8C58F300DF505B /* Build configuration list for PBXProject "Speculid" */ = { isa = XCConfigurationList; buildConfigurations = ( From 4ef84b854f42725ea926e96658fe8540b0f15e76 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Tue, 23 Oct 2018 16:40:29 -0400 Subject: [PATCH 03/15] working on installer service --- Speculid-Installer/ServiceDelegate.swift | 28 ++++ Speculid-Installer/launchd.plist | 8 + Speculid-Installer/main.swift | 6 + Speculid.xcodeproj/project.pbxproj | 140 +++++++++++++++++- applications/mac/Info.plist | 4 + .../speculid/Controllers/Application.swift | 2 +- .../RemoteObjectInterfaceProvider.swift | 56 +++---- ...emoteObjectInterfaceProviderProtocol.swift | 7 +- 8 files changed, 222 insertions(+), 29 deletions(-) create mode 100644 Speculid-Installer/ServiceDelegate.swift create mode 100644 Speculid-Installer/launchd.plist create mode 100644 Speculid-Installer/main.swift diff --git a/Speculid-Installer/ServiceDelegate.swift b/Speculid-Installer/ServiceDelegate.swift new file mode 100644 index 00000000..a72f9641 --- /dev/null +++ b/Speculid-Installer/ServiceDelegate.swift @@ -0,0 +1,28 @@ +import Cocoa +import CoreFoundation + +@objc public protocol InstallerProtocol { + func hello(name: String) -> String +} + +public class Installer : NSObject, InstallerProtocol { + public func hello(name: String) -> String { + return ["hello", name].joined(separator:" ") + } + + +} + +@objc open class ServiceDelegate: NSObject, NSXPCListenerDelegate { + public func listener(_: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool { + let exportedInterface = NSXPCInterface(with: InstallerProtocol.self) +// let currentClasses: NSSet = exportedInterface.classes(for: #selector(ServiceProtocol.exportImageAtURL(_:toSpecifications:_:)), argumentIndex: 1, ofReply: false) as NSSet +// let classes = currentClasses.addingObjects(from: [ImageSpecification.self, ImageFile.self, NSURL.self, NSColor.self]) +// exportedInterface.setClasses(classes, for: #selector(ServiceProtocol.exportImageAtURL(_:toSpecifications:_:)), argumentIndex: 1, ofReply: false) + newConnection.exportedInterface = exportedInterface + let exportedObject = Installer() + newConnection.exportedObject = exportedObject + newConnection.resume() + return true + } +} diff --git a/Speculid-Installer/launchd.plist b/Speculid-Installer/launchd.plist new file mode 100644 index 00000000..0389118f --- /dev/null +++ b/Speculid-Installer/launchd.plist @@ -0,0 +1,8 @@ + + + + + Label + com.brightdigit.Speculid-Mac-Installer + + diff --git a/Speculid-Installer/main.swift b/Speculid-Installer/main.swift new file mode 100644 index 00000000..4a14b9ee --- /dev/null +++ b/Speculid-Installer/main.swift @@ -0,0 +1,6 @@ +import Foundation + +let delegate = ServiceDelegate() +let listener = NSXPCListener.service() +listener.delegate = delegate +listener.resume() diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index e5b233ed..ce929895 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -297,6 +297,10 @@ B31BEAFC1F96269F00496E7A /* RegularExpressionSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFB1F96269F00496E7A /* RegularExpressionSet.swift */; }; B31BEAFE1F9626AC00496E7A /* RegularExpressionSetProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFD1F9626AC00496E7A /* RegularExpressionSetProtocol.swift */; }; B31BEB001F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFF1F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift */; }; + B323FC0D217FB34900D95E9C /* Speculid-Mac-Installer.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + B323FC0F217FB44400D95E9C /* launchd.plist in Resources */ = {isa = PBXBuildFile; fileRef = B323FC0E217FB44400D95E9C /* launchd.plist */; }; + B323FC11217FB5CB00D95E9C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC10217FB5CB00D95E9C /* main.swift */; }; + B323FC13217FB5F500D95E9C /* ServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */; }; B3242E9A213DBE6C0063037C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3242E99213DBE6C0063037C /* main.swift */; }; B33A533E1F954FF800E74800 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A533D1F954FF800E74800 /* Result.swift */; }; B33F0BB61F958640004A87DD /* StatusItemProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */; }; @@ -1012,6 +1016,13 @@ remoteGlobalIDString = B37C74881F8C5B5C00DF505B; remoteInfo = CairoSVG; }; + B323FC14217FB96B00D95E9C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B37C74361F8C58F300DF505B /* Project object */; + proxyType = 1; + remoteGlobalIDString = B323FC00217FB2C300D95E9C; + remoteInfo = "Speculid-Mac-Installer"; + }; B37C745C1F8C590D00DF505B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B37C74361F8C58F300DF505B /* Project object */; @@ -1057,9 +1068,10 @@ B34B52DE217EB2530080E6DC /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; - dstPath = Library/PrivilegedHelperTools; + dstPath = Contents/Library/LaunchServices; dstSubfolderSpec = 1; files = ( + B323FC0D217FB34900D95E9C /* Speculid-Mac-Installer.xpc in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1537,6 +1549,15 @@ B3220A4921154D1A00047BF6 /* decrypt-certs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "decrypt-certs.sh"; sourceTree = ""; }; B3220A4A21154D1A00047BF6 /* shasum.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = shasum.sh; sourceTree = ""; }; B3220A4B21154D1A00047BF6 /* build-keychain.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-keychain.sh"; sourceTree = ""; }; + B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "Speculid-Mac-Installer.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; + B323FC03217FB2C400D95E9C /* Speculid_InstallerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_InstallerProtocol.h; sourceTree = ""; }; + B323FC04217FB2C400D95E9C /* Speculid_Installer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_Installer.h; sourceTree = ""; }; + B323FC05217FB2C400D95E9C /* Speculid_Installer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Speculid_Installer.m; sourceTree = ""; }; + B323FC07217FB2C400D95E9C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + B323FC09217FB2C400D95E9C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B323FC0E217FB44400D95E9C /* launchd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = launchd.plist; sourceTree = ""; }; + B323FC10217FB5CB00D95E9C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = ""; }; B3242E97213DBE6C0063037C /* speculid */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = speculid; sourceTree = BUILT_PRODUCTS_DIR; }; B3242E99213DBE6C0063037C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B32D69EA1F9EC5CA00C21C8C /* Speculid.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Speculid.entitlements; sourceTree = ""; }; @@ -3969,6 +3990,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B323FBFE217FB2C300D95E9C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; B3242E94213DBE6C0063037C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -4757,6 +4785,21 @@ path = scripts; sourceTree = ""; }; + B323FC02217FB2C400D95E9C /* Speculid-Installer */ = { + isa = PBXGroup; + children = ( + B323FC03217FB2C400D95E9C /* Speculid_InstallerProtocol.h */, + B323FC04217FB2C400D95E9C /* Speculid_Installer.h */, + B323FC05217FB2C400D95E9C /* Speculid_Installer.m */, + B323FC07217FB2C400D95E9C /* main.m */, + B323FC09217FB2C400D95E9C /* Info.plist */, + B323FC0E217FB44400D95E9C /* launchd.plist */, + B323FC10217FB5CB00D95E9C /* main.swift */, + B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */, + ); + path = "Speculid-Installer"; + sourceTree = ""; + }; B3242E9E213DBE960063037C /* command */ = { isa = PBXGroup; children = ( @@ -4787,6 +4830,7 @@ B3136E6A1F90FCD90002B7AB /* tests */, B37C74401F8C58F300DF505B /* applications */, B3136DB51F90E23E0002B7AB /* frameworks */, + B323FC02217FB2C400D95E9C /* Speculid-Installer */, B37C743F1F8C58F300DF505B /* Products */, B37C74801F8C5AE200DF505B /* Frameworks */, ACD4DBE14098687CAAFBB2FA /* Pods */, @@ -4804,6 +4848,7 @@ B3136E7E1F90FD2E0002B7AB /* SpeculidTests.xctest */, B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */, B3242E97213DBE6C0063037C /* speculid */, + B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */, ); name = Products; sourceTree = ""; @@ -14044,6 +14089,23 @@ productReference = B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + B323FC00217FB2C300D95E9C /* Speculid-Mac-Installer */ = { + isa = PBXNativeTarget; + buildConfigurationList = B323FC0A217FB2C400D95E9C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; + buildPhases = ( + B323FBFD217FB2C300D95E9C /* Sources */, + B323FBFE217FB2C300D95E9C /* Frameworks */, + B323FBFF217FB2C300D95E9C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Speculid-Mac-Installer"; + productName = "Speculid-Installer"; + productReference = B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */; + productType = "com.apple.product-type.xpc-service"; + }; B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */ = { isa = PBXNativeTarget; buildConfigurationList = B3242E9D213DBE6C0063037C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Cmd" */; @@ -14080,6 +14142,7 @@ buildRules = ( ); dependencies = ( + B323FC15217FB96B00D95E9C /* PBXTargetDependency */, B37C745D1F8C590D00DF505B /* PBXTargetDependency */, B37C74791F8C5ADA00DF505B /* PBXTargetDependency */, B37C748F1F8C5B5C00DF505B /* PBXTargetDependency */, @@ -14175,6 +14238,11 @@ CreatedOnToolsVersion = 9.0; ProvisioningStyle = Automatic; }; + B323FC00217FB2C300D95E9C = { + CreatedOnToolsVersion = 10.0; + LastSwiftMigration = 1000; + ProvisioningStyle = Automatic; + }; B3242E96213DBE6C0063037C = { CreatedOnToolsVersion = 10.0; ProvisioningStyle = Automatic; @@ -14226,6 +14294,7 @@ B3136E7D1F90FD2E0002B7AB /* SpeculidTests */, B3136E8C1F90FD3D0002B7AB /* CairoSVGTests */, B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */, + B323FC00217FB2C300D95E9C /* Speculid-Mac-Installer */, ); }; /* End PBXProject section */ @@ -14253,6 +14322,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B323FBFF217FB2C300D95E9C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B323FC0F217FB44400D95E9C /* launchd.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B37C743C1F8C58F300DF505B /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -14593,6 +14670,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B323FBFD217FB2C300D95E9C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B323FC13217FB5F500D95E9C /* ServiceDelegate.swift in Sources */, + B323FC11217FB5CB00D95E9C /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B3242E93213DBE6C0063037C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -14743,6 +14829,11 @@ target = B37C74881F8C5B5C00DF505B /* CairoSVG */; targetProxy = B3136E931F90FD3D0002B7AB /* PBXContainerItemProxy */; }; + B323FC15217FB96B00D95E9C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = B323FC00217FB2C300D95E9C /* Speculid-Mac-Installer */; + targetProxy = B323FC14217FB96B00D95E9C /* PBXContainerItemProxy */; + }; B37C745D1F8C590D00DF505B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B37C74521F8C590D00DF505B /* Speculid-Mac-XPC */; @@ -14871,6 +14962,44 @@ }; name = Release; }; + B323FC0B217FB2C400D95E9C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = MLT7M394S7; + INFOPLIST_FILE = "Speculid-Installer/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; + }; + name = Debug; + }; + B323FC0C217FB2C400D95E9C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = MLT7M394S7; + INFOPLIST_FILE = "Speculid-Installer/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; + }; + name = Release; + }; B3242E9B213DBE6C0063037C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -15293,6 +15422,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + B323FC0A217FB2C400D95E9C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B323FC0B217FB2C400D95E9C /* Debug */, + B323FC0C217FB2C400D95E9C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; B3242E9D213DBE6C0063037C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Cmd" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/applications/mac/Info.plist b/applications/mac/Info.plist index 9ba4179f..fc44e2bf 100644 --- a/applications/mac/Info.plist +++ b/applications/mac/Info.plist @@ -30,5 +30,9 @@ Copyright © 2017 Bright Digit, LLC. All rights reserved. NSPrincipalClass $(TARGET_NAME:c99extidentifier).Application + SMAuthorizedClients + + com.brightdigit.Speculid-Mac-Installer + diff --git a/frameworks/speculid/Controllers/Application.swift b/frameworks/speculid/Controllers/Application.swift index 0d12bf0a..2e26d71f 100644 --- a/frameworks/speculid/Controllers/Application.swift +++ b/frameworks/speculid/Controllers/Application.swift @@ -62,7 +62,7 @@ open class Application: NSApplication, ApplicationProtocol { open private(set) var builder: SpeculidBuilderProtocol! open let statusItemProvider: StatusItemProviderProtocol - open let remoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol + open let remoteObjectInterfaceProvider: ServiceObjectInterfaceProvider open let regularExpressionBuilder: RegularExpressionSetBuilderProtocol open let configurationBuilder: SpeculidConfigurationBuilderProtocol open let jsonDecoder: JSONDecoder diff --git a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift index 652a2f2f..0ab68fd9 100644 --- a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift +++ b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift @@ -2,30 +2,34 @@ import Foundation public struct NoServiceReturnedError: Error {} -public struct RemoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol { - public func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) { - let interface = NSXPCInterface(with: ServiceProtocol.self) - let connection = NSXPCConnection(serviceName: "com.brightdigit.Speculid-Mac-XPC") - - connection.remoteObjectInterface = interface - connection.resume() - - var error: Error? - - let proxy = connection.remoteObjectProxyWithErrorHandler { handlerError in - error = handlerError - } - - let result: Result - - if let error = error { - result = .error(error) - } else if let service = proxy as? ServiceProtocol { - result = .success(service) - } else { - result = .error(NoServiceReturnedError()) - } - - handler(result) - } +public struct RemoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol { + public func remoteObjectProxyWith(serviceName _: String, andHandler _: (Result.ProxyType>) -> Void) {} + public typealias ProxyType = T + +// public func remoteObjectProxyWith(serviceName: String, andHandler handler: (Result) -> Void) { +// let interface = NSXPCInterface(with: ServiceProtocol.self) + //// let connection = NSXPCConnection(serviceName: "com.brightdigit.Speculid-Mac-XPC") +// let connection = NSXPCConnection(serviceName: serviceName) +// +// connection.remoteObjectInterface = interface +// connection.resume() +// +// var error: Error? +// +// let proxy = connection.remoteObjectProxyWithErrorHandler { handlerError in +// error = handlerError +// } +// +// let result: Result +// +// if let error = error { +// result = .error(error) +// } else if let service = proxy as? ServiceProtocol { +// result = .success(service) +// } else { +// result = .error(NoServiceReturnedError()) +// } +// +// handler(result) +// } } diff --git a/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift b/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift index 38639ea2..98aa364d 100644 --- a/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift +++ b/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift @@ -1,5 +1,10 @@ import Foundation -public protocol RemoteObjectInterfaceProviderProtocol { +public protocol RemoteObjectInterfaceProviderProtocol where ProxyType: Protocol { + associatedtype ProxyType + func remoteObjectProxyWith(serviceName: String, andHandler handler: (Result) -> Void) +} + +public protocol ServiceObjectInterfaceProvider { func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) } From 11154ec9ad1af32410952dfcd1b79c31b74a7616 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Tue, 23 Oct 2018 17:21:13 -0400 Subject: [PATCH 04/15] rollback change with service --- .../speculid/Controllers/Application.swift | 2 +- .../RemoteObjectInterfaceProvider.swift | 56 +++++++++---------- ...emoteObjectInterfaceProviderProtocol.swift | 7 +-- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/frameworks/speculid/Controllers/Application.swift b/frameworks/speculid/Controllers/Application.swift index 2e26d71f..0d12bf0a 100644 --- a/frameworks/speculid/Controllers/Application.swift +++ b/frameworks/speculid/Controllers/Application.swift @@ -62,7 +62,7 @@ open class Application: NSApplication, ApplicationProtocol { open private(set) var builder: SpeculidBuilderProtocol! open let statusItemProvider: StatusItemProviderProtocol - open let remoteObjectInterfaceProvider: ServiceObjectInterfaceProvider + open let remoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol open let regularExpressionBuilder: RegularExpressionSetBuilderProtocol open let configurationBuilder: SpeculidConfigurationBuilderProtocol open let jsonDecoder: JSONDecoder diff --git a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift index 0ab68fd9..652a2f2f 100644 --- a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift +++ b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift @@ -2,34 +2,30 @@ import Foundation public struct NoServiceReturnedError: Error {} -public struct RemoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol { - public func remoteObjectProxyWith(serviceName _: String, andHandler _: (Result.ProxyType>) -> Void) {} - public typealias ProxyType = T - -// public func remoteObjectProxyWith(serviceName: String, andHandler handler: (Result) -> Void) { -// let interface = NSXPCInterface(with: ServiceProtocol.self) - //// let connection = NSXPCConnection(serviceName: "com.brightdigit.Speculid-Mac-XPC") -// let connection = NSXPCConnection(serviceName: serviceName) -// -// connection.remoteObjectInterface = interface -// connection.resume() -// -// var error: Error? -// -// let proxy = connection.remoteObjectProxyWithErrorHandler { handlerError in -// error = handlerError -// } -// -// let result: Result -// -// if let error = error { -// result = .error(error) -// } else if let service = proxy as? ServiceProtocol { -// result = .success(service) -// } else { -// result = .error(NoServiceReturnedError()) -// } -// -// handler(result) -// } +public struct RemoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol { + public func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) { + let interface = NSXPCInterface(with: ServiceProtocol.self) + let connection = NSXPCConnection(serviceName: "com.brightdigit.Speculid-Mac-XPC") + + connection.remoteObjectInterface = interface + connection.resume() + + var error: Error? + + let proxy = connection.remoteObjectProxyWithErrorHandler { handlerError in + error = handlerError + } + + let result: Result + + if let error = error { + result = .error(error) + } else if let service = proxy as? ServiceProtocol { + result = .success(service) + } else { + result = .error(NoServiceReturnedError()) + } + + handler(result) + } } diff --git a/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift b/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift index 98aa364d..38639ea2 100644 --- a/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift +++ b/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift @@ -1,10 +1,5 @@ import Foundation -public protocol RemoteObjectInterfaceProviderProtocol where ProxyType: Protocol { - associatedtype ProxyType - func remoteObjectProxyWith(serviceName: String, andHandler handler: (Result) -> Void) -} - -public protocol ServiceObjectInterfaceProvider { +public protocol RemoteObjectInterfaceProviderProtocol { func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) } From e7ac323a6da53a14fd95c6686c09b44a46b8ded7 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 08:52:03 -0400 Subject: [PATCH 05/15] cleaned up fix script --- scripts/fix_dylibs.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/fix_dylibs.sh b/scripts/fix_dylibs.sh index 988feab3..eb9a2a07 100755 --- a/scripts/fix_dylibs.sh +++ b/scripts/fix_dylibs.sh @@ -9,7 +9,6 @@ done FRAMEWORKS_FOLDER_PATH="`dirname $1`/Frameworks/" deps=`ls "$FRAMEWORKS_FOLDER_PATH" | awk -F' ' '{ print $1 }'` for lib in $deps; do - echo "Fixing $dependency" install_name_tool -id @rpath/`basename $lib` "`dirname $1`/Frameworks/`basename $lib`" install_name_tool -change $lib @rpath/`basename $lib` "$1" dylib="`dirname $1`/Frameworks/`basename $lib`" From 65b3dcc96cbc97b10c952e4996ef8f97e7970436 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 09:48:25 -0400 Subject: [PATCH 06/15] fixing service --- Speculid-Installer/Info.plist | 35 +++++++++++++++++++ Speculid-Installer/ServiceDelegate.swift | 10 ++---- ...t => Speculid-Mac-Installer-Launchd.plist} | 0 Speculid.xcodeproj/project.pbxproj | 26 +++++++------- .../xcschemes/Speculid-Mac-App.xcscheme | 2 +- applications/mac/Info.plist | 5 +++ .../speculid/Controllers/Application.swift | 8 +++++ .../Controllers/CommandLineInstaller.swift | 18 +++++++++- .../RemoteObjectInterfaceProvider.swift | 29 +++++++++++++++ .../Protocols/ApplicationProtocol.swift | 2 ++ .../Protocols/InstallerProtocol.swift | 5 +++ ...emoteObjectInterfaceProviderProtocol.swift | 4 +++ 12 files changed, 122 insertions(+), 22 deletions(-) create mode 100644 Speculid-Installer/Info.plist rename Speculid-Installer/{launchd.plist => Speculid-Mac-Installer-Launchd.plist} (100%) create mode 100644 frameworks/speculid/Protocols/InstallerProtocol.swift diff --git a/Speculid-Installer/Info.plist b/Speculid-Installer/Info.plist new file mode 100644 index 00000000..d799034a --- /dev/null +++ b/Speculid-Installer/Info.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Speculid-Mac-Installer + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright © 2018 Bright Digit, LLC. All rights reserved. + SMAuthorizedClients + + identifier com.brightdigit.Speculid-Mac-App and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" + + XPCService + + ServiceType + Application + + + diff --git a/Speculid-Installer/ServiceDelegate.swift b/Speculid-Installer/ServiceDelegate.swift index a72f9641..5ca592c9 100644 --- a/Speculid-Installer/ServiceDelegate.swift +++ b/Speculid-Installer/ServiceDelegate.swift @@ -1,16 +1,10 @@ import Cocoa import CoreFoundation -@objc public protocol InstallerProtocol { - func hello(name: String) -> String -} - public class Installer : NSObject, InstallerProtocol { - public func hello(name: String) -> String { - return ["hello", name].joined(separator:" ") + public func hello(name: String, _ completed: (String) -> Void) { + completed(["hello", name].joined(separator:" ")) } - - } @objc open class ServiceDelegate: NSObject, NSXPCListenerDelegate { diff --git a/Speculid-Installer/launchd.plist b/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist similarity index 100% rename from Speculid-Installer/launchd.plist rename to Speculid-Installer/Speculid-Mac-Installer-Launchd.plist diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index ce929895..a1357a47 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -298,7 +298,7 @@ B31BEAFE1F9626AC00496E7A /* RegularExpressionSetProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFD1F9626AC00496E7A /* RegularExpressionSetProtocol.swift */; }; B31BEB001F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFF1F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift */; }; B323FC0D217FB34900D95E9C /* Speculid-Mac-Installer.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - B323FC0F217FB44400D95E9C /* launchd.plist in Resources */ = {isa = PBXBuildFile; fileRef = B323FC0E217FB44400D95E9C /* launchd.plist */; }; + B323FC0F217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist in Resources */ = {isa = PBXBuildFile; fileRef = B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */; }; B323FC11217FB5CB00D95E9C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC10217FB5CB00D95E9C /* main.swift */; }; B323FC13217FB5F500D95E9C /* ServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */; }; B3242E9A213DBE6C0063037C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3242E99213DBE6C0063037C /* main.swift */; }; @@ -991,6 +991,8 @@ B3F80CAE20E586A000030497 /* libharfbuzz-icu.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = B3F8096B20E585E800030497 /* libharfbuzz-icu.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; B3F80CAF20E586A000030497 /* libharfbuzz-subset.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = B3F8096C20E585E800030497 /* libharfbuzz-subset.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; B3FAD3EB1FA564D0004381A7 /* VersionMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FAD3EA1FA564D0004381A7 /* VersionMenuItem.swift */; }; + B3FDF6452180A3FF00455A43 /* InstallerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */; }; + B3FDF6462180A3FF00455A43 /* InstallerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */; }; CBE9EF18228D2DADFC9D264F /* Pods_Speculid.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCB0AF202D3672415910AFDE /* Pods_Speculid.framework */; }; /* End PBXBuildFile section */ @@ -1550,12 +1552,8 @@ B3220A4A21154D1A00047BF6 /* shasum.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = shasum.sh; sourceTree = ""; }; B3220A4B21154D1A00047BF6 /* build-keychain.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-keychain.sh"; sourceTree = ""; }; B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "Speculid-Mac-Installer.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; - B323FC03217FB2C400D95E9C /* Speculid_InstallerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_InstallerProtocol.h; sourceTree = ""; }; - B323FC04217FB2C400D95E9C /* Speculid_Installer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speculid_Installer.h; sourceTree = ""; }; - B323FC05217FB2C400D95E9C /* Speculid_Installer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Speculid_Installer.m; sourceTree = ""; }; - B323FC07217FB2C400D95E9C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; B323FC09217FB2C400D95E9C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - B323FC0E217FB44400D95E9C /* launchd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = launchd.plist; sourceTree = ""; }; + B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Speculid-Mac-Installer-Launchd.plist"; sourceTree = ""; }; B323FC10217FB5CB00D95E9C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = ""; }; B3242E97213DBE6C0063037C /* speculid */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = speculid; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -3953,6 +3951,7 @@ B3F809C820E585E900030497 /* api-index-0-9-30.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "api-index-0-9-30.html"; sourceTree = ""; }; B3F809CA20E585E900030497 /* HarfBuzz-0.0.gir */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "HarfBuzz-0.0.gir"; sourceTree = ""; }; B3FAD3EA1FA564D0004381A7 /* VersionMenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionMenuItem.swift; sourceTree = ""; }; + B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallerProtocol.swift; sourceTree = ""; }; C743CA092B2436D579EB1965 /* Pods-Speculid-Mac-XPC.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Speculid-Mac-XPC.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Speculid-Mac-XPC/Pods-Speculid-Mac-XPC.debug.xcconfig"; sourceTree = ""; }; C7A962F08D51F2247E1ADBEF /* Pods-SpeculidTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SpeculidTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SpeculidTests/Pods-SpeculidTests.release.xcconfig"; sourceTree = ""; }; DCB0AF202D3672415910AFDE /* Pods_Speculid.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Speculid.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -4308,6 +4307,7 @@ B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */, B3F0ECEF1F9E6A4D0078690E /* SpeculidImageSpecificationBuilderProtocol.swift */, B3CB156F2113AA8C00A6DC5C /* VersionProvider.swift */, + B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */, ); path = Protocols; sourceTree = ""; @@ -4788,12 +4788,8 @@ B323FC02217FB2C400D95E9C /* Speculid-Installer */ = { isa = PBXGroup; children = ( - B323FC03217FB2C400D95E9C /* Speculid_InstallerProtocol.h */, - B323FC04217FB2C400D95E9C /* Speculid_Installer.h */, - B323FC05217FB2C400D95E9C /* Speculid_Installer.m */, - B323FC07217FB2C400D95E9C /* main.m */, B323FC09217FB2C400D95E9C /* Info.plist */, - B323FC0E217FB44400D95E9C /* launchd.plist */, + B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */, B323FC10217FB5CB00D95E9C /* main.swift */, B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */, ); @@ -14326,7 +14322,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - B323FC0F217FB44400D95E9C /* launchd.plist in Resources */, + B323FC0F217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -14676,6 +14672,7 @@ files = ( B323FC13217FB5F500D95E9C /* ServiceDelegate.swift in Sources */, B323FC11217FB5CB00D95E9C /* main.swift in Sources */, + B3FDF6462180A3FF00455A43 /* InstallerProtocol.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -14755,6 +14752,7 @@ B3FAD3EB1FA564D0004381A7 /* VersionMenuItem.swift in Sources */, B3D32A061F9A5FEE0042B46F /* FileHandle.swift in Sources */, B3136DD51F90E45F0002B7AB /* ServiceProtocol.swift in Sources */, + B3FDF6452180A3FF00455A43 /* InstallerProtocol.swift in Sources */, B3136E4C1F90F73B0002B7AB /* AnalyticsEventProtocol.swift in Sources */, B31BEB001F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift in Sources */, B3E9A9031FB4DDE400FD8E7A /* Version.swift in Sources */, @@ -14967,6 +14965,7 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = MLT7M394S7; @@ -14976,6 +14975,7 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.2; @@ -14987,6 +14987,7 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = MLT7M394S7; @@ -14995,6 +14996,7 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_VERSION = 4.2; }; diff --git a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme index dc1e0e17..c13acd75 100644 --- a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme +++ b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme @@ -62,7 +62,7 @@ com.brightdigit.Speculid-Mac-Installer + SMPrivilegedExecutables + + com.brightdigit.Speculid-Mac-Installer + identifier com.brightdigit.Speculid-Mac-Installer and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" + diff --git a/frameworks/speculid/Controllers/Application.swift b/frameworks/speculid/Controllers/Application.swift index 0d12bf0a..86ecc245 100644 --- a/frameworks/speculid/Controllers/Application.swift +++ b/frameworks/speculid/Controllers/Application.swift @@ -20,6 +20,10 @@ func exceptionHandlerMethod(exception: NSException) { public typealias RegularExpressionArgumentSet = (String, options: NSRegularExpression.Options) open class Application: NSApplication, ApplicationProtocol { + public func withInstaller(_ completed: (Result) -> Void) { + installerObjectInterfaceProvider.remoteObjectProxyWithHandler(completed) + } + public func document(url: URL) throws -> SpeculidDocumentProtocol { return try SpeculidDocument(url: url, decoder: jsonDecoder, configuration: configuration) } @@ -56,6 +60,7 @@ open class Application: NSApplication, ApplicationProtocol { open private(set) var commandLineActivity: CommandLineActivityProtocol? open private(set) var statusItem: NSStatusItem? open private(set) var service: ServiceProtocol! + open private(set) var installer: InstallerProtocol! open private(set) var regularExpressions: RegularExpressionSetProtocol! open private(set) var tracker: AnalyticsTrackerProtocol! open private(set) var configuration: SpeculidConfigurationProtocol! @@ -63,6 +68,7 @@ open class Application: NSApplication, ApplicationProtocol { open let statusItemProvider: StatusItemProviderProtocol open let remoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol + open let installerObjectInterfaceProvider: InstallerObjectInterfaceProviderProtocol open let regularExpressionBuilder: RegularExpressionSetBuilderProtocol open let configurationBuilder: SpeculidConfigurationBuilderProtocol open let jsonDecoder: JSONDecoder @@ -72,6 +78,7 @@ open class Application: NSApplication, ApplicationProtocol { public override init() { statusItemProvider = StatusItemProvider() remoteObjectInterfaceProvider = RemoteObjectInterfaceProvider() + installerObjectInterfaceProvider = InstallerObjectInterfaceProvider() regularExpressionBuilder = RegularExpressionSetBuilder() configurationBuilder = SpeculidConfigurationBuilder() jsonDecoder = JSONDecoder() @@ -87,6 +94,7 @@ open class Application: NSApplication, ApplicationProtocol { public required init?(coder: NSCoder) { statusItemProvider = StatusItemProvider() remoteObjectInterfaceProvider = RemoteObjectInterfaceProvider() + installerObjectInterfaceProvider = InstallerObjectInterfaceProvider() regularExpressionBuilder = RegularExpressionSetBuilder() configurationBuilder = SpeculidConfigurationBuilder(coder: coder) jsonDecoder = JSONDecoder() diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index 00568260..f60854fd 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -18,6 +18,22 @@ public struct CommandLineInstaller { let result = SMJobBless(kSMDomainSystemLaunchd, "com.brightdigit.Speculid-Mac-Installer" as CFString, authorizationRef, &cfError) debugPrint(result) debugPrint(cfError?.takeRetainedValue()) - completed() + + Application.current.withInstaller { + result in + + switch result { + case let .success(installer): + installer.hello(name: "Foo", { value in + + debugPrint(value) + completed() + }) + + case let .error(error): + debugPrint(error) + completed() + } + } } } diff --git a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift index 652a2f2f..c5b8ce66 100644 --- a/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift +++ b/frameworks/speculid/Controllers/RemoteObjectInterfaceProvider.swift @@ -29,3 +29,32 @@ public struct RemoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtoc handler(result) } } + +public struct InstallerObjectInterfaceProvider: InstallerObjectInterfaceProviderProtocol { + public func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) { + let interface = NSXPCInterface(with: InstallerProtocol.self) + let connection = + NSXPCConnection(machServiceName: "com.brightdigit.Speculid-Mac-Installer", options: .privileged) + + connection.remoteObjectInterface = interface + connection.resume() + + var error: Error? + + let proxy = connection.remoteObjectProxyWithErrorHandler { handlerError in + error = handlerError + } + + let result: Result + + if let error = error { + result = .error(error) + } else if let service = proxy as? InstallerProtocol { + result = .success(service) + } else { + result = .error(NoServiceReturnedError()) + } + + handler(result) + } +} diff --git a/frameworks/speculid/Protocols/ApplicationProtocol.swift b/frameworks/speculid/Protocols/ApplicationProtocol.swift index 001b9820..9966f9c6 100644 --- a/frameworks/speculid/Protocols/ApplicationProtocol.swift +++ b/frameworks/speculid/Protocols/ApplicationProtocol.swift @@ -5,7 +5,9 @@ public protocol ApplicationProtocol: VersionProvider { func document(url: URL) throws -> SpeculidDocumentProtocol var builder: SpeculidBuilderProtocol! { get } var service: ServiceProtocol! { get } + // var installer: InstallerProtocol! { get } var regularExpressions: RegularExpressionSetProtocol! { get } var tracker: AnalyticsTrackerProtocol! { get } func quit(_ sender: Any?) + func withInstaller(_ completed: (Result) -> Void) } diff --git a/frameworks/speculid/Protocols/InstallerProtocol.swift b/frameworks/speculid/Protocols/InstallerProtocol.swift new file mode 100644 index 00000000..3952442d --- /dev/null +++ b/frameworks/speculid/Protocols/InstallerProtocol.swift @@ -0,0 +1,5 @@ +import Foundation + +@objc public protocol InstallerProtocol { + func hello(name: String, _ completed: (String) -> Void) +} diff --git a/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift b/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift index 38639ea2..3a549b39 100644 --- a/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift +++ b/frameworks/speculid/Protocols/RemoteObjectInterfaceProviderProtocol.swift @@ -3,3 +3,7 @@ import Foundation public protocol RemoteObjectInterfaceProviderProtocol { func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) } + +public protocol InstallerObjectInterfaceProviderProtocol { + func remoteObjectProxyWithHandler(_ handler: (Result) -> Void) +} From 218f28a20d36db815e2b7f6177019ea4d6c1c412 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 16:40:12 -0400 Subject: [PATCH 07/15] adding CodeSigningUpdate script --- Speculid-Installer/Info.plist | 2 +- Speculid.xcodeproj/project.pbxproj | 2 ++ applications/mac/Info.plist | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Speculid-Installer/Info.plist b/Speculid-Installer/Info.plist index d799034a..174a16be 100644 --- a/Speculid-Installer/Info.plist +++ b/Speculid-Installer/Info.plist @@ -24,7 +24,7 @@ Copyright © 2018 Bright Digit, LLC. All rights reserved. SMAuthorizedClients - identifier com.brightdigit.Speculid-Mac-App and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" + identifier com.brightdigit.Speculid-Mac-App XPCService diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index a1357a47..e9c1b15c 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -1558,6 +1558,7 @@ B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = ""; }; B3242E97213DBE6C0063037C /* speculid */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = speculid; sourceTree = BUILT_PRODUCTS_DIR; }; B3242E99213DBE6C0063037C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + B326F24821810F580072D652 /* CodeSignUpdate.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = CodeSignUpdate.sh; sourceTree = ""; }; B32D69EA1F9EC5CA00C21C8C /* Speculid.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Speculid.entitlements; sourceTree = ""; }; B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusItemProviderProtocol.swift; sourceTree = ""; }; B33A533B1F954F8C00E74800 /* RemoteObjectInterfaceProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteObjectInterfaceProviderProtocol.swift; sourceTree = ""; }; @@ -4776,6 +4777,7 @@ B3220A4621154D1A00047BF6 /* scripts */ = { isa = PBXGroup; children = ( + B326F24821810F580072D652 /* CodeSignUpdate.sh */, B3220A4721154D1A00047BF6 /* fix_dylibs.sh */, B3220A4821154D1A00047BF6 /* codesign-framework.sh */, B3220A4921154D1A00047BF6 /* decrypt-certs.sh */, diff --git a/applications/mac/Info.plist b/applications/mac/Info.plist index 0a277df8..eb2ec05c 100644 --- a/applications/mac/Info.plist +++ b/applications/mac/Info.plist @@ -37,7 +37,7 @@ SMPrivilegedExecutables com.brightdigit.Speculid-Mac-Installer - identifier com.brightdigit.Speculid-Mac-Installer and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" + identifier com.brightdigit.Speculid-Mac-Installer From a4112f0d151ebe20146a0753cc38f8eb610ae65a Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 17:15:23 -0400 Subject: [PATCH 08/15] working on getting service working --- Speculid-Installer/Info.plist | 2 +- Speculid-Installer/ServiceDelegate.swift | 4 +- .../Speculid-Mac-Installer-Launchd.plist | 13 +- Speculid-Installer/main.swift | 2 +- Speculid.xcodeproj/project.pbxproj | 37 +++++ applications/mac/Info.plist | 6 +- .../Controllers/CommandLineInstaller.swift | 12 +- .../Controllers/CommandLineRunner.swift | 3 +- .../Protocols/InstallerProtocol.swift | 2 +- scripts/CodeSignUpdate.sh | 138 ++++++++++++++++++ 10 files changed, 203 insertions(+), 16 deletions(-) create mode 100755 scripts/CodeSignUpdate.sh diff --git a/Speculid-Installer/Info.plist b/Speculid-Installer/Info.plist index 174a16be..484917fa 100644 --- a/Speculid-Installer/Info.plist +++ b/Speculid-Installer/Info.plist @@ -24,7 +24,7 @@ Copyright © 2018 Bright Digit, LLC. All rights reserved. SMAuthorizedClients - identifier com.brightdigit.Speculid-Mac-App + identifier "com.brightdigit.Speculid-Mac-App" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ XPCService diff --git a/Speculid-Installer/ServiceDelegate.swift b/Speculid-Installer/ServiceDelegate.swift index 5ca592c9..d9f9e2a7 100644 --- a/Speculid-Installer/ServiceDelegate.swift +++ b/Speculid-Installer/ServiceDelegate.swift @@ -1,8 +1,8 @@ import Cocoa import CoreFoundation -public class Installer : NSObject, InstallerProtocol { - public func hello(name: String, _ completed: (String) -> Void) { +public class Installer: NSObject, InstallerProtocol { + public func hello(name: String, _ completed: @escaping (String) -> Void) { completed(["hello", name].joined(separator:" ")) } } diff --git a/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist b/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist index 0389118f..e8f2ff20 100644 --- a/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist +++ b/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist @@ -1,8 +1,13 @@ - - Label - com.brightdigit.Speculid-Mac-Installer - + + Label + com.brightdigit.Speculid-Mac-Installer + MachServices + + com.brightdigit.Speculid-Mac-Installer + + + diff --git a/Speculid-Installer/main.swift b/Speculid-Installer/main.swift index 4a14b9ee..8cfa87d4 100644 --- a/Speculid-Installer/main.swift +++ b/Speculid-Installer/main.swift @@ -1,6 +1,6 @@ import Foundation let delegate = ServiceDelegate() -let listener = NSXPCListener.service() +let listener = NSXPCListener(machServiceName: Bundle.main.bundleIdentifier!) listener.delegate = delegate listener.resume() diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index e9c1b15c..294fb743 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -14091,6 +14091,7 @@ isa = PBXNativeTarget; buildConfigurationList = B323FC0A217FB2C400D95E9C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; buildPhases = ( + B326F2492181111D0072D652 /* Update CodeSign */, B323FBFD217FB2C300D95E9C /* Sources */, B323FBFE217FB2C300D95E9C /* Frameworks */, B323FBFF217FB2C300D95E9C /* Resources */, @@ -14125,6 +14126,7 @@ isa = PBXNativeTarget; buildConfigurationList = B37C744C1F8C58F300DF505B /* Build configuration list for PBXNativeTarget "Speculid-Mac-App" */; buildPhases = ( + B326F24A2181113D0072D652 /* ShellScript */, 6B0E6A3126F4611E46C09D7C /* [CP] Check Pods Manifest.lock */, B3D329F91F9A55A20042B46F /* swiftformat */, B37C743A1F8C58F300DF505B /* Sources */, @@ -14517,6 +14519,41 @@ shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\""; }; + B326F2492181111D0072D652 /* Update CodeSign */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Update CodeSign"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}\"/scripts/CodeSignUpdate.sh\n"; + }; + B326F24A2181113D0072D652 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}\"/scripts/CodeSignUpdate.sh\n\n"; + }; B32D69ED1F9ED4A600C21C8C /* Codesign Dynamic Libraries */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/applications/mac/Info.plist b/applications/mac/Info.plist index eb2ec05c..87570230 100644 --- a/applications/mac/Info.plist +++ b/applications/mac/Info.plist @@ -30,14 +30,10 @@ Copyright © 2017 Bright Digit, LLC. All rights reserved. NSPrincipalClass $(TARGET_NAME:c99extidentifier).Application - SMAuthorizedClients - - com.brightdigit.Speculid-Mac-Installer - SMPrivilegedExecutables com.brightdigit.Speculid-Mac-Installer - identifier com.brightdigit.Speculid-Mac-Installer + identifier "com.brightdigit.Speculid-Mac-Installer" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index f60854fd..40069270 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -3,7 +3,7 @@ import Security import ServiceManagement public struct CommandLineInstaller { - public static func start(_ completed: () -> Void) { + public static func start(_ completed: @escaping () -> Void) { var authorizationRef: AuthorizationRef? let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) @@ -37,3 +37,13 @@ public struct CommandLineInstaller { } } } + +extension CommandLineInstaller { + public static func startSync() { + let semaphore = DispatchSemaphore(value: 0) + start { + semaphore.signal() + } + semaphore.wait(timeout: .now() + 100) + } +} diff --git a/frameworks/speculid/Controllers/CommandLineRunner.swift b/frameworks/speculid/Controllers/CommandLineRunner.swift index 7de80ccd..49a7f06c 100644 --- a/frameworks/speculid/Controllers/CommandLineRunner.swift +++ b/frameworks/speculid/Controllers/CommandLineRunner.swift @@ -63,7 +63,8 @@ public class CommandLineRunner: CommandLineRunnerProtocol { return completed() case let .install(type): if type.contains(.command) { - CommandLineInstaller.start(completed) + CommandLineInstaller.startSync() + return completed() } else { return completed() } diff --git a/frameworks/speculid/Protocols/InstallerProtocol.swift b/frameworks/speculid/Protocols/InstallerProtocol.swift index 3952442d..bfcb7d29 100644 --- a/frameworks/speculid/Protocols/InstallerProtocol.swift +++ b/frameworks/speculid/Protocols/InstallerProtocol.swift @@ -1,5 +1,5 @@ import Foundation @objc public protocol InstallerProtocol { - func hello(name: String, _ completed: (String) -> Void) + func hello(name: String, _ completed: @escaping (String) -> Void) } diff --git a/scripts/CodeSignUpdate.sh b/scripts/CodeSignUpdate.sh new file mode 100755 index 00000000..1856d6f6 --- /dev/null +++ b/scripts/CodeSignUpdate.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +# CodeSignUpdate.sh +# SwiftPrivilegedHelperApplication +# +# Created by Erik Berglund. +# Copyright © 2018 Erik Berglund. All rights reserved. + +set -e + +### +### CUSTOM VARIABLES +### + +bundleIdentifierApplication="com.brightdigit.Speculid-Mac-App" +bundleIdentifierHelper="com.brightdigit.Speculid-Mac-Installer" + +### +### STATIC VARIABLES +### + +infoPlist="${INFOPLIST_FILE}" + +if [[ $( /usr/libexec/PlistBuddy -c "Print NSPrincipalClass" "${infoPlist}" 2>/dev/null ) == *Application ]]; then + target="application" +else + target="helper" +fi + +oidAppleDeveloperIDCA="1.2.840.113635.100.6.2.6" +oidAppleDeveloperIDApplication="1.2.840.113635.100.6.1.13" +oidAppleMacAppStoreApplication="1.2.840.113635.100.6.1.9" +oidAppleWWDRIntermediate="1.2.840.113635.100.6.2.1" + +### +### FUNCTIONS +### + +function appleGeneric { + printf "%s" "anchor apple generic" +} + +function appleDeveloperID { + printf "%s" "certificate leaf[field.${oidAppleMacAppStoreApplication}] /* exists */ or certificate 1[field.${oidAppleDeveloperIDCA}] /* exists */ and certificate leaf[field.${oidAppleDeveloperIDApplication}] /* exists */" +} + +function appleMacDeveloper { + printf "%s" "certificate 1[field.${oidAppleWWDRIntermediate}]" +} + +function identifierApplication { + printf "%s" "identifier \"${bundleIdentifierApplication}\"" +} + +function identifierHelper { + printf "%s" "identifier \"${bundleIdentifierHelper}\"" +} + + +function developerID { + developmentTeamIdentifier="${DEVELOPMENT_TEAM}" + if ! [[ ${developmentTeamIdentifier} =~ ^[A-Z0-9]{10}$ ]]; then + printf "%s\n" "Invalid Development Team Identifier: ${developmentTeamIdentifier}" + exit 1 + fi + + printf "%s" "certificate leaf[subject.OU] = ${developmentTeamIdentifier}" +} + +function macDeveloper { + macDeveloperCN="${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + if ! [[ ${macDeveloperCN} =~ ^Mac\ Developer:\ .*\ \([A-Z0-9]{10}\)$ ]]; then + printf "%s\n" "Invalid Mac Developer CN: ${macDeveloperCN}" + exit 1 + fi + + printf "%s" "certificate leaf[subject.CN] = \"${macDeveloperCN}\"" +} + +function updateSMPrivilegedExecutables { + /usr/libexec/PlistBuddy -c 'Delete SMPrivilegedExecutables' "${infoPlist}" + /usr/libexec/PlistBuddy -c 'Add SMPrivilegedExecutables dict' "${infoPlist}" + /usr/libexec/PlistBuddy -c 'Add SMPrivilegedExecutables:'"${bundleIdentifierHelper}"' string '"$( sed -E 's/\"/\\\"/g' <<< ${1})"'' "${infoPlist}" +} + +function updateSMAuthorizedClients { + /usr/libexec/PlistBuddy -c 'Delete SMAuthorizedClients' "${infoPlist}" + /usr/libexec/PlistBuddy -c 'Add SMAuthorizedClients array' "${infoPlist}" + /usr/libexec/PlistBuddy -c 'Add SMAuthorizedClients: string '"$( sed -E 's/\"/\\\"/g' <<< ${1})"'' "${infoPlist}" +} + +### +### MAIN SCRIPT +### + +case "${ACTION}" in + "build") + appString=$( identifierApplication ) + appString="${appString} and $( appleGeneric )" + appString="${appString} and $( macDeveloper )" + appString="${appString} and $( appleMacDeveloper )" + appString="${appString} /* exists */" + + helperString=$( identifierHelper ) + helperString="${helperString} and $( appleGeneric )" + helperString="${helperString} and $( macDeveloper )" + helperString="${helperString} and $( appleMacDeveloper )" + helperString="${helperString} /* exists */" + ;; + "install") + appString=$( appleGeneric ) + appString="${appString} and $( identifierApplication )" + appString="${appString} and ($( appleDeveloperID )" + appString="${appString} and $( developerID ))" + + helperString=$( appleGeneric ) + helperString="${helperString} and $( identifierHelper )" + helperString="${helperString} and ($( appleDeveloperID )" + helperString="${helperString} and $( developerID ))" + ;; + *) + printf "%s\n" "Unknown Xcode Action: ${ACTION}" + exit 1 + ;; +esac + +case "${target}" in + "helper") + updateSMAuthorizedClients "${appString}" + ;; + "application") + updateSMPrivilegedExecutables "${helperString}" + ;; + *) + printf "%s\n" "Unknown Target: ${target}" + exit 1 + ;; +esac From e8bae8061ec893114e5024e78c6a1bd8c658edf8 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 17:28:12 -0400 Subject: [PATCH 09/15] fixing service --- ...list => Speculid-Mac-Installer-Info.plist} | 15 --------- Speculid.xcodeproj/project.pbxproj | 32 +++++++++++++++---- 2 files changed, 26 insertions(+), 21 deletions(-) rename Speculid-Installer/{Info.plist => Speculid-Mac-Installer-Info.plist} (61%) diff --git a/Speculid-Installer/Info.plist b/Speculid-Installer/Speculid-Mac-Installer-Info.plist similarity index 61% rename from Speculid-Installer/Info.plist rename to Speculid-Installer/Speculid-Mac-Installer-Info.plist index 484917fa..5fd09ed2 100644 --- a/Speculid-Installer/Info.plist +++ b/Speculid-Installer/Speculid-Mac-Installer-Info.plist @@ -2,34 +2,19 @@ - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Speculid-Mac-Installer - CFBundleExecutable - $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) - CFBundlePackageType - XPC! CFBundleShortVersionString 1.0 CFBundleVersion 1 - NSHumanReadableCopyright - Copyright © 2018 Bright Digit, LLC. All rights reserved. SMAuthorizedClients identifier "com.brightdigit.Speculid-Mac-App" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ - XPCService - - ServiceType - Application - diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 294fb743..cfcec651 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -1552,7 +1552,7 @@ B3220A4A21154D1A00047BF6 /* shasum.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = shasum.sh; sourceTree = ""; }; B3220A4B21154D1A00047BF6 /* build-keychain.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-keychain.sh"; sourceTree = ""; }; B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "Speculid-Mac-Installer.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; - B323FC09217FB2C400D95E9C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B323FC09217FB2C400D95E9C /* Speculid-Mac-Installer-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Speculid-Mac-Installer-Info.plist"; sourceTree = ""; }; B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Speculid-Mac-Installer-Launchd.plist"; sourceTree = ""; }; B323FC10217FB5CB00D95E9C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = ""; }; @@ -4790,7 +4790,7 @@ B323FC02217FB2C400D95E9C /* Speculid-Installer */ = { isa = PBXGroup; children = ( - B323FC09217FB2C400D95E9C /* Info.plist */, + B323FC09217FB2C400D95E9C /* Speculid-Mac-Installer-Info.plist */, B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */, B323FC10217FB5CB00D95E9C /* main.swift */, B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */, @@ -15008,10 +15008,20 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = MLT7M394S7; - INFOPLIST_FILE = "Speculid-Installer/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist\"", + "-sectcreate", + __TEXT, + __launchd_plist, + "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist\"", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -15030,9 +15040,19 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = MLT7M394S7; - INFOPLIST_FILE = "Speculid-Installer/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MTL_FAST_MATH = YES; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist\"", + "-sectcreate", + __TEXT, + __launchd_plist, + "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist\"", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; From 82d480823da9f06464c417c080ebb8a5b233292a Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 20:10:52 -0400 Subject: [PATCH 10/15] integrating swift helper code --- Speculid-Installer/main.swift | 3 + .../ServiceDelegate.swift | 14 ++ .../Speculid-Mac-Installer-Info.plist | 0 .../Speculid-Mac-Installer-Launchd.plist | 0 Speculid.xcodeproj/project.pbxproj | 234 ++++++++---------- .../xcschemes/Speculid-Mac-App.xcscheme | 2 - .../Controllers/CommandLineInstaller.swift | 7 +- 7 files changed, 129 insertions(+), 131 deletions(-) rename {Speculid-Installer => Speculid-Mac-Installer}/ServiceDelegate.swift (70%) rename {Speculid-Installer => Speculid-Mac-Installer}/Speculid-Mac-Installer-Info.plist (100%) rename {Speculid-Installer => Speculid-Mac-Installer}/Speculid-Mac-Installer-Launchd.plist (100%) diff --git a/Speculid-Installer/main.swift b/Speculid-Installer/main.swift index 8cfa87d4..3fb5dc71 100644 --- a/Speculid-Installer/main.swift +++ b/Speculid-Installer/main.swift @@ -4,3 +4,6 @@ let delegate = ServiceDelegate() let listener = NSXPCListener(machServiceName: Bundle.main.bundleIdentifier!) listener.delegate = delegate listener.resume() +while !delegate.shouldQuit { + RunLoop.current.run(until: Date(timeIntervalSinceNow: delegate.shouldQuitCheckInterval)) +} diff --git a/Speculid-Installer/ServiceDelegate.swift b/Speculid-Mac-Installer/ServiceDelegate.swift similarity index 70% rename from Speculid-Installer/ServiceDelegate.swift rename to Speculid-Mac-Installer/ServiceDelegate.swift index d9f9e2a7..8f1293e5 100644 --- a/Speculid-Installer/ServiceDelegate.swift +++ b/Speculid-Mac-Installer/ServiceDelegate.swift @@ -8,6 +8,10 @@ public class Installer: NSObject, InstallerProtocol { } @objc open class ServiceDelegate: NSObject, NSXPCListenerDelegate { + + private var connections = [NSXPCConnection]() + public private(set) var shouldQuit = false + public private(set) var shouldQuitCheckInterval = 1.0 public func listener(_: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool { let exportedInterface = NSXPCInterface(with: InstallerProtocol.self) // let currentClasses: NSSet = exportedInterface.classes(for: #selector(ServiceProtocol.exportImageAtURL(_:toSpecifications:_:)), argumentIndex: 1, ofReply: false) as NSSet @@ -16,6 +20,16 @@ public class Installer: NSObject, InstallerProtocol { newConnection.exportedInterface = exportedInterface let exportedObject = Installer() newConnection.exportedObject = exportedObject + newConnection.invalidationHandler = { + if let connectionIndex = self.connections.firstIndex(of: newConnection) { + self.connections.remove(at: connectionIndex) + } + + if self.connections.isEmpty { + self.shouldQuit = true + } + } + self.connections.append(newConnection) newConnection.resume() return true } diff --git a/Speculid-Installer/Speculid-Mac-Installer-Info.plist b/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist similarity index 100% rename from Speculid-Installer/Speculid-Mac-Installer-Info.plist rename to Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist diff --git a/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist b/Speculid-Mac-Installer/Speculid-Mac-Installer-Launchd.plist similarity index 100% rename from Speculid-Installer/Speculid-Mac-Installer-Launchd.plist rename to Speculid-Mac-Installer/Speculid-Mac-Installer-Launchd.plist diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index cfcec651..37549d96 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -297,11 +297,11 @@ B31BEAFC1F96269F00496E7A /* RegularExpressionSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFB1F96269F00496E7A /* RegularExpressionSet.swift */; }; B31BEAFE1F9626AC00496E7A /* RegularExpressionSetProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFD1F9626AC00496E7A /* RegularExpressionSetProtocol.swift */; }; B31BEB001F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31BEAFF1F9626BB00496E7A /* RegularExpressionSetBuilderProtocol.swift */; }; - B323FC0D217FB34900D95E9C /* Speculid-Mac-Installer.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - B323FC0F217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist in Resources */ = {isa = PBXBuildFile; fileRef = B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */; }; - B323FC11217FB5CB00D95E9C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC10217FB5CB00D95E9C /* main.swift */; }; - B323FC13217FB5F500D95E9C /* ServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */; }; B3242E9A213DBE6C0063037C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3242E99213DBE6C0063037C /* main.swift */; }; + B326F25621811BA20072D652 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC10217FB5CB00D95E9C /* main.swift */; }; + B326F25721811BA20072D652 /* ServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */; }; + B326F25821811C870072D652 /* InstallerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */; }; + B326F25921811CCD0072D652 /* Speculid-Mac-Installer in CopyFiles */ = {isa = PBXBuildFile; fileRef = B326F24F21811B970072D652 /* Speculid-Mac-Installer */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; B33A533E1F954FF800E74800 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A533D1F954FF800E74800 /* Result.swift */; }; B33F0BB61F958640004A87DD /* StatusItemProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */; }; B33F0BB71F958640004A87DD /* RemoteObjectInterfaceProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A533B1F954F8C00E74800 /* RemoteObjectInterfaceProviderProtocol.swift */; }; @@ -992,7 +992,6 @@ B3F80CAF20E586A000030497 /* libharfbuzz-subset.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = B3F8096C20E585E800030497 /* libharfbuzz-subset.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; B3FAD3EB1FA564D0004381A7 /* VersionMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FAD3EA1FA564D0004381A7 /* VersionMenuItem.swift */; }; B3FDF6452180A3FF00455A43 /* InstallerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */; }; - B3FDF6462180A3FF00455A43 /* InstallerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */; }; CBE9EF18228D2DADFC9D264F /* Pods_Speculid.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCB0AF202D3672415910AFDE /* Pods_Speculid.framework */; }; /* End PBXBuildFile section */ @@ -1018,13 +1017,6 @@ remoteGlobalIDString = B37C74881F8C5B5C00DF505B; remoteInfo = CairoSVG; }; - B323FC14217FB96B00D95E9C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = B37C74361F8C58F300DF505B /* Project object */; - proxyType = 1; - remoteGlobalIDString = B323FC00217FB2C300D95E9C; - remoteInfo = "Speculid-Mac-Installer"; - }; B37C745C1F8C590D00DF505B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B37C74361F8C58F300DF505B /* Project object */; @@ -1058,6 +1050,15 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + B326F24D21811B970072D652 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; B33A533F1F95568F00E74800 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1073,7 +1074,7 @@ dstPath = Contents/Library/LaunchServices; dstSubfolderSpec = 1; files = ( - B323FC0D217FB34900D95E9C /* Speculid-Mac-Installer.xpc in CopyFiles */, + B326F25921811CCD0072D652 /* Speculid-Mac-Installer in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1551,14 +1552,14 @@ B3220A4921154D1A00047BF6 /* decrypt-certs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "decrypt-certs.sh"; sourceTree = ""; }; B3220A4A21154D1A00047BF6 /* shasum.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = shasum.sh; sourceTree = ""; }; B3220A4B21154D1A00047BF6 /* build-keychain.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-keychain.sh"; sourceTree = ""; }; - B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "Speculid-Mac-Installer.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; B323FC09217FB2C400D95E9C /* Speculid-Mac-Installer-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Speculid-Mac-Installer-Info.plist"; sourceTree = ""; }; B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Speculid-Mac-Installer-Launchd.plist"; sourceTree = ""; }; - B323FC10217FB5CB00D95E9C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + B323FC10217FB5CB00D95E9C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = main.swift; path = "../Speculid-Installer/main.swift"; sourceTree = ""; }; B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = ""; }; B3242E97213DBE6C0063037C /* speculid */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = speculid; sourceTree = BUILT_PRODUCTS_DIR; }; B3242E99213DBE6C0063037C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B326F24821810F580072D652 /* CodeSignUpdate.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = CodeSignUpdate.sh; sourceTree = ""; }; + B326F24F21811B970072D652 /* Speculid-Mac-Installer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Speculid-Mac-Installer"; sourceTree = BUILT_PRODUCTS_DIR; }; B32D69EA1F9EC5CA00C21C8C /* Speculid.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Speculid.entitlements; sourceTree = ""; }; B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusItemProviderProtocol.swift; sourceTree = ""; }; B33A533B1F954F8C00E74800 /* RemoteObjectInterfaceProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteObjectInterfaceProviderProtocol.swift; sourceTree = ""; }; @@ -3990,14 +3991,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B323FBFE217FB2C300D95E9C /* Frameworks */ = { + B3242E94213DBE6C0063037C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; - B3242E94213DBE6C0063037C /* Frameworks */ = { + B326F24C21811B970072D652 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( @@ -4790,10 +4791,6 @@ B323FC02217FB2C400D95E9C /* Speculid-Installer */ = { isa = PBXGroup; children = ( - B323FC09217FB2C400D95E9C /* Speculid-Mac-Installer-Info.plist */, - B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */, - B323FC10217FB5CB00D95E9C /* main.swift */, - B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */, ); path = "Speculid-Installer"; sourceTree = ""; @@ -4806,6 +4803,17 @@ path = command; sourceTree = ""; }; + B326F25021811B970072D652 /* Speculid-Mac-Installer */ = { + isa = PBXGroup; + children = ( + B323FC09217FB2C400D95E9C /* Speculid-Mac-Installer-Info.plist */, + B323FC0E217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist */, + B323FC10217FB5CB00D95E9C /* main.swift */, + B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */, + ); + path = "Speculid-Mac-Installer"; + sourceTree = ""; + }; B341888F1F9A478800C5F356 /* Controllers */ = { isa = PBXGroup; children = ( @@ -4829,6 +4837,7 @@ B37C74401F8C58F300DF505B /* applications */, B3136DB51F90E23E0002B7AB /* frameworks */, B323FC02217FB2C400D95E9C /* Speculid-Installer */, + B326F25021811B970072D652 /* Speculid-Mac-Installer */, B37C743F1F8C58F300DF505B /* Products */, B37C74801F8C5AE200DF505B /* Frameworks */, ACD4DBE14098687CAAFBB2FA /* Pods */, @@ -4846,7 +4855,7 @@ B3136E7E1F90FD2E0002B7AB /* SpeculidTests.xctest */, B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */, B3242E97213DBE6C0063037C /* speculid */, - B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */, + B326F24F21811B970072D652 /* Speculid-Mac-Installer */, ); name = Products; sourceTree = ""; @@ -14087,24 +14096,6 @@ productReference = B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - B323FC00217FB2C300D95E9C /* Speculid-Mac-Installer */ = { - isa = PBXNativeTarget; - buildConfigurationList = B323FC0A217FB2C400D95E9C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; - buildPhases = ( - B326F2492181111D0072D652 /* Update CodeSign */, - B323FBFD217FB2C300D95E9C /* Sources */, - B323FBFE217FB2C300D95E9C /* Frameworks */, - B323FBFF217FB2C300D95E9C /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "Speculid-Mac-Installer"; - productName = "Speculid-Installer"; - productReference = B323FC01217FB2C300D95E9C /* Speculid-Mac-Installer.xpc */; - productType = "com.apple.product-type.xpc-service"; - }; B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */ = { isa = PBXNativeTarget; buildConfigurationList = B3242E9D213DBE6C0063037C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Cmd" */; @@ -14122,6 +14113,24 @@ productReference = B3242E97213DBE6C0063037C /* speculid */; productType = "com.apple.product-type.tool"; }; + B326F24E21811B970072D652 /* Speculid-Mac-Installer */ = { + isa = PBXNativeTarget; + buildConfigurationList = B326F25321811B980072D652 /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; + buildPhases = ( + B326F25A21811E250072D652 /* ShellScript */, + B326F24B21811B970072D652 /* Sources */, + B326F24C21811B970072D652 /* Frameworks */, + B326F24D21811B970072D652 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Speculid-Mac-Installer"; + productName = "Speculid-Mac-Installer"; + productReference = B326F24F21811B970072D652 /* Speculid-Mac-Installer */; + productType = "com.apple.product-type.tool"; + }; B37C743D1F8C58F300DF505B /* Speculid-Mac-App */ = { isa = PBXNativeTarget; buildConfigurationList = B37C744C1F8C58F300DF505B /* Build configuration list for PBXNativeTarget "Speculid-Mac-App" */; @@ -14142,7 +14151,6 @@ buildRules = ( ); dependencies = ( - B323FC15217FB96B00D95E9C /* PBXTargetDependency */, B37C745D1F8C590D00DF505B /* PBXTargetDependency */, B37C74791F8C5ADA00DF505B /* PBXTargetDependency */, B37C748F1F8C5B5C00DF505B /* PBXTargetDependency */, @@ -14238,12 +14246,11 @@ CreatedOnToolsVersion = 9.0; ProvisioningStyle = Automatic; }; - B323FC00217FB2C300D95E9C = { + B3242E96213DBE6C0063037C = { CreatedOnToolsVersion = 10.0; - LastSwiftMigration = 1000; ProvisioningStyle = Automatic; }; - B3242E96213DBE6C0063037C = { + B326F24E21811B970072D652 = { CreatedOnToolsVersion = 10.0; ProvisioningStyle = Automatic; }; @@ -14294,7 +14301,7 @@ B3136E7D1F90FD2E0002B7AB /* SpeculidTests */, B3136E8C1F90FD3D0002B7AB /* CairoSVGTests */, B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */, - B323FC00217FB2C300D95E9C /* Speculid-Mac-Installer */, + B326F24E21811B970072D652 /* Speculid-Mac-Installer */, ); }; /* End PBXProject section */ @@ -14322,14 +14329,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B323FBFF217FB2C300D95E9C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - B323FC0F217FB44400D95E9C /* Speculid-Mac-Installer-Launchd.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; B37C743C1F8C58F300DF505B /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -14519,7 +14518,7 @@ shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\""; }; - B326F2492181111D0072D652 /* Update CodeSign */ = { + B326F24A2181113D0072D652 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -14528,16 +14527,15 @@ ); inputPaths = ( ); - name = "Update CodeSign"; outputFileListPaths = ( ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}\"/scripts/CodeSignUpdate.sh\n"; + shellScript = "\"${SRCROOT}\"/scripts/CodeSignUpdate.sh\n\n"; }; - B326F24A2181113D0072D652 /* ShellScript */ = { + B326F25A21811E250072D652 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -14552,7 +14550,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}\"/scripts/CodeSignUpdate.sh\n\n"; + shellScript = "\"${SRCROOT}\"/scripts/CodeSignUpdate.sh\n"; }; B32D69ED1F9ED4A600C21C8C /* Codesign Dynamic Libraries */ = { isa = PBXShellScriptBuildPhase; @@ -14705,21 +14703,21 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B323FBFD217FB2C300D95E9C /* Sources */ = { + B3242E93213DBE6C0063037C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B323FC13217FB5F500D95E9C /* ServiceDelegate.swift in Sources */, - B323FC11217FB5CB00D95E9C /* main.swift in Sources */, - B3FDF6462180A3FF00455A43 /* InstallerProtocol.swift in Sources */, + B3242E9A213DBE6C0063037C /* main.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - B3242E93213DBE6C0063037C /* Sources */ = { + B326F24B21811B970072D652 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B3242E9A213DBE6C0063037C /* main.swift in Sources */, + B326F25621811BA20072D652 /* main.swift in Sources */, + B326F25721811BA20072D652 /* ServiceDelegate.swift in Sources */, + B326F25821811C870072D652 /* InstallerProtocol.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -14866,11 +14864,6 @@ target = B37C74881F8C5B5C00DF505B /* CairoSVG */; targetProxy = B3136E931F90FD3D0002B7AB /* PBXContainerItemProxy */; }; - B323FC15217FB96B00D95E9C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B323FC00217FB2C300D95E9C /* Speculid-Mac-Installer */; - targetProxy = B323FC14217FB96B00D95E9C /* PBXContainerItemProxy */; - }; B37C745D1F8C590D00DF505B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B37C74521F8C590D00DF505B /* Speculid-Mac-XPC */; @@ -14999,93 +14992,82 @@ }; name = Release; }; - B323FC0B217FB2C400D95E9C /* Debug */ = { + B3242E9B213DBE6C0063037C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = MLT7M394S7; - INFOPLIST_FILE = "$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + INSTALL_PATH = ""; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - OTHER_LDFLAGS = ( - "-sectcreate", - __TEXT, - __info_plist, - "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist\"", - "-sectcreate", - __TEXT, - __launchd_plist, - "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist\"", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + MTL_FAST_MATH = YES; + PRODUCT_NAME = speculid; SWIFT_VERSION = 4.2; }; name = Debug; }; - B323FC0C217FB2C400D95E9C /* Release */ = { + B3242E9C213DBE6C0063037C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = MLT7M394S7; - INFOPLIST_FILE = "$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MTL_FAST_MATH = YES; - OTHER_LDFLAGS = ( - "-sectcreate", - __TEXT, - __info_plist, - "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Info.plist\"", - "-sectcreate", - __TEXT, - __launchd_plist, - "\"$(SRCROOT)/Speculid-Installer/Speculid-Mac-Installer-Launchd.plist\"", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = YES; + INSTALL_PATH = ""; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_FAST_MATH = YES; + PRODUCT_NAME = speculid; SWIFT_VERSION = 4.2; }; name = Release; }; - B3242E9B213DBE6C0063037C /* Debug */ = { + B326F25421811B980072D652 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; - INSTALL_PATH = ""; - MACOSX_DEPLOYMENT_TARGET = 10.14; + INFOPLIST_FILE = "$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_NAME = speculid; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "\"$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist\"", + "-sectcreate", + __TEXT, + __launchd_plist, + "\"$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Launchd.plist\"", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; + PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; }; name = Debug; }; - B3242E9C213DBE6C0063037C /* Release */ = { + B326F25521811B980072D652 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; - INSTALL_PATH = ""; - MACOSX_DEPLOYMENT_TARGET = 10.14; + INFOPLIST_FILE = "$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_FAST_MATH = YES; - PRODUCT_NAME = speculid; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "\"$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist\"", + "-sectcreate", + __TEXT, + __launchd_plist, + "\"$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Launchd.plist\"", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; + PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; }; name = Release; @@ -15483,20 +15465,20 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - B323FC0A217FB2C400D95E9C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */ = { + B3242E9D213DBE6C0063037C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Cmd" */ = { isa = XCConfigurationList; buildConfigurations = ( - B323FC0B217FB2C400D95E9C /* Debug */, - B323FC0C217FB2C400D95E9C /* Release */, + B3242E9B213DBE6C0063037C /* Debug */, + B3242E9C213DBE6C0063037C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - B3242E9D213DBE6C0063037C /* Build configuration list for PBXNativeTarget "Speculid-Mac-Cmd" */ = { + B326F25321811B980072D652 /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */ = { isa = XCConfigurationList; buildConfigurations = ( - B3242E9B213DBE6C0063037C /* Debug */, - B3242E9C213DBE6C0063037C /* Release */, + B326F25421811B980072D652 /* Debug */, + B326F25521811B980072D652 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme index c13acd75..f0a59326 100644 --- a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme +++ b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme @@ -65,8 +65,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "nl" - region = "NL" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index 40069270..2cda9e80 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -6,13 +6,14 @@ public struct CommandLineInstaller { public static func start(_ completed: @escaping () -> Void) { var authorizationRef: AuthorizationRef? - let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) - var items = AuthorizationItem(name: kAuthorizationRightExecute, valueLength: 0, value: nil, flags: 0) + //let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) + var items = AuthorizationItem(name: kSMRightBlessPrivilegedHelper, valueLength: 0, value: nil, flags: 0) var rights = AuthorizationRights(count: 1, items: &items) let flags: AuthorizationFlags = [.interactionAllowed, .extendRights, .preAuthorize] - let err = AuthorizationCopyRights(authorizationRef!, &rights, nil, flags, nil) + //let err = AuthorizationCopyRights(authorizationRef!, &rights, nil, flags, nil) + var cfError: Unmanaged? let result = SMJobBless(kSMDomainSystemLaunchd, "com.brightdigit.Speculid-Mac-Installer" as CFString, authorizationRef, &cfError) From 6ee8129b5b7f3112e374e312a5fba0aba10879ed Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 24 Oct 2018 21:31:52 -0400 Subject: [PATCH 11/15] fixing installer --- Speculid-Mac-Installer/ServiceDelegate.swift | 2 ++ .../Speculid-Mac-Installer-Info.plist | 4 +-- Speculid.xcodeproj/project.pbxproj | 32 ++++++++----------- .../Controllers/CommandLineInstaller.swift | 8 ++--- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Speculid-Mac-Installer/ServiceDelegate.swift b/Speculid-Mac-Installer/ServiceDelegate.swift index 8f1293e5..50df2858 100644 --- a/Speculid-Mac-Installer/ServiceDelegate.swift +++ b/Speculid-Mac-Installer/ServiceDelegate.swift @@ -33,4 +33,6 @@ public class Installer: NSObject, InstallerProtocol { newConnection.resume() return true } + + } diff --git a/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist b/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist index 5fd09ed2..b2eb3476 100644 --- a/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist +++ b/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist @@ -3,11 +3,11 @@ CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + com.brightdigit.Speculid-Mac-Installer CFBundleInfoDictionaryVersion 6.0 CFBundleName - $(PRODUCT_NAME) + com.brightdigit.Speculid-Mac-Installer CFBundleShortVersionString 1.0 CFBundleVersion diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 37549d96..5307806d 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -301,7 +301,7 @@ B326F25621811BA20072D652 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC10217FB5CB00D95E9C /* main.swift */; }; B326F25721811BA20072D652 /* ServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B323FC12217FB5F500D95E9C /* ServiceDelegate.swift */; }; B326F25821811C870072D652 /* InstallerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FDF6442180A3FF00455A43 /* InstallerProtocol.swift */; }; - B326F25921811CCD0072D652 /* Speculid-Mac-Installer in CopyFiles */ = {isa = PBXBuildFile; fileRef = B326F24F21811B970072D652 /* Speculid-Mac-Installer */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + B326F25921811CCD0072D652 /* com.brightdigit.Speculid-Mac-Installer in CopyFiles */ = {isa = PBXBuildFile; fileRef = B326F24F21811B970072D652 /* com.brightdigit.Speculid-Mac-Installer */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; B33A533E1F954FF800E74800 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A533D1F954FF800E74800 /* Result.swift */; }; B33F0BB61F958640004A87DD /* StatusItemProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */; }; B33F0BB71F958640004A87DD /* RemoteObjectInterfaceProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33A533B1F954F8C00E74800 /* RemoteObjectInterfaceProviderProtocol.swift */; }; @@ -1074,7 +1074,7 @@ dstPath = Contents/Library/LaunchServices; dstSubfolderSpec = 1; files = ( - B326F25921811CCD0072D652 /* Speculid-Mac-Installer in CopyFiles */, + B326F25921811CCD0072D652 /* com.brightdigit.Speculid-Mac-Installer in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1559,7 +1559,7 @@ B3242E97213DBE6C0063037C /* speculid */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = speculid; sourceTree = BUILT_PRODUCTS_DIR; }; B3242E99213DBE6C0063037C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B326F24821810F580072D652 /* CodeSignUpdate.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = CodeSignUpdate.sh; sourceTree = ""; }; - B326F24F21811B970072D652 /* Speculid-Mac-Installer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Speculid-Mac-Installer"; sourceTree = BUILT_PRODUCTS_DIR; }; + B326F24F21811B970072D652 /* com.brightdigit.Speculid-Mac-Installer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "com.brightdigit.Speculid-Mac-Installer"; sourceTree = BUILT_PRODUCTS_DIR; }; B32D69EA1F9EC5CA00C21C8C /* Speculid.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Speculid.entitlements; sourceTree = ""; }; B33A53391F954E4B00E74800 /* StatusItemProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusItemProviderProtocol.swift; sourceTree = ""; }; B33A533B1F954F8C00E74800 /* RemoteObjectInterfaceProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteObjectInterfaceProviderProtocol.swift; sourceTree = ""; }; @@ -4788,13 +4788,6 @@ path = scripts; sourceTree = ""; }; - B323FC02217FB2C400D95E9C /* Speculid-Installer */ = { - isa = PBXGroup; - children = ( - ); - path = "Speculid-Installer"; - sourceTree = ""; - }; B3242E9E213DBE960063037C /* command */ = { isa = PBXGroup; children = ( @@ -4836,7 +4829,6 @@ B3136E6A1F90FCD90002B7AB /* tests */, B37C74401F8C58F300DF505B /* applications */, B3136DB51F90E23E0002B7AB /* frameworks */, - B323FC02217FB2C400D95E9C /* Speculid-Installer */, B326F25021811B970072D652 /* Speculid-Mac-Installer */, B37C743F1F8C58F300DF505B /* Products */, B37C74801F8C5AE200DF505B /* Frameworks */, @@ -4855,7 +4847,7 @@ B3136E7E1F90FD2E0002B7AB /* SpeculidTests.xctest */, B3136E8D1F90FD3D0002B7AB /* CairoSVGTests.xctest */, B3242E97213DBE6C0063037C /* speculid */, - B326F24F21811B970072D652 /* Speculid-Mac-Installer */, + B326F24F21811B970072D652 /* com.brightdigit.Speculid-Mac-Installer */, ); name = Products; sourceTree = ""; @@ -14113,9 +14105,9 @@ productReference = B3242E97213DBE6C0063037C /* speculid */; productType = "com.apple.product-type.tool"; }; - B326F24E21811B970072D652 /* Speculid-Mac-Installer */ = { + B326F24E21811B970072D652 /* com.brightdigit.Speculid-Mac-Installer */ = { isa = PBXNativeTarget; - buildConfigurationList = B326F25321811B980072D652 /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */; + buildConfigurationList = B326F25321811B980072D652 /* Build configuration list for PBXNativeTarget "com.brightdigit.Speculid-Mac-Installer" */; buildPhases = ( B326F25A21811E250072D652 /* ShellScript */, B326F24B21811B970072D652 /* Sources */, @@ -14126,9 +14118,9 @@ ); dependencies = ( ); - name = "Speculid-Mac-Installer"; + name = "com.brightdigit.Speculid-Mac-Installer"; productName = "Speculid-Mac-Installer"; - productReference = B326F24F21811B970072D652 /* Speculid-Mac-Installer */; + productReference = B326F24F21811B970072D652 /* com.brightdigit.Speculid-Mac-Installer */; productType = "com.apple.product-type.tool"; }; B37C743D1F8C58F300DF505B /* Speculid-Mac-App */ = { @@ -14301,7 +14293,7 @@ B3136E7D1F90FD2E0002B7AB /* SpeculidTests */, B3136E8C1F90FD3D0002B7AB /* CairoSVGTests */, B3242E96213DBE6C0063037C /* Speculid-Mac-Cmd */, - B326F24E21811B970072D652 /* Speculid-Mac-Installer */, + B326F24E21811B970072D652 /* com.brightdigit.Speculid-Mac-Installer */, ); }; /* End PBXProject section */ @@ -15025,6 +15017,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; INFOPLIST_FILE = "$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist"; @@ -15043,6 +15036,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.2; }; name = Debug; @@ -15051,6 +15045,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; INFOPLIST_FILE = "$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist"; @@ -15068,6 +15063,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.2; }; name = Release; @@ -15474,7 +15470,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - B326F25321811B980072D652 /* Build configuration list for PBXNativeTarget "Speculid-Mac-Installer" */ = { + B326F25321811B980072D652 /* Build configuration list for PBXNativeTarget "com.brightdigit.Speculid-Mac-Installer" */ = { isa = XCConfigurationList; buildConfigurations = ( B326F25421811B980072D652 /* Debug */, diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index 2cda9e80..7f78e8fe 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -6,14 +6,14 @@ public struct CommandLineInstaller { public static func start(_ completed: @escaping () -> Void) { var authorizationRef: AuthorizationRef? - //let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) + // let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) var items = AuthorizationItem(name: kSMRightBlessPrivilegedHelper, valueLength: 0, value: nil, flags: 0) var rights = AuthorizationRights(count: 1, items: &items) let flags: AuthorizationFlags = [.interactionAllowed, .extendRights, .preAuthorize] - //let err = AuthorizationCopyRights(authorizationRef!, &rights, nil, flags, nil) - + let stats = AuthorizationCreate(&rights, nil, flags, &authorizationRef) + // let err = AuthorizationCopyRights(authorizationRef!, &rights, nil, flags, nil) var cfError: Unmanaged? let result = SMJobBless(kSMDomainSystemLaunchd, "com.brightdigit.Speculid-Mac-Installer" as CFString, authorizationRef, &cfError) @@ -45,6 +45,6 @@ extension CommandLineInstaller { start { semaphore.signal() } - semaphore.wait(timeout: .now() + 100) + semaphore.wait(timeout: .now() + 10) } } From 887a7b1bf034d71fb1b78ea5b478c25467142520 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 25 Oct 2018 08:31:10 -0400 Subject: [PATCH 12/15] working on copying command line tool --- Speculid-Mac-Installer/ServiceDelegate.swift | 45 ++ Speculid.xcodeproj/project.pbxproj | 8 +- .../Controllers/CommandLineInstaller.swift | 42 +- .../Controllers/CommandLineRunner.swift | 2 +- .../Protocols/InstallerProtocol.swift | 1 + scripts/SMJobBlessUtil.py | 437 ++++++++++++++++++ 6 files changed, 518 insertions(+), 17 deletions(-) create mode 100755 scripts/SMJobBlessUtil.py diff --git a/Speculid-Mac-Installer/ServiceDelegate.swift b/Speculid-Mac-Installer/ServiceDelegate.swift index 50df2858..affd5233 100644 --- a/Speculid-Mac-Installer/ServiceDelegate.swift +++ b/Speculid-Mac-Installer/ServiceDelegate.swift @@ -2,9 +2,54 @@ import Cocoa import CoreFoundation public class Installer: NSObject, InstallerProtocol { + public func installCommandLineTool(fromBundleURL bundleURL: URL, _ completed: @escaping (NSError?) -> Void) { + guard let bundle = Bundle(url: bundleURL) else { + fatalError() + } + + guard let speculidCommandURL = bundle.sharedSupportURL?.appendingPathComponent("speculid") else { + fatalError() + } + + guard FileManager.default.fileExists(atPath: speculidCommandURL.path) else { + fatalError() + } + + let binDirectoryURL = URL(fileURLWithPath: "/usr/local/bin", isDirectory: true) + + var isDirectory : ObjCBool = false + + let binDirExists = FileManager.default.fileExists(atPath: binDirectoryURL.path, isDirectory: &isDirectory) + + guard isDirectory.boolValue && binDirExists else { + fatalError() + } + + let destURL = binDirectoryURL.appendingPathComponent(speculidCommandURL.lastPathComponent) + + var error : Error? + do { + try FileManager.default.copyItem(at: speculidCommandURL, to: destURL) + } catch let err { + error = err + } + } + + public func installCommandLineTool(fromBundleURL bundleURL: URL) { + guard let bundle = Bundle(url: bundleURL) else { + return + } + + guard let executableURL = bundle.url(forAuxiliaryExecutable: "speculid") else { + return + } + } + public func hello(name: String, _ completed: @escaping (String) -> Void) { completed(["hello", name].joined(separator:" ")) } + + } @objc open class ServiceDelegate: NSObject, NSXPCListenerDelegate { diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 5307806d..f1994635 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -14991,7 +14991,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; INSTALL_PATH = ""; - MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_NAME = speculid; @@ -15006,7 +15005,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; INSTALL_PATH = ""; - MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_FAST_MATH = YES; PRODUCT_NAME = speculid; SWIFT_VERSION = 4.2; @@ -15021,7 +15019,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; INFOPLIST_FILE = "$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_LDFLAGS = ( @@ -15049,7 +15046,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MLT7M394S7; INFOPLIST_FILE = "$(SRCROOT)/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_FAST_MATH = YES; OTHER_LDFLAGS = ( "-sectcreate", @@ -15123,7 +15119,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -15181,7 +15177,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index 7f78e8fe..0f03f916 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -2,24 +2,34 @@ import Foundation import Security import ServiceManagement +struct TimeoutError: Error {} +struct OSStatusError: Error { + let osStatus: OSStatus +} + public struct CommandLineInstaller { - public static func start(_ completed: @escaping () -> Void) { + public static func start(_ completed: @escaping (Error?) -> Void) { var authorizationRef: AuthorizationRef? - // let status = AuthorizationCreate(nil, nil, AuthorizationFlags(rawValue: 0), &authorizationRef) var items = AuthorizationItem(name: kSMRightBlessPrivilegedHelper, valueLength: 0, value: nil, flags: 0) var rights = AuthorizationRights(count: 1, items: &items) let flags: AuthorizationFlags = [.interactionAllowed, .extendRights, .preAuthorize] - let stats = AuthorizationCreate(&rights, nil, flags, &authorizationRef) - // let err = AuthorizationCopyRights(authorizationRef!, &rights, nil, flags, nil) + let osStatus = AuthorizationCreate(&rights, nil, flags, &authorizationRef) + + guard osStatus == errAuthorizationSuccess else { + completed(OSStatusError(osStatus: osStatus)) + return + } var cfError: Unmanaged? let result = SMJobBless(kSMDomainSystemLaunchd, "com.brightdigit.Speculid-Mac-Installer" as CFString, authorizationRef, &cfError) - debugPrint(result) - debugPrint(cfError?.takeRetainedValue()) + guard result else { + completed(cfError?.takeRetainedValue()) + return + } Application.current.withInstaller { result in @@ -28,23 +38,35 @@ public struct CommandLineInstaller { installer.hello(name: "Foo", { value in debugPrint(value) - completed() + completed(nil) }) case let .error(error): debugPrint(error) - completed() + completed(nil) } } } } extension CommandLineInstaller { - public static func startSync() { + public static func startSync() -> Error? { + var error: Error? let semaphore = DispatchSemaphore(value: 0) start { + error = $0 semaphore.signal() } - semaphore.wait(timeout: .now() + 10) + let result = semaphore.wait(timeout: .now() + 10) + if let error = error { + return error + } else { + switch result { + case .success: + return nil + case .timedOut: + return TimeoutError() + } + } } } diff --git a/frameworks/speculid/Controllers/CommandLineRunner.swift b/frameworks/speculid/Controllers/CommandLineRunner.swift index 49a7f06c..15d15542 100644 --- a/frameworks/speculid/Controllers/CommandLineRunner.swift +++ b/frameworks/speculid/Controllers/CommandLineRunner.swift @@ -63,7 +63,7 @@ public class CommandLineRunner: CommandLineRunnerProtocol { return completed() case let .install(type): if type.contains(.command) { - CommandLineInstaller.startSync() + error = CommandLineInstaller.startSync() return completed() } else { return completed() diff --git a/frameworks/speculid/Protocols/InstallerProtocol.swift b/frameworks/speculid/Protocols/InstallerProtocol.swift index bfcb7d29..15cf3f09 100644 --- a/frameworks/speculid/Protocols/InstallerProtocol.swift +++ b/frameworks/speculid/Protocols/InstallerProtocol.swift @@ -2,4 +2,5 @@ import Foundation @objc public protocol InstallerProtocol { func hello(name: String, _ completed: @escaping (String) -> Void) + func installCommandLineTool(fromBundleURL bundleURL: URL, _ completed: @escaping (NSError?) -> Void) } diff --git a/scripts/SMJobBlessUtil.py b/scripts/SMJobBlessUtil.py new file mode 100755 index 00000000..c041363a --- /dev/null +++ b/scripts/SMJobBlessUtil.py @@ -0,0 +1,437 @@ +#! /usr/bin/python +# +# File: SMJobBlessUtil.py +# +# Contains: Tool for checking and correcting apps that use SMJobBless. +# +# Written by: DTS +# +# Copyright: Copyright (c) 2012 Apple Inc. All Rights Reserved. +# +# Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. +# ("Apple") in consideration of your agreement to the following +# terms, and your use, installation, modification or +# redistribution of this Apple software constitutes acceptance of +# these terms. If you do not agree with these terms, please do +# not use, install, modify or redistribute this Apple software. +# +# In consideration of your agreement to abide by the following +# terms, and subject to these terms, Apple grants you a personal, +# non-exclusive license, under Apple's copyrights in this +# original Apple software (the "Apple Software"), to use, +# reproduce, modify and redistribute the Apple Software, with or +# without modifications, in source and/or binary forms; provided +# that if you redistribute the Apple Software in its entirety and +# without modifications, you must retain this notice and the +# following text and disclaimers in all such redistributions of +# the Apple Software. Neither the name, trademarks, service marks +# or logos of Apple Inc. may be used to endorse or promote +# products derived from the Apple Software without specific prior +# written permission from Apple. Except as expressly stated in +# this notice, no other rights or licenses, express or implied, +# are granted by Apple herein, including but not limited to any +# patent rights that may be infringed by your derivative works or +# by other works in which the Apple Software may be incorporated. +# +# The Apple Software is provided by Apple on an "AS IS" basis. +# APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING +# WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING +# THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN +# COMBINATION WITH YOUR PRODUCTS. +# +# IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, +# INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY +# OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION +# OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY +# OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR +# OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +import sys +import os +import getopt +import subprocess +import plistlib +import operator + +class UsageException (Exception): + """ + Raised when the progam detects a usage issue; the top-level code catches this + and prints a usage message. + """ + pass + +class CheckException (Exception): + """ + Raised when the "check" subcommand detects a problem; the top-level code catches + this and prints a nice error message. + """ + def __init__(self, message, path=None): + self.message = message + self.path = path + +def checkCodeSignature(programPath, programType): + """Checks the code signature of the referenced program.""" + + # Use the codesign tool to check the signature. The second "-v" is required to enable + # verbose mode, which causes codesign to do more checking. By default it does the minimum + # amount of checking ("Is the program properly signed?"). If you enabled verbose mode it + # does other sanity checks, which we definitely want. The specific thing I'd like to + # detect is "Does the code satisfy its own designated requirement?" and I need to enable + # verbose mode to get that. + + args = [ + # "false", + "codesign", + "-v", + "-v", + programPath + ] + try: + subprocess.check_call(args, stderr=open("/dev/null")) + except subprocess.CalledProcessError, e: + raise CheckException("%s code signature invalid" % programType, programPath) + +def readDesignatedRequirement(programPath, programType): + """Returns the designated requirement of the program as a string.""" + args = [ + # "false", + "codesign", + "-d", + "-r", + "-", + programPath + ] + try: + req = subprocess.check_output(args, stderr=open("/dev/null")) + except subprocess.CalledProcessError, e: + raise CheckException("%s designated requirement unreadable" % programType, programPath) + + reqLines = req.splitlines() + if len(reqLines) != 1 or not req.startswith("designated => "): + raise CheckException("%s designated requirement malformed" % programType, programPath) + return reqLines[0][len("designated => "):] + +def readInfoPlistFromPath(infoPath): + """Reads an "Info.plist" file from the specified path.""" + try: + info = plistlib.readPlist(infoPath) + except: + raise CheckException("'Info.plist' not readable", infoPath) + if not isinstance(info, dict): + raise CheckException("'Info.plist' root must be a dictionary", infoPath) + return info + +def readPlistFromToolSection(toolPath, segmentName, sectionName): + """Reads a dictionary property list from the specified section within the specified executable.""" + + # Run otool -s to get a hex dump of the section. + + args = [ + # "false", + "otool", + "-s", + segmentName, + sectionName, + toolPath + ] + try: + plistDump = subprocess.check_output(args) + except subprocess.CalledProcessError, e: + raise CheckException("tool %s / %s section unreadable" % (segmentName, sectionName), toolPath) + + # Convert that hex dump to an property list. + + plistLines = plistDump.splitlines() + if len(plistLines) < 3 or plistLines[1] != ("Contents of (%s,%s) section" % (segmentName, sectionName)): + raise CheckException("tool %s / %s section dump malformed (1)" % (segmentName, sectionName), toolPath) + del plistLines[0:2] + + try: + bytes = [] + for line in plistLines: + # line looks like this: + # + # '0000000100000b80\t3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31 ' + columns = line.split("\t") + assert len(columns) == 2 + for hexStr in columns[1].split(): + bytes.append(int(hexStr, 16)) + plist = plistlib.readPlistFromString(bytearray(bytes)) + except: + raise CheckException("tool %s / %s section dump malformed (2)" % (segmentName, sectionName), toolPath) + + # Check the root of the property list. + + if not isinstance(plist, dict): + raise CheckException("tool %s / %s property list root must be a dictionary" % (segmentName, sectionName), toolPath) + + return plist + +def checkStep1(appPath): + """Checks that the app and the tool are both correctly code signed.""" + + if not os.path.isdir(appPath): + raise CheckException("app not found", appPath) + + # Check the app's code signature. + + checkCodeSignature(appPath, "app") + + # Check the tool directory. + + toolDirPath = os.path.join(appPath, "Contents", "Library", "LaunchServices") + if not os.path.isdir(toolDirPath): + raise CheckException("tool directory not found", toolDirPath) + + # Check each tool's code signature. + + toolPathList = [] + for toolName in os.listdir(toolDirPath): + if toolName != ".DS_Store": + toolPath = os.path.join(toolDirPath, toolName) + if not os.path.isfile(toolPath): + raise CheckException("tool directory contains a directory", toolPath) + checkCodeSignature(toolPath, "tool") + toolPathList.append(toolPath) + + # Check that we have at least one tool. + + if len(toolPathList) == 0: + raise CheckException("no tools found", toolDirPath) + + return toolPathList + +def checkStep2(appPath, toolPathList): + """Checks the SMPrivilegedExecutables entry in the app's "Info.plist".""" + + # Create a map from the tool name (not path) to its designated requirement. + + toolNameToReqMap = dict() + for toolPath in toolPathList: + req = readDesignatedRequirement(toolPath, "tool") + toolNameToReqMap[os.path.basename(toolPath)] = req + + # Read the Info.plist for the app and extract the SMPrivilegedExecutables value. + + infoPath = os.path.join(appPath, "Contents", "Info.plist") + info = readInfoPlistFromPath(infoPath) + if not info.has_key("SMPrivilegedExecutables"): + raise CheckException("'SMPrivilegedExecutables' not found", infoPath) + infoToolDict = info["SMPrivilegedExecutables"] + if not isinstance(infoToolDict, dict): + raise CheckException("'SMPrivilegedExecutables' must be a dictionary", infoPath) + + # Check that the list of tools matches the list of SMPrivilegedExecutables entries. + + if sorted(infoToolDict.keys()) != sorted(toolNameToReqMap.keys()): + raise CheckException("'SMPrivilegedExecutables' and tools in 'Contents/Library/LaunchServices' don't match") + + # Check that all the requirements match. + + # This is an interesting policy choice. Technically the tool just needs to match + # the requirement listed in SMPrivilegedExecutables, and we can check that by + # putting the requirement into tmp.req and then running + # + # $ codesign -v -R tmp.req /path/to/tool + # + # However, for a Developer ID signed tool we really want to have the SMPrivilegedExecutables + # entry contain the tool's designated requirement because Xcode has built a + # more complex DR that does lots of useful and important checks. So, as a matter + # of policy we require that the value in SMPrivilegedExecutables match the tool's DR. + + for toolName in infoToolDict: + if infoToolDict[toolName] != toolNameToReqMap[toolName]: + raise CheckException("tool designated requirement (%s) doesn't match entry in 'SMPrivilegedExecutables' (%s)" % (toolNameToReqMap[toolName], infoToolDict[toolName])) + +def checkStep3(appPath, toolPathList): + """Checks the "Info.plist" embedded in each helper tool.""" + + # First get the app's designated requirement. + + appReq = readDesignatedRequirement(appPath, "app") + + # Then check that the tool's SMAuthorizedClients value matches it. + + for toolPath in toolPathList: + info = readPlistFromToolSection(toolPath, "__TEXT", "__info_plist") + + if not info.has_key("CFBundleInfoDictionaryVersion") or info["CFBundleInfoDictionaryVersion"] != "6.0": + raise CheckException("'CFBundleInfoDictionaryVersion' in tool __TEXT / __info_plist section must be '6.0'", toolPath) + + if not info.has_key("CFBundleIdentifier") or info["CFBundleIdentifier"] != os.path.basename(toolPath): + raise CheckException("'CFBundleIdentifier' in tool __TEXT / __info_plist section must match tool name", toolPath) + + if not info.has_key("SMAuthorizedClients"): + raise CheckException("'SMAuthorizedClients' in tool __TEXT / __info_plist section not found", toolPath) + infoClientList = info["SMAuthorizedClients"] + if not isinstance(infoClientList, list): + raise CheckException("'SMAuthorizedClients' in tool __TEXT / __info_plist section must be an array", toolPath) + if len(infoClientList) != 1: + raise CheckException("'SMAuthorizedClients' in tool __TEXT / __info_plist section must have one entry", toolPath) + + # Again, as a matter of policy we require that the SMAuthorizedClients entry must + # match exactly the designated requirement of the app. + + if infoClientList[0] != appReq: + raise CheckException("app designated requirement (%s) doesn't match entry in 'SMAuthorizedClients' (%s)" % (appReq, infoClientList[0]), toolPath) + +def checkStep4(appPath, toolPathList): + """Checks the "launchd.plist" embedded in each helper tool.""" + + for toolPath in toolPathList: + launchd = readPlistFromToolSection(toolPath, "__TEXT", "__launchd_plist") + + if not launchd.has_key("Label") or launchd["Label"] != os.path.basename(toolPath): + raise CheckException("'Label' in tool __TEXT / __launchd_plist section must match tool name", toolPath) + + # We don't need to check that the label matches the bundle identifier because + # we know it matches the tool name and step 4 checks that the tool name matches + # the bundle identifier. + +def checkStep5(appPath): + """There's nothing to do here; we effectively checked for this is steps 1 and 2.""" + pass + +def check(appPath): + """Checks the SMJobBless setup of the specified app.""" + + # Each of the following steps matches a bullet point in the SMJobBless header doc. + + toolPathList = checkStep1(appPath) + + checkStep2(appPath, toolPathList) + + checkStep3(appPath, toolPathList) + + checkStep4(appPath, toolPathList) + + checkStep5(appPath) + +def setreq(appPath, appInfoPlistPath, toolInfoPlistPaths): + """ + Reads information from the built app and uses it to set the SMJobBless setup + in the specified app and tool Info.plist source files. + """ + + if not os.path.isdir(appPath): + raise CheckException("app not found", appPath) + + if not os.path.isfile(appInfoPlistPath): + raise CheckException("app 'Info.plist' not found", appInfoPlistPath) + for toolInfoPlistPath in toolInfoPlistPaths: + if not os.path.isfile(toolInfoPlistPath): + raise CheckException("app 'Info.plist' not found", toolInfoPlistPath) + + # Get the designated requirement for the app and each of the tools. + + appReq = readDesignatedRequirement(appPath, "app") + + toolDirPath = os.path.join(appPath, "Contents", "Library", "LaunchServices") + if not os.path.isdir(toolDirPath): + raise CheckException("tool directory not found", toolDirPath) + + toolNameToReqMap = {} + for toolName in os.listdir(toolDirPath): + req = readDesignatedRequirement(os.path.join(toolDirPath, toolName), "tool") + toolNameToReqMap[toolName] = req + + if len(toolNameToReqMap) > len(toolInfoPlistPaths): + raise CheckException("tool directory has more tools (%d) than you've supplied tool 'Info.plist' paths (%d)" % (len(toolNameToReqMap), len(toolInfoPlistPaths)), toolDirPath) + if len(toolNameToReqMap) < len(toolInfoPlistPaths): + raise CheckException("tool directory has fewer tools (%d) than you've supplied tool 'Info.plist' paths (%d)" % (len(toolNameToReqMap), len(toolInfoPlistPaths)), toolDirPath) + + # Build the new value for SMPrivilegedExecutables. + + appToolDict = {} + toolInfoPlistPathToToolInfoMap = {} + for toolInfoPlistPath in toolInfoPlistPaths: + toolInfo = readInfoPlistFromPath(toolInfoPlistPath) + toolInfoPlistPathToToolInfoMap[toolInfoPlistPath] = toolInfo + if not toolInfo.has_key("CFBundleIdentifier"): + raise CheckException("'CFBundleIdentifier' not found", toolInfoPlistPath) + bundleID = toolInfo["CFBundleIdentifier"] + if not isinstance(bundleID, basestring): + raise CheckException("'CFBundleIdentifier' must be a string", toolInfoPlistPath) + appToolDict[bundleID] = toolNameToReqMap[bundleID] + + # Set the SMPrivilegedExecutables value in the app "Info.plist". + + appInfo = readInfoPlistFromPath(appInfoPlistPath) + needsUpdate = not appInfo.has_key("SMPrivilegedExecutables") + if not needsUpdate: + oldAppToolDict = appInfo["SMPrivilegedExecutables"] + if not isinstance(oldAppToolDict, dict): + raise CheckException("'SMPrivilegedExecutables' must be a dictionary", appInfoPlistPath) + appToolDictSorted = sorted(appToolDict.iteritems(), key=operator.itemgetter(0)) + oldAppToolDictSorted = sorted(oldAppToolDict.iteritems(), key=operator.itemgetter(0)) + needsUpdate = (appToolDictSorted != oldAppToolDictSorted) + + if needsUpdate: + appInfo["SMPrivilegedExecutables"] = appToolDict + plistlib.writePlist(appInfo, appInfoPlistPath) + print >> sys.stdout, "%s: updated" % appInfoPlistPath + + # Set the SMAuthorizedClients value in each tool's "Info.plist". + + toolAppListSorted = [ appReq ] # only one element, so obviously sorted (-: + for toolInfoPlistPath in toolInfoPlistPaths: + toolInfo = toolInfoPlistPathToToolInfoMap[toolInfoPlistPath] + + needsUpdate = not toolInfo.has_key("SMAuthorizedClients") + if not needsUpdate: + oldToolAppList = toolInfo["SMAuthorizedClients"] + if not isinstance(oldToolAppList, list): + raise CheckException("'SMAuthorizedClients' must be an array", toolInfoPlistPath) + oldToolAppListSorted = sorted(oldToolAppList) + needsUpdate = (toolAppListSorted != oldToolAppListSorted) + + if needsUpdate: + toolInfo["SMAuthorizedClients"] = toolAppListSorted + plistlib.writePlist(toolInfo, toolInfoPlistPath) + print >> sys.stdout, "%s: updated" % toolInfoPlistPath + +def main(): + options, appArgs = getopt.getopt(sys.argv[1:], "d") + + debug = False + for opt, val in options: + if opt == "-d": + debug = True + else: + raise UsageException() + + if len(appArgs) == 0: + raise UsageException() + command = appArgs[0] + if command == "check": + if len(appArgs) != 2: + raise UsageException() + check(appArgs[1]) + elif command == "setreq": + if len(appArgs) < 4: + raise UsageException() + setreq(appArgs[1], appArgs[2], appArgs[3:]) + else: + raise UsageException() + +if __name__ == "__main__": + try: + main() + except CheckException, e: + if e.path is None: + print >> sys.stderr, "%s: %s" % (os.path.basename(sys.argv[0]), e.message) + else: + path = e.path + if path.endswith("/"): + path = path[:-1] + print >> sys.stderr, "%s: %s" % (path, e.message) + sys.exit(1) + except UsageException, e: + print >> sys.stderr, "usage: %s check /path/to/app" % os.path.basename(sys.argv[0]) + print >> sys.stderr, " %s setreq /path/to/app /path/to/app/Info.plist /path/to/tool/Info.plist..." % os.path.basename(sys.argv[0]) + sys.exit(1) From 4f9efd62c93fd776baa8a8ab8cb76ef385caf6e3 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 25 Oct 2018 12:21:41 -0400 Subject: [PATCH 13/15] [skip ci] fixing installer --- Speculid-Mac-Installer/ServiceDelegate.swift | 39 +++++++++++-------- Speculid.xcodeproj/project.pbxproj | 2 +- .../Controllers/CommandLineInstaller.swift | 8 ++-- .../Protocols/InstallerProtocol.swift | 1 - scripts/fix_dylibs.sh | 1 + 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Speculid-Mac-Installer/ServiceDelegate.swift b/Speculid-Mac-Installer/ServiceDelegate.swift index affd5233..06dd50f6 100644 --- a/Speculid-Mac-Installer/ServiceDelegate.swift +++ b/Speculid-Mac-Installer/ServiceDelegate.swift @@ -1,18 +1,34 @@ import Cocoa import CoreFoundation +public enum InstallerErrorCode : Int { + public typealias RawValue = Int + case bundleNotFound = 1 + case sharedSupportNotFound = 2 + case speculidCommandNotFound = 3 + case usrLocalBinDirNotFound = 4 +} + +public struct InstallerError { + private init () {} + static func error(fromCode code: InstallerErrorCode) -> NSError { + return NSError(domain: Bundle.main.bundleIdentifier!, code: code.rawValue, userInfo: nil) + } +} + public class Installer: NSObject, InstallerProtocol { public func installCommandLineTool(fromBundleURL bundleURL: URL, _ completed: @escaping (NSError?) -> Void) { + guard let bundle = Bundle(url: bundleURL) else { - fatalError() + return completed(InstallerError.error(fromCode: .bundleNotFound)) } guard let speculidCommandURL = bundle.sharedSupportURL?.appendingPathComponent("speculid") else { - fatalError() + return completed(InstallerError.error(fromCode: .sharedSupportNotFound)) } guard FileManager.default.fileExists(atPath: speculidCommandURL.path) else { - fatalError() + return completed(InstallerError.error(fromCode: .speculidCommandNotFound)) } let binDirectoryURL = URL(fileURLWithPath: "/usr/local/bin", isDirectory: true) @@ -22,27 +38,18 @@ public class Installer: NSObject, InstallerProtocol { let binDirExists = FileManager.default.fileExists(atPath: binDirectoryURL.path, isDirectory: &isDirectory) guard isDirectory.boolValue && binDirExists else { - fatalError() + return completed(InstallerError.error(fromCode: .usrLocalBinDirNotFound)) } let destURL = binDirectoryURL.appendingPathComponent(speculidCommandURL.lastPathComponent) - var error : Error? do { try FileManager.default.copyItem(at: speculidCommandURL, to: destURL) - } catch let err { - error = err - } - } - - public func installCommandLineTool(fromBundleURL bundleURL: URL) { - guard let bundle = Bundle(url: bundleURL) else { - return + } catch let error as NSError { + completed(error) } - guard let executableURL = bundle.url(forAuxiliaryExecutable: "speculid") else { - return - } + completed(nil) } public func hello(name: String, _ completed: @escaping (String) -> Void) { diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index f1994635..c91e093a 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -14127,8 +14127,8 @@ isa = PBXNativeTarget; buildConfigurationList = B37C744C1F8C58F300DF505B /* Build configuration list for PBXNativeTarget "Speculid-Mac-App" */; buildPhases = ( - B326F24A2181113D0072D652 /* ShellScript */, 6B0E6A3126F4611E46C09D7C /* [CP] Check Pods Manifest.lock */, + B326F24A2181113D0072D652 /* ShellScript */, B3D329F91F9A55A20042B46F /* swiftformat */, B37C743A1F8C58F300DF505B /* Sources */, B37C743B1F8C58F300DF505B /* Frameworks */, diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index 0f03f916..f9189039 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -35,12 +35,10 @@ public struct CommandLineInstaller { switch result { case let .success(installer): - installer.hello(name: "Foo", { value in - - debugPrint(value) - completed(nil) + installer.installCommandLineTool(fromBundleURL: Bundle.main, { (error) in + debugPrint(error) + completed(error) }) - case let .error(error): debugPrint(error) completed(nil) diff --git a/frameworks/speculid/Protocols/InstallerProtocol.swift b/frameworks/speculid/Protocols/InstallerProtocol.swift index 15cf3f09..009ed945 100644 --- a/frameworks/speculid/Protocols/InstallerProtocol.swift +++ b/frameworks/speculid/Protocols/InstallerProtocol.swift @@ -1,6 +1,5 @@ import Foundation @objc public protocol InstallerProtocol { - func hello(name: String, _ completed: @escaping (String) -> Void) func installCommandLineTool(fromBundleURL bundleURL: URL, _ completed: @escaping (NSError?) -> Void) } diff --git a/scripts/fix_dylibs.sh b/scripts/fix_dylibs.sh index eb9a2a07..e1a06445 100755 --- a/scripts/fix_dylibs.sh +++ b/scripts/fix_dylibs.sh @@ -17,3 +17,4 @@ for lib in $deps; do install_name_tool -change $dependency @rpath/`basename $dependency` "$dylib" done done + From 2fd1e51361e19165a349ceaea737776cb6a04cc5 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 25 Oct 2018 12:51:47 -0400 Subject: [PATCH 14/15] fixed missing url --- frameworks/speculid/Controllers/CommandLineInstaller.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/speculid/Controllers/CommandLineInstaller.swift b/frameworks/speculid/Controllers/CommandLineInstaller.swift index f9189039..5fa681fb 100644 --- a/frameworks/speculid/Controllers/CommandLineInstaller.swift +++ b/frameworks/speculid/Controllers/CommandLineInstaller.swift @@ -35,7 +35,7 @@ public struct CommandLineInstaller { switch result { case let .success(installer): - installer.installCommandLineTool(fromBundleURL: Bundle.main, { (error) in + installer.installCommandLineTool(fromBundleURL: Bundle.main.bundleURL, { error in debugPrint(error) completed(error) }) From 1e7a40c40766b595bc75add6008350dca9a1f3a3 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 25 Oct 2018 16:41:11 -0400 Subject: [PATCH 15/15] fixing bundle export --- Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist | 2 +- Speculid.xcodeproj/project.pbxproj | 2 ++ applications/mac/Info.plist | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist b/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist index b2eb3476..97e349c5 100644 --- a/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist +++ b/Speculid-Mac-Installer/Speculid-Mac-Installer-Info.plist @@ -14,7 +14,7 @@ 1 SMAuthorizedClients - identifier "com.brightdigit.Speculid-Mac-App" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ + anchor apple generic and identifier "com.brightdigit.Speculid-Mac-App" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = MLT7M394S7) diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index c91e093a..63adc71a 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -15034,6 +15034,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; SWIFT_VERSION = 4.2; }; name = Debug; @@ -15060,6 +15061,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Installer"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; SWIFT_VERSION = 4.2; }; name = Release; diff --git a/applications/mac/Info.plist b/applications/mac/Info.plist index 87570230..5b4fe661 100644 --- a/applications/mac/Info.plist +++ b/applications/mac/Info.plist @@ -33,7 +33,7 @@ SMPrivilegedExecutables com.brightdigit.Speculid-Mac-Installer - identifier "com.brightdigit.Speculid-Mac-Installer" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Leo Dion (5VZ4KT69B9)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ + anchor apple generic and identifier "com.brightdigit.Speculid-Mac-Installer" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = MLT7M394S7)