Fix enum to objc core data for app permission

This commit is contained in:
Joe Mattiello
2023-03-04 04:00:00 -05:00
parent 452cf89c95
commit 1f2693bea6
13 changed files with 90 additions and 17 deletions

View File

@@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 53; objectVersion = 55;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@@ -29,6 +29,8 @@
B34AFC1329B032DF000F318E /* WidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34AFC0B29B032DF000F318E /* WidgetView.swift */; }; B34AFC1329B032DF000F318E /* WidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34AFC0B29B032DF000F318E /* WidgetView.swift */; };
B34AFC1429B032DF000F318E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B34AFC0D29B032DF000F318E /* Assets.xcassets */; }; B34AFC1429B032DF000F318E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B34AFC0D29B032DF000F318E /* Assets.xcassets */; };
B34AFC1629B032DF000F318E /* SideWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34AFC1029B032DF000F318E /* SideWidget.swift */; }; B34AFC1629B032DF000F318E /* SideWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34AFC1029B032DF000F318E /* SideWidget.swift */; };
B34BA8E629B0FE8D0055A710 /* AppDelegate+BackgroundFetch.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34BA8E529B0FE8D0055A710 /* AppDelegate+BackgroundFetch.swift */; };
B34BA8EC29B332FF0055A710 /* SideStoreAppKit in Frameworks */ = {isa = PBXBuildFile; productRef = B34BA8EB29B332FF0055A710 /* SideStoreAppKit */; };
B3C40F5229B05B4200C93D50 /* SideWidget in Frameworks */ = {isa = PBXBuildFile; productRef = B3C40F5129B05B4200C93D50 /* SideWidget */; }; B3C40F5229B05B4200C93D50 /* SideWidget in Frameworks */ = {isa = PBXBuildFile; productRef = B3C40F5129B05B4200C93D50 /* SideWidget */; };
B3C40F5329B06A0000C93D50 /* PatchApp.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B34AFBD929B0324C000F318E /* PatchApp.storyboard */; }; B3C40F5329B06A0000C93D50 /* PatchApp.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B34AFBD929B0324C000F318E /* PatchApp.storyboard */; };
B3C40F5429B06A2B00C93D50 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B34AFBE629B0324C000F318E /* LaunchScreen.storyboard */; }; B3C40F5429B06A2B00C93D50 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B34AFBE629B0324C000F318E /* LaunchScreen.storyboard */; };
@@ -88,6 +90,7 @@
B34AFC1029B032DF000F318E /* SideWidget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideWidget.swift; sourceTree = "<group>"; }; B34AFC1029B032DF000F318E /* SideWidget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideWidget.swift; sourceTree = "<group>"; };
B34AFC1929B04EBB000F318E /* Dangerfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dangerfile.swift; sourceTree = "<group>"; }; B34AFC1929B04EBB000F318E /* Dangerfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dangerfile.swift; sourceTree = "<group>"; };
B34AFC1A29B04EBB000F318E /* Project.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Project.swift; sourceTree = "<group>"; }; B34AFC1A29B04EBB000F318E /* Project.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Project.swift; sourceTree = "<group>"; };
B34BA8E529B0FE8D0055A710 /* AppDelegate+BackgroundFetch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+BackgroundFetch.swift"; sourceTree = "<group>"; };
B39575F4284F29E20080B4FF /* Roxas.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Roxas.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B39575F4284F29E20080B4FF /* Roxas.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Roxas.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B3C39606284F4C8400DA9E2F /* CodeSigning.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = CodeSigning.xcconfig; sourceTree = "<group>"; }; B3C39606284F4C8400DA9E2F /* CodeSigning.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = CodeSigning.xcconfig; sourceTree = "<group>"; };
B3C39607284F4C8400DA9E2F /* Build.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Build.xcconfig; sourceTree = "<group>"; }; B3C39607284F4C8400DA9E2F /* Build.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Build.xcconfig; sourceTree = "<group>"; };
@@ -113,6 +116,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
B34BA8EC29B332FF0055A710 /* SideStoreAppKit in Frameworks */,
B3C40F5229B05B4200C93D50 /* SideWidget in Frameworks */, B3C40F5229B05B4200C93D50 /* SideWidget in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@@ -134,6 +138,7 @@
children = ( children = (
B34AFBD729B0324C000F318E /* Resources */, B34AFBD729B0324C000F318E /* Resources */,
B34AFBF529B0324C000F318E /* AppDelegate.swift */, B34AFBF529B0324C000F318E /* AppDelegate.swift */,
B34BA8E529B0FE8D0055A710 /* AppDelegate+BackgroundFetch.swift */,
B34AFBF629B0324C000F318E /* LaunchViewController.swift */, B34AFBF629B0324C000F318E /* LaunchViewController.swift */,
B34AFBF729B0324C000F318E /* SceneDelegate.swift */, B34AFBF729B0324C000F318E /* SceneDelegate.swift */,
); );
@@ -315,6 +320,7 @@
name = SideWidgetExtension; name = SideWidgetExtension;
packageProductDependencies = ( packageProductDependencies = (
B3C40F5129B05B4200C93D50 /* SideWidget */, B3C40F5129B05B4200C93D50 /* SideWidget */,
B34BA8EB29B332FF0055A710 /* SideStoreAppKit */,
); );
productName = AltWidgetExtension; productName = AltWidgetExtension;
productReference = BF989167250AABF3002ACF50 /* SideWidgetExtension.appex */; productReference = BF989167250AABF3002ACF50 /* SideWidgetExtension.appex */;
@@ -371,7 +377,7 @@
}; };
}; };
buildConfigurationList = BFD247652284B9A500981D42 /* Build configuration list for PBXProject "SideStore" */; buildConfigurationList = BFD247652284B9A500981D42 /* Build configuration list for PBXProject "SideStore" */;
compatibilityVersion = "Xcode 9.3"; compatibilityVersion = "Xcode 13.0";
developmentRegion = en; developmentRegion = en;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
@@ -445,6 +451,7 @@
B34AFBFA29B03251000F318E /* AppDelegate.swift in Sources */, B34AFBFA29B03251000F318E /* AppDelegate.swift in Sources */,
B34AFBF829B03251000F318E /* LaunchViewController.swift in Sources */, B34AFBF829B03251000F318E /* LaunchViewController.swift in Sources */,
B34AFBF929B03251000F318E /* SceneDelegate.swift in Sources */, B34AFBF929B03251000F318E /* SceneDelegate.swift in Sources */,
B34BA8E629B0FE8D0055A710 /* AppDelegate+BackgroundFetch.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@@ -674,7 +681,7 @@
CODE_SIGN_ENTITLEMENTS = SideStoreApp/Sources/SideStore/Resources/SideStore.entitlements; CODE_SIGN_ENTITLEMENTS = SideStoreApp/Sources/SideStore/Resources/SideStore.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; DEVELOPMENT_TEAM = S32Z3HMYVQ;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = SideStoreApp/Sources/SideStore/Resources/Info.plist; INFOPLIST_FILE = SideStoreApp/Sources/SideStore/Resources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0; IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -702,7 +709,7 @@
CODE_SIGN_ENTITLEMENTS = SideStoreApp/Sources/SideStore/Resources/SideStore.entitlements; CODE_SIGN_ENTITLEMENTS = SideStoreApp/Sources/SideStore/Resources/SideStore.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; DEVELOPMENT_TEAM = S32Z3HMYVQ;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = SideStoreApp/Sources/SideStore/Resources/Info.plist; INFOPLIST_FILE = SideStoreApp/Sources/SideStore/Resources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0; IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -757,6 +764,10 @@
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
productName = SideStoreAppKit; productName = SideStoreAppKit;
}; };
B34BA8EB29B332FF0055A710 /* SideStoreAppKit */ = {
isa = XCSwiftPackageProductDependency;
productName = SideStoreAppKit;
};
B3C40F5129B05B4200C93D50 /* SideWidget */ = { B3C40F5129B05B4200C93D50 /* SideWidget */ = {
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
productName = SideWidget; productName = SideWidget;

View File

@@ -291,6 +291,7 @@ let package = Package(
.target( .target(
name: "SideWidget", name: "SideWidget",
dependencies: [ dependencies: [
"SideStoreAppKit",
"Shared", "Shared",
"SideStoreCore", "SideStoreCore",
"AltSign", "AltSign",

View File

@@ -0,0 +1,9 @@
//
// AppDelegate+BackgroundFetch.swift
// SideStore
//
// Created by Joseph Mattiello on 3/2/23.
// Copyright © 2023 SideStore. All rights reserved.
//
import Foundation

View File

@@ -10,13 +10,13 @@ import AVFoundation
import Intents import Intents
import UIKit import UIKit
import UserNotifications import UserNotifications
import os.log
import AltSign import AltSign
import SideStoreCore import SideStoreCore
import SideStoreAppKit import SideStoreAppKit
import EmotionalDamage import EmotionalDamage
import RoxasUIKit import RoxasUIKit
import os.log
@UIApplicationMain @UIApplicationMain
final class AppDelegate: SideStoreAppDelegate { final class AppDelegate: SideStoreAppDelegate {
@@ -53,6 +53,8 @@ final class AppDelegate: SideStoreAppDelegate {
os_log("Failed to start DatabaseManager. Error: %@", type: .error , error.localizedDescription) os_log("Failed to start DatabaseManager. Error: %@", type: .error , error.localizedDescription)
} else { } else {
os_log("Started DatabaseManager.", type: .info) os_log("Started DatabaseManager.", type: .info)
let transformer = ALTAppPermissionTypeTransformer()
ValueTransformer.setValueTransformer(transformer, forName: NSValueTransformerName(rawValue: "ALTAppPermissionTypeTransformer"))
} }
} }

View File

@@ -4,6 +4,8 @@
<dict> <dict>
<key>aps-environment</key> <key>aps-environment</key>
<string>development</string> <string>development</string>
<key>com.apple.developer.kernel.increased-memory-limit</key>
<true/>
<key>com.apple.developer.siri</key> <key>com.apple.developer.siri</key>
<true/> <true/>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>

View File

@@ -3,16 +3,18 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>application-identifier</key> <key>application-identifier</key>
<string>A72ZC8AJ5X.com.SideStore.SideStore</string> <string>S32Z3HMYVQ.com.SideStore.SideStore</string>
<key>aps-environment</key> <key>aps-environment</key>
<string>development</string> <string>development</string>
<key>com.apple.developer.siri</key> <key>com.apple.developer.siri</key>
<true/> <true/>
<key>com.apple.developer.kernel.increased-memory-limit</key>
<true/>
<key>com.apple.developer.team-identifier</key> <key>com.apple.developer.team-identifier</key>
<string>A72ZC8AJ5X</string> <string>A72ZC8AJ5X</string>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>
<array> <array>
<string>group.com.SideStore.SideStore</string> <string>group.$(APP_GROUP_IDENTIFIER)</string>
</array> </array>
<key>get-task-allow</key> <key>get-task-allow</key>
<true/> <true/>

View File

@@ -10,7 +10,9 @@ import UIKit
import RoxasUIKit import RoxasUIKit
@objc
final class NavigationBar: UINavigationBar { final class NavigationBar: UINavigationBar {
@objc
@IBInspectable var automaticallyAdjustsItemPositions: Bool = true @IBInspectable var automaticallyAdjustsItemPositions: Bool = true
private let backgroundColorView = UIView() private let backgroundColorView = UIView()

View File

@@ -68,9 +68,30 @@ public extension ALTAppPermissionType {
} }
@objc(AppPermission) @objc(AppPermission)
public class AppPermission: NSManagedObject, Decodable, Fetchable { public class AppPermission: NSManagedObject, Decodable, Fetchable, NSKeyValueObservingCustomization {
public static func keyPathsAffectingValue(for key: AnyKeyPath) -> Set<AnyKeyPath> {
print("keyPathsAffectingValue: \(String(describing: key))")
return Set<AnyKeyPath>([key])
}
public static func automaticallyNotifiesObservers(for key: AnyKeyPath) -> Bool {
print("automaticallyNotifiesObservers: \(String(describing: key))")
return true
}
/* Properties */ /* Properties */
@NSManaged public var type: ALTAppPermissionType @objc(type)
@NSManaged public var _type: String
@nonobjc
public var type: ALTAppPermissionType {
get {
ALTAppPermissionType(rawValue: _type)
}
set {
_type = newValue.stringValue
}
}
@NSManaged public var usageDescription: String @NSManaged public var usageDescription: String
/* Relationships */ /* Relationships */
@@ -95,11 +116,13 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable {
usageDescription = try container.decode(String.self, forKey: .usageDescription) usageDescription = try container.decode(String.self, forKey: .usageDescription)
let rawType = try container.decode(String.self, forKey: .type) let rawType = try container.decode(String.self, forKey: .type)
guard let type = ALTAppPermissionType(rawValue: rawType) else { // guard
throw DecodingError.dataCorrupted( let type = ALTAppPermissionType(rawValue: rawType)
DecodingError.Context(codingPath: [CodingKeys.type], // else {
debugDescription: "Invalid value for `ALTAppPermissionType` \"\(rawType)\"")) // throw DecodingError.dataCorrupted(
} // DecodingError.Context(codingPath: [CodingKeys.type],
// debugDescription: "Invalid value for `ALTAppPermissionType` \"\(rawType)\""))
// }
self.type = type self.type = type
} catch { } catch {
if let context = managedObjectContext { if let context = managedObjectContext {

View File

@@ -27,8 +27,9 @@ public enum ALTAppPermissionType: Int, CaseIterable {
case faceID case faceID
case siri case siri
case motion case motion
case null
public init?(rawValue: String) { public init(rawValue: String) {
switch rawValue { switch rawValue {
case "photos": self = .photos case "photos": self = .photos
case "camera": self = .camera case "camera": self = .camera
@@ -47,7 +48,7 @@ public enum ALTAppPermissionType: Int, CaseIterable {
case "faceID", "faceid": self = .faceID case "faceID", "faceid": self = .faceID
case "siri": self = .siri case "siri": self = .siri
case "motion": self = .motion case "motion": self = .motion
default: return nil default: self = .null
} }
} }
@@ -87,6 +88,21 @@ public enum ALTAppPermissionType: Int, CaseIterable {
return "siri" return "siri"
case .motion: case .motion:
return "motion" return "motion"
} case .null:
return ""
}
} }
} }
@objc
public final class ALTAppPermissionTypeTransformer: ValueTransformer {
public override func transformedValue(_ value: Any?) -> Any? {
guard let enumValue = value as? ALTAppPermissionType else { return "" }
return enumValue.rawValue
}
public override func reverseTransformedValue(_ value: Any?) -> Any? {
guard let rawValue = value as? String else { return ALTAppPermissionType.null }
return ALTAppPermissionType(rawValue: rawValue)
}
}

View File

@@ -23,6 +23,11 @@
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string> <string>$(MARKETING_VERSION)</string>
<key>INIntentsSupported</key>
<array>
<string>RefreshAllIntent</string>
<string>ViewAppIntent</string>
</array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>NSExtension</key> <key>NSExtension</key>