Skip to content

Commit

Permalink
Merge 9ac8a3f into 2a86ded
Browse files Browse the repository at this point in the history
  • Loading branch information
evandcoleman authored Jan 25, 2022
2 parents 2a86ded + 9ac8a3f commit b3a8694
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sources/ScipioKit/Helpers/Xcodebuild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public extension Xcodebuild {
case createXCFramework
}

enum SDK: String {
enum SDK: String, CaseIterable {
case iphoneos
case iphonesimulator
case macos
Expand Down
18 changes: 10 additions & 8 deletions Sources/ScipioKit/Models/Architecture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import Foundation

public enum Architecture: String, CaseIterable, CustomStringConvertible {
case armv7
case i386
case x86_64
case arm64

public var description: String { rawValue }

public var sdk: Xcodebuild.SDK {
public var possibleSDKs: [Xcodebuild.SDK] {
switch self {
case .armv7, .arm64:
return .iphoneos
case .x86_64, .i386:
return .iphonesimulator
case .armv7:
return [.iphoneos]
case .x86_64:
return [.iphonesimulator]
case .arm64:
return [.iphoneos, .iphonesimulator]
}
}
}
Expand All @@ -24,13 +25,14 @@ public extension Xcodebuild.SDK {
case .iphoneos:
return [.armv7, .arm64]
case .iphonesimulator, .macos:
return [.x86_64, .i386]
return [.x86_64, .arm64]
}
}
}

extension Collection where Iterator.Element == Architecture {
public var sdkArchitectures: [Xcodebuild.SDK: [Architecture]] {
return reduce(into: [:]) { $0[$1.sdk, default: []].append($1) }
return Set(flatMap(\.possibleSDKs))
.reduce(into: [:]) { $0[$1] = $1.architectures }
}
}
6 changes: 3 additions & 3 deletions Tests/ScipioTests/ArchitectureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import XCTest

final class ArchitectureTests: XCTestCase {
func sdkArchitectures() throws {
func testSdkArchitectures() throws {
let architectures = Architecture.allCases

XCTAssertEqual(architectures.sdkArchitectures, [
.iphoneos: [.arm64, .armv7],
.iphonesimulator: [.i386, .x86_64],
.iphonesimulator: [.x86_64, .arm64],
.iphoneos: [.armv7, .arm64],
])
}
}

0 comments on commit b3a8694

Please sign in to comment.