Skip to content
Draft
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
25 changes: 18 additions & 7 deletions SwiftPMTests/swift-test/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,31 @@ class importTest: XCTestCase {
XCTAssertFalse(GULAppEnvironmentUtil.isFromAppStore())
#if targetEnvironment(simulator)
XCTAssertTrue(GULAppEnvironmentUtil.isSimulator())
// Device model should return the host's build architecture (x86_64 or arm64) for iOS, tvOS
// watchOS, and visionOS simulators.
XCTAssertEqual(GULAppEnvironmentUtil.deviceModel(), buildArchitecture())
#else
XCTAssertFalse(GULAppEnvironmentUtil.isSimulator())
// Device model should return the appropriate hardware model (e.g., "iPhone12,3" or
// "MacBookPro18,2") on real devices.
XCTAssertNotEqual(GULAppEnvironmentUtil.deviceModel(), buildArchitecture())
#endif
XCTAssertFalse(GULAppEnvironmentUtil.isAppExtension())

#if os(macOS) || targetEnvironment(macCatalyst)
// Device model should now return the appropriate hardware model on macOS.
XCTAssertNotEqual(GULAppEnvironmentUtil.deviceModel(), "x86_64")
print("System version? Answer: \(GULAppEnvironmentUtil.systemVersion())")
}

func buildArchitecture() -> String {
#if arch(arm64)
return "arm64"
#elseif arch(x86_64)
return "x86_64"
#else
// Device model should show up as x86_64 for iOS, tvOS, and watchOS
// simulators.
XCTAssertEqual(GULAppEnvironmentUtil.deviceModel(), "x86_64")
throw TestError(errorDescription: "Unexpected build architecture.")
#endif
}

print("System version? Answer: \(GULAppEnvironmentUtil.systemVersion())")
struct TestError: Error {
var errorDescription: String?
}
}