Skip to content

Commit

Permalink
Add AIP and hardware year to main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bstillitano committed Apr 7, 2024
1 parent a894402 commit 7ff7c1e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
43 changes: 39 additions & 4 deletions Sources/Scyther/Extensions/Bundle+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,48 @@ extension Bundle {
}
return infoAttributes[.modificationDate] as? Date ?? Date()
}


/// Returns the "App Identifier Prefix" for the application. This is also commonly referred to as the "Seed ID" or the "Team ID".
/// https://stackoverflow.com/questions/11726672/access-app-identifier-prefix-programmatically
public var seedId: String? {
let queryLoad: [String: AnyObject] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: "bundleSeedID" as AnyObject,
kSecAttrService as String: "" as AnyObject,
kSecReturnAttributes as String: kCFBooleanTrue
]

var result: AnyObject?
var status = withUnsafeMutablePointer(to: &result) {
SecItemCopyMatching(queryLoad as CFDictionary, UnsafeMutablePointer($0))
}

if status == errSecItemNotFound {
status = withUnsafeMutablePointer(to: &result) {
SecItemAdd(queryLoad as CFDictionary, UnsafeMutablePointer($0))
}
}

if status == noErr {
if let resultDict = result as? [String: Any], let accessGroup = resultDict[kSecAttrAccessGroup as String] as? String {
let components = accessGroup.components(separatedBy: ".")
return components.first
} else {
return nil
}
} else {
print("Error getting bundleSeedID to Keychain")
return nil
}
}
}

/// Cocoapods Specific Extensions
#if !SWIFT_PACKAGE
extension Bundle {
static var module: Bundle {
Bundle(identifier: "org.cocoapods.Scyther")!
extension Bundle {
static var module: Bundle {
Bundle(identifier: "org.cocoapods.Scyther")!
}
}
}
#endif
12 changes: 6 additions & 6 deletions Sources/Scyther/Extensions/UIDevice+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public extension UIDevice {
/// Get System Info
var systemInfo = utsname()
uname(&systemInfo)

/// Determine Device Identifier
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
Expand All @@ -23,20 +23,20 @@ public extension UIDevice {
}
return identifier + String(UnicodeScalar(UInt8(value)))
}

return identifier
}

/// Determines the type of device that this code is running on. Returns one of the following: `phone` or `tablet`
var deviceType: String {
//Check Type
if UIDevice.current.userInterfaceIdiom == .pad {
return "tablet"
}

return "phone"
}

/// Determines the generation of the running device.
var generation: Float {
/// Setup Data
Expand All @@ -45,7 +45,7 @@ public extension UIDevice {
value = value.replacingOccurences(of: ["iphone", "ipad", "ipod", "watch"], with: "")
value = value.replacingOccurences(of: ["x86_64", "i386"], with: "99.9")
value = value.replacingOccurrences(of: ",", with: ".")

/// Add 2007 to the value as that was the year of release for the first generation of iOS
return (Float(value) ?? 0) + 2007
}
Expand Down
12 changes: 11 additions & 1 deletion Sources/Scyther/User Interface/Menu/MenuViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,26 @@ internal class MenuViewModel {
deviceSection.rows.append(valueRow(name: "Hardware",
value: UIDevice.current.modelName,
icon: nil))
deviceSection.rows.append(valueRow(name: "Release Year",
value: String(UIDevice.current.generation),
icon: nil,
showMenu: true))
deviceSection.rows.append(valueRow(name: "UDID",
value: UIDevice.current.identifierForVendor?.uuidString,
icon: nil,
showMenu: true))

// Setup Application Section
var applicationSection: Section = Section()
applicationSection.title = "Application"
applicationSection.rows.append(valueRow(name: "Bundle Identifier",
applicationSection.rows.append(valueRow(name: "Bundle ID",
value: Bundle.main.bundleIdentifier,
icon: nil))
if let value = Bundle.main.seedId {
applicationSection.rows.append(valueRow(name: "App ID Prefix",
value: Bundle.main.bundleIdentifier,
icon: nil))
}
applicationSection.rows.append(valueRow(name: "Version",
value: Bundle.main.versionNumber,
icon: nil))
Expand Down

0 comments on commit 7ff7c1e

Please sign in to comment.