mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-26 09:05:46 +00:00
Enable Xcodes.app to be used as a Standard (ie non Admin) user in managed environments. Install, rename/symbolic link to Xcode.app during activate/switch, uninstall are performed using the helper. An options in the Advanced Preferences pane added to enable/disable this feature.
65 lines
2.5 KiB
Swift
65 lines
2.5 KiB
Swift
import Foundation
|
|
|
|
let machServiceName = "com.xcodesorg.xcodesapp.Helper"
|
|
let clientBundleID = "com.xcodesorg.xcodesapp"
|
|
let subjectOrganizationalUnit = Bundle.main.infoDictionary!["CODE_SIGNING_SUBJECT_ORGANIZATIONAL_UNIT"] as! String
|
|
|
|
@objc(HelperXPCProtocol)
|
|
protocol HelperXPCProtocol {
|
|
func getVersion(completion: @escaping (String) -> Void)
|
|
func xcodeSelect(absolutePath: String, completion: @escaping (Error?) -> Void)
|
|
func devToolsSecurityEnable(completion: @escaping (Error?) -> Void)
|
|
func addStaffToDevelopersGroup(completion: @escaping (Error?) -> Void)
|
|
func acceptXcodeLicense(absoluteXcodePath: String, completion: @escaping (Error?) -> Void)
|
|
func runFirstLaunch(absoluteXcodePath: String, completion: @escaping (Error?) -> Void)
|
|
func moveApp(at source: String, to destination: String, completion: @escaping (Error?) -> Void)
|
|
func createSymbolicLink(source: String, destination: String, completion: @escaping (Error?) -> Void)
|
|
func rename(source: String, destination: String, completion: @escaping (Error?) -> Void)
|
|
func remove(path: String, completion: @escaping (Error?) -> Void)
|
|
}
|
|
|
|
struct XPCDelegateError: CustomNSError {
|
|
enum Code: Int {
|
|
case invalidXcodePath
|
|
case invalidSourcePath
|
|
case invalidDestinationPath
|
|
case destinationIsNotASymbolicLink
|
|
}
|
|
|
|
let code: Code
|
|
|
|
init(_ code: Code) {
|
|
self.code = code
|
|
}
|
|
|
|
// MARK: - CustomNSError
|
|
|
|
static var errorDomain: String { "XPCDelegateError" }
|
|
|
|
var errorCode: Int { code.rawValue }
|
|
|
|
var errorUserInfo: [String : Any] {
|
|
switch code {
|
|
case .invalidXcodePath:
|
|
return [
|
|
NSLocalizedDescriptionKey: "Invalid Xcode path.",
|
|
NSLocalizedFailureReasonErrorKey: "Xcode path must be absolute."
|
|
]
|
|
case .invalidSourcePath:
|
|
return [
|
|
NSLocalizedDescriptionKey: "Invalid source path.",
|
|
NSLocalizedFailureReasonErrorKey: "Source path must be absolute and must be a directory."
|
|
]
|
|
case .invalidDestinationPath:
|
|
return [
|
|
NSLocalizedDescriptionKey: "Invalid destination path.",
|
|
NSLocalizedFailureReasonErrorKey: "Destination path must be absolute and must be a directory."
|
|
]
|
|
case .destinationIsNotASymbolicLink:
|
|
return [
|
|
NSLocalizedDescriptionKey: "Invalid destination path.",
|
|
NSLocalizedFailureReasonErrorKey: "Destination path must be a symbolic link."
|
|
]
|
|
}
|
|
}
|
|
}
|