Skip to content

Commit

Permalink
feat: watchOS/tvOS/visionOS/SwiftUI support (#300)
Browse files Browse the repository at this point in the history
* chore: add watchOS demo for test

* feat: watchOS/tvOS/visionOS support

* style: code format

* fix: add default value to device info in order to prevent new platform in future

* style: code format

* fix: some UIKit-based class and categories are only used on iOS platform

* style: code format

* chore: add visionOS demo for test

* style: code format

* chore: add tvOS demo for test

* fix: use nw_path_monitor_t to determine network status

* style: code format

* ci: update ci

* fix: target condition judge

* style: code format

* chore: remove using of RealityKitContent in visionOS demo

* ci: update ci

* chore: swift macro is not compatible in Xcode 14

* fix: device orientation logic

* chore: update spi.yml

* style: code format

* fix: update version of GrowingUtils and GrowingAPM

* fix: bugs

* chore: update podfile lock

* chore: code coverage ignore Package@swift-*.swift

* fix: adapt deep link to SwiftUI

* fix: null safety

* style: code format

* test: add SwiftUI Demo

* chore: update GrowingUtils to 1.2.3

* chore: update pod dep

* style: add comment about undetermined reachability

* fix: path 为空时,mobiledebugger 上无法显示该字段

* fix: path 为空时,mobiledebugger 上无法显示该字段 (仅无埋点事件)

* style: code format

* fix: ignore nw_path_status on watchOS

---------

Co-authored-by: GIOSDK <[email protected]>
  • Loading branch information
YoloMao and GIOSDK authored Mar 26, 2024
1 parent 59e5cdd commit 0ef1b26
Show file tree
Hide file tree
Showing 112 changed files with 3,155 additions and 636 deletions.
182 changes: 46 additions & 136 deletions .github/workflows/spm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,145 +11,55 @@ concurrency:
cancel-in-progress: true

jobs:
autotracker-build-iOS:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingAutotracker -destination 'platform=iOS Simulator,name=iPhone 14' \
| xcbeautify --renderer github-actions
autotracker-build-catalyst:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingAutotracker -destination 'platform=macOS,variant=Mac Catalyst' \
| xcbeautify --renderer github-actions
tracker-build-iOS:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingTracker -destination 'platform=iOS Simulator,name=iPhone 14' \
| xcbeautify --renderer github-actions
tracker-build-catalyst:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingTracker -destination 'platform=macOS,variant=Mac Catalyst' \
| xcbeautify --renderer github-actions
tracker-build-macos:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingTracker -destination 'platform=macOS' \
| xcbeautify --renderer github-actions
ads-build-iOS:
runs-on: macos-latest

spm-build:
strategy:
matrix:
target: [
iOS,
macOS,
macCatalyst,
tvOS,
watchOS
]
os: [macos-12, macos-13]
include:
- os: macos-12
xcode: Xcode_14.2
- os: macos-13
xcode: Xcode_15.2
- target: iOS
platform: iOS Simulator,name=iPhone 14 Pro Max
- target: macOS
platform: macOS
- target: macCatalyst
platform: macOS,variant=Mac Catalyst
- target: tvOS
platform: tvOS Simulator,name=Apple TV
- target: watchOS
platform: watchOS Simulator,name=Apple Watch Ultra (49mm)
- scheme: GrowingAnalytics-Package
target: iOS
- scheme: GrowingAutotracker
target: macCatalyst
- scheme: GrowingAutotracker
target: tvOS
- scheme: GrowingTracker
target: macOS
- scheme: GrowingTracker
target: watchOS
- target: visionOS
os: macos-14
xcode: Xcode_15.2
platform: visionOS Simulator,name=Apple Vision Pro
scheme: GrowingTracker
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingModule_Ads -destination 'platform=iOS Simulator,name=iPhone 14' \
| xcbeautify --renderer github-actions
apm-build-iOS:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingModule_APM -destination 'platform=iOS Simulator,name=iPhone 14' \
| xcbeautify --renderer github-actions
apm-build-catalyst:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingModule_APM -destination 'platform=macOS,variant=Mac Catalyst' \
| xcbeautify --renderer github-actions
hybrid-build-iOS:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingModule_Hybrid -destination 'platform=iOS Simulator,name=iPhone 14' \
| xcbeautify --renderer github-actions
hybrid-build-catalyst:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingModule_Hybrid -destination 'platform=macOS,variant=Mac Catalyst' \
| xcbeautify --renderer github-actions
imp-build-iOS:
runs-on: macos-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Xcode
run: sudo xcode-select -switch /Applications/${{ matrix.xcode }}.app
- name: Build
run: |
set -euo pipefail
xcodebuild build -scheme GrowingModule_ImpressionTrack -destination 'platform=iOS Simulator,name=iPhone 14' \
| xcbeautify --renderer github-actions
xcodebuild build -scheme ${{ matrix.scheme }} -destination 'platform=${{ matrix.platform }}' \
| xcbeautify --renderer github-actions
8 changes: 7 additions & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ version: 1
builder:
configs:
- platform: ios
scheme: GrowingAutotracker
scheme: GrowingAnalytics-Package
- platform: macos-xcodebuild
scheme: GrowingTracker
- platform: macos-spm
target: GrowingTracker
- platform: tvos
scheme: GrowingAutotracker
- platform: watchos
scheme: GrowingTracker
- platform: visionos
scheme: GrowingTracker
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Example/Example-SwiftUI/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
41 changes: 41 additions & 0 deletions Example/Example-SwiftUI/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// ContentView.swift
// GrowingAnalytics
//
// Created by YoloMao on 2024/2/21.
// Copyright (C) 2024 Beijing Yishu Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import SwiftUI
import GrowingAnalytics

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Button("TrackCustomEvent") {
GrowingAutotracker.sharedInstance().trackCustomEvent("SwiftUI_custom_event",
withAttributes: ["key": "value"])
}
}
.padding()
}
}

#Preview {
ContentView()
}
34 changes: 34 additions & 0 deletions Example/Example-SwiftUI/CustomAppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// CustomAppDelegate.swift
// GrowingAnalytics
//
// Created by YoloMao on 2024/2/21.
// Copyright (C) 2024 Beijing Yishu Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
import UIKit
import GrowingAnalytics

class CustomAppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let config = GrowingAutotrackConfiguration(accountId: "0a1b4118dd954ec3bcc69da5138bdb96")
config?.dataSourceId = "ab555003531e0fd1"
config?.urlScheme = "growing.bf30ad277eaae1aa"
config?.debugEnabled = true
GrowingAutotracker.start(with: config!)

return true
}
}
39 changes: 39 additions & 0 deletions Example/Example-SwiftUI/Example_SwiftUIApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Example_SwiftUIApp.swift
// GrowingAnalytics
//
// Created by YoloMao on 2024/2/21.
// Copyright (C) 2024 Beijing Yishu Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import SwiftUI
import GrowingAnalytics

@main
struct Example_SwiftUIApp: App {

@UIApplicationDelegateAdaptor(CustomAppDelegate.self) var delegate

var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL(perform: { url in
DeepLink.handle(url)
})
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb, perform: { userActivity in
DeepLink.handle(userActivity.webpageURL)
})
}
}
}
25 changes: 25 additions & 0 deletions Example/Example-SwiftUI/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>growing.bf30ad277eaae1aa</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>growing.deeplink</string>
</array>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 0ef1b26

Please sign in to comment.