Simplified process startup on macOS and Linux
This commit is contained in:
parent
9e03c9680c
commit
b462f3fb6c
40 changed files with 1343 additions and 1157 deletions
22
Apple/Shared/Constants.swift
Normal file
22
Apple/Shared/Constants.swift
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
@_implementationOnly import Constants
|
||||
|
||||
public enum Constants {
|
||||
enum Error: Swift.Error {
|
||||
case invalidAppGroupIdentifier
|
||||
}
|
||||
|
||||
public static let bundleIdentifier = AppBundleIdentifier
|
||||
public static let appGroupIdentifier = AppGroupIdentifier
|
||||
|
||||
public static var groupContainerURL: URL {
|
||||
get throws { try _groupContainerURL.get() }
|
||||
}
|
||||
|
||||
private static let _groupContainerURL: Result<URL, Error> = {
|
||||
guard let groupContainerURL = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier) else {
|
||||
return .failure(.invalidAppGroupIdentifier)
|
||||
}
|
||||
return .success(groupContainerURL)
|
||||
}()
|
||||
}
|
||||
11
Apple/Shared/Constants/Constants.h
Normal file
11
Apple/Shared/Constants/Constants.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
#define MACRO_STRING_(m) #m
|
||||
#define MACRO_STRING(m) @MACRO_STRING_(m)
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
static NSString * const AppBundleIdentifier = MACRO_STRING(APP_BUNDLE_IDENTIFIER);
|
||||
static NSString * const AppGroupIdentifier = MACRO_STRING(APP_GROUP_IDENTIFIER);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
4
Apple/Shared/Constants/module.modulemap
Normal file
4
Apple/Shared/Constants/module.modulemap
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module Constants {
|
||||
header "Constants.h"
|
||||
export *
|
||||
}
|
||||
19
Apple/Shared/Logging.swift
Normal file
19
Apple/Shared/Logging.swift
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import os
|
||||
@_exported import OSLog
|
||||
|
||||
extension Logger {
|
||||
private static let loggers: OSAllocatedUnfairLock<[String: Logger]> = OSAllocatedUnfairLock(initialState: [:])
|
||||
|
||||
public static let subsystem = Constants.bundleIdentifier
|
||||
|
||||
public static func logger(for type: Any.Type) -> Logger {
|
||||
let category = String(describing: type)
|
||||
let logger = loggers.withLock { loggers in
|
||||
if let logger = loggers[category] { return logger }
|
||||
let logger = Logger(subsystem: subsystem, category: category)
|
||||
loggers[category] = logger
|
||||
return logger
|
||||
}
|
||||
return logger
|
||||
}
|
||||
}
|
||||
5
Apple/Shared/Shared.xcconfig
Normal file
5
Apple/Shared/Shared.xcconfig
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
PRODUCT_NAME = BurrowShared
|
||||
MERGEABLE_LIBRARY = YES
|
||||
|
||||
SWIFT_INCLUDE_PATHS = $(PROJECT_DIR)/Shared/Constants
|
||||
GCC_PREPROCESSOR_DEFINITIONS = APP_BUNDLE_IDENTIFIER=$(APP_BUNDLE_IDENTIFIER) APP_GROUP_IDENTIFIER=$(APP_GROUP_IDENTIFIER)
|
||||
Loading…
Add table
Add a link
Reference in a new issue