Switch to gRPC client in Swift app
This commit is contained in:
parent
25a0f7c421
commit
083ec73613
93 changed files with 1666 additions and 1327 deletions
12
Apple/Configuration/Constants/Constants.h
Normal file
12
Apple/Configuration/Constants/Constants.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#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);
|
||||
static NSString * const NetworkExtensionBundleIdentifier = MACRO_STRING(NETWORK_EXTENSION_BUNDLE_IDENTIFIER);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
38
Apple/Configuration/Constants/Constants.swift
Normal file
38
Apple/Configuration/Constants/Constants.swift
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
@_implementationOnly import CConstants
|
||||
import OSLog
|
||||
|
||||
public enum Constants {
|
||||
enum Error: Swift.Error {
|
||||
case invalidAppGroupIdentifier
|
||||
}
|
||||
|
||||
public static let bundleIdentifier = AppBundleIdentifier
|
||||
public static let appGroupIdentifier = AppGroupIdentifier
|
||||
public static let networkExtensionBundleIdentifier = NetworkExtensionBundleIdentifier
|
||||
|
||||
public static var socketURL: URL {
|
||||
get throws {
|
||||
try groupContainerURL.appending(component: "burrow.sock", directoryHint: .notDirectory)
|
||||
}
|
||||
}
|
||||
public static var databaseURL: URL {
|
||||
get throws {
|
||||
try groupContainerURL.appending(component: "burrow.db", directoryHint: .notDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
private static var groupContainerURL: URL {
|
||||
get throws { try _groupContainerURL.get() }
|
||||
}
|
||||
private static let _groupContainerURL: Result<URL, Error> = {
|
||||
switch FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier) {
|
||||
case .some(let url): .success(url)
|
||||
case .none: .failure(.invalidAppGroupIdentifier)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
extension Logger {
|
||||
@_dynamicReplacement(for: subsystem)
|
||||
public static var subsystem: String { Constants.bundleIdentifier }
|
||||
}
|
||||
4
Apple/Configuration/Constants/module.modulemap
Normal file
4
Apple/Configuration/Constants/module.modulemap
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module CConstants {
|
||||
header "Constants.h"
|
||||
export *
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue