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

fix: update device model reporting for iPhone, iPad, Apple Watch and Apple TV devices #186

Merged
merged 2 commits into from
Feb 14, 2024
Merged
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
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
Loading