Skip to content

Commit

Permalink
fix: update device model reporting for iPhone, iPad, Apple Watch and …
Browse files Browse the repository at this point in the history
…Apple TV devices (#186)

* [fix]: update device model reporting for iPhone, iPad, Apple Watch and Apple TV devices

* [chore]: bump ssh-agent gh action to v0.9.0
  • Loading branch information
kaushalkapasi authored Feb 14, 2024
1 parent 6bfbac5 commit e4ffeca
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ name: Build and Test macOS

on:
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:
runs-on: macos-12
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: "Select Latest Xcode"
- name: 'Select Latest Xcode'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: "Set SSH key"
uses: webfactory/ssh-agent@v0.8.0
- name: 'Set SSH key'
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: "Carthage Cached Bootstrap"
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: 'Carthage Cached Bootstrap'
uses: DevCycleHQ/carthage-bootstrap@xcframeworks2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -32,4 +32,4 @@ jobs:
TEMP_KEYCHAIN_USER: '${{ secrets.TEMP_KEYCHAIN_USER }}'
APPLE_KEY_ID: '${{ secrets.APPLE_KEY_ID }}'
APPLE_ISSUER_ID: '${{ secrets.APPLE_ISSUER_ID }}'
APPLE_KEY_CONTENT: '${{ secrets.APPLE_KEY_CONTENT }}'
APPLE_KEY_CONTENT: '${{ secrets.APPLE_KEY_CONTENT }}'
15 changes: 13 additions & 2 deletions DevCycle/Models/PlatformDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import IOKit

struct PlatformDetails {
#if os(iOS) || os(tvOS)
var deviceModel: String { UIDevice.current.model }
var deviceModel = getDeviceModel()
var systemVersion: String { UIDevice.current.systemVersion }
var systemName: String { UIDevice.current.systemName }
#elseif os(watchOS)
var deviceModel: String { WKInterfaceDevice.current().model }
var deviceModel = getDeviceModel()
var systemVersion: String { WKInterfaceDevice.current().systemVersion }
var systemName: String { WKInterfaceDevice.current().systemName }
#elseif os(macOS)
Expand Down Expand Up @@ -56,3 +56,14 @@ func getMacOSModelIdentifier() -> String {
}
}
#endif

#if os(iOS) || os(tvOS) || os(watchOS)
func getDeviceModel() -> String {
if let simulatorModelIdentifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] {
return "Simulator " + simulatorModelIdentifier
}
var sysinfo = utsname()
uname(&sysinfo) // ignore return value
return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
}
#endif
4 changes: 2 additions & 2 deletions DevCycleTests/Models/DevCycleUserTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class DevCycleUserTest: XCTestCase {
#if os(tvOS)
XCTAssert(user.platform == "tvOS")
XCTAssertNotNil(user.platformVersion)
XCTAssert(user.deviceModel.contains("Apple TV"))
XCTAssert(user.deviceModel.contains("AppleTV"))
#elseif os(iOS)
XCTAssert(user.platform == "iOS" || user.platform == "iPadOS")
XCTAssertNotNil(user.platformVersion)
XCTAssert(user.deviceModel.contains("iPhone"))
XCTAssert(user.deviceModel.contains("iPhone") || user.deviceModel.contains("iPad"))
#elseif os(watchOS)
XCTAssert(user.platform == "watchOS")
XCTAssertNotNil(user.platformVersion)
Expand Down
13 changes: 13 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ run tvOS DevCycle tests
----


## watchos

### watchos tests

```sh
[bundle exec] fastlane watchos tests
```

run watchOS DevCycle tests

----


## Mac

### mac tests
Expand Down

0 comments on commit e4ffeca

Please sign in to comment.