Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutli-platform support #830

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions AltStore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3022,11 +3022,11 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 6XVY5G3U44;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -3040,6 +3040,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltStoreCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -3056,10 +3058,10 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 6XVY5G3U44;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -3073,6 +3075,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltStoreCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
3 changes: 3 additions & 0 deletions AltStore.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 88 additions & 1 deletion AltStoreCore/Model/StoreApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,74 @@ public extension StoreApp
static let dolphinAppID = "me.oatmealdome.dolphinios-njb"
}

@objc
public enum Platform: UInt {
case ios
case tvos
case macos
}

extension Platform: Decodable {}

@objc
public final class PlatformURL: NSManagedObject, Decodable {
/* Properties */
@NSManaged public private(set) var platform: Platform
@NSManaged public private(set) var downloadURL: URL


private enum CodingKeys: String, CodingKey
{
case platform
case downloadURL
}


public init(from decoder: Decoder) throws
{
guard let context = decoder.managedObjectContext else { preconditionFailure("Decoder must have non-nil NSManagedObjectContext.") }

// Must initialize with context in order for child context saves to work correctly.
super.init(entity: PlatformURL.entity(), insertInto: context)

do
{
let container = try decoder.container(keyedBy: CodingKeys.self)
self.platform = try container.decode(Platform.self, forKey: .platform)
self.downloadURL = try container.decode(URL.self, forKey: .downloadURL)
}
catch
{
if let context = self.managedObjectContext
{
context.delete(self)
}

throw error
}
}
}

extension PlatformURL: Comparable {
public static func < (lhs: PlatformURL, rhs: PlatformURL) -> Bool {
return lhs.platform.rawValue < rhs.platform.rawValue
}

public static func > (lhs: PlatformURL, rhs: PlatformURL) -> Bool {
return lhs.platform.rawValue > rhs.platform.rawValue
}

public static func <= (lhs: PlatformURL, rhs: PlatformURL) -> Bool {
return lhs.platform.rawValue <= rhs.platform.rawValue
}

public static func >= (lhs: PlatformURL, rhs: PlatformURL) -> Bool {
return lhs.platform.rawValue >= rhs.platform.rawValue
}
}

public typealias PlatformURLs = [PlatformURL]

@objc(StoreApp)
public class StoreApp: NSManagedObject, Decodable, Fetchable
{
Expand All @@ -45,6 +113,8 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
@NSManaged public private(set) var versionDescription: String?

@NSManaged public private(set) var downloadURL: URL
@NSManaged public private(set) var platformURLs: PlatformURLs?

@NSManaged public private(set) var tintColor: UIColor?
@NSManaged public private(set) var isBeta: Bool

Expand Down Expand Up @@ -90,6 +160,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
case iconURL
case screenshotURLs
case downloadURL
case platformURLs
case tintColor
case subtitle
case permissions
Expand Down Expand Up @@ -121,7 +192,23 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
self.iconURL = try container.decode(URL.self, forKey: .iconURL)
self.screenshotURLs = try container.decodeIfPresent([URL].self, forKey: .screenshotURLs) ?? []

self.downloadURL = try container.decode(URL.self, forKey: .downloadURL)
let downloadURL = try container.decodeIfPresent(URL.self, forKey: .downloadURL)
let platformURLs = try container.decodeIfPresent(PlatformURLs.self.self, forKey: .platformURLs)
if let platformURLs = platformURLs {
self.platformURLs = platformURLs
// Backwards compatibility, use the fiirst (iOS will be first since sorted that way)
if let first = platformURLs.sorted().first {
self.downloadURL = first.downloadURL
} else {
throw DecodingError.dataCorruptedError(forKey: .platformURLs, in: container, debugDescription: "platformURLs has no entries")

}

} else if let downloadURL = downloadURL {
self.downloadURL = downloadURL
} else {
throw DecodingError.dataCorruptedError(forKey: .downloadURL, in: container, debugDescription: "E downloadURL:String or downloadURLs:[[Platform:URL]] key required.")
}

if let tintColorHex = try container.decodeIfPresent(String.self, forKey: .tintColor)
{
Expand Down
9 changes: 8 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
inhibit_all_warnings!

def common_pods
pod 'Roxas', :git => 'https://github.com/rileytestut/Roxas.git'
end

target 'AltStore' do
platform :ios, '12.0'

use_frameworks!

common_pods

# Pods for AltStore
pod 'Nuke', '~> 7.0'
pod 'AppCenter', '~> 4.2.0'
Expand All @@ -26,7 +32,8 @@ target 'AltStoreCore' do
platform :ios, '12.0'

use_frameworks!

common_pods

# Pods for AltServer
pod 'KeychainAccess', '~> 4.2.0'

Expand Down
12 changes: 10 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ PODS:
- AppCenter/Core
- KeychainAccess (4.2.1)
- Nuke (7.6.3)
- Roxas (0.1)
- Sparkle (1.24.0)
- STPrivilegedTask (1.0.7)

DEPENDENCIES:
- AppCenter (~> 4.2.0)
- KeychainAccess (~> 4.2.0)
- Nuke (~> 7.0)
- Roxas (from `https://github.com/rileytestut/Roxas.git`)
- Sparkle
- STPrivilegedTask (from `https://github.com/rileytestut/STPrivilegedTask.git`)

Expand All @@ -27,10 +29,15 @@ SPEC REPOS:
- Sparkle

EXTERNAL SOURCES:
Roxas:
:git: https://github.com/rileytestut/Roxas.git
STPrivilegedTask:
:git: https://github.com/rileytestut/STPrivilegedTask.git

CHECKOUT OPTIONS:
Roxas:
:commit: 2bb3182495f680ce60da8e72c3d84a7d4451ef75
:git: https://github.com/rileytestut/Roxas.git
STPrivilegedTask:
:commit: 6ca513d0dcb2aefb0e5a95915b77bbbbd8a6d942
:git: https://github.com/rileytestut/STPrivilegedTask.git
Expand All @@ -39,9 +46,10 @@ SPEC CHECKSUMS:
AppCenter: 87ef6eefd8ade4df59e88951288587429f3dd2a5
KeychainAccess: 9b07f665298d13c3a85881bd3171f6f49b8151c1
Nuke: 44130e95e09463f8773ae4b96b90de1eba6b3350
Roxas: 1990039f843f5dc284918dc82375feb80020ef62
Sparkle: 270cd27377bf04e9c128af06e3a22d0f572d6ee3
STPrivilegedTask: 56c3397238a1ec07720fb877a044898373cd2c68

PODFILE CHECKSUM: ab4f64a189ce4136fef92ee4057edd44e3266b69
PODFILE CHECKSUM: 1ddfe1781438ac09f5d1efb2a16833512faab687

COCOAPODS: 1.10.1
COCOAPODS: 1.11.2
12 changes: 10 additions & 2 deletions Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading