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

feat: add visionOS support #244

Merged
merged 10 commits into from
Nov 20, 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
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
authorize:
name: Authorize
runs-on: macos-13
runs-on: macos-13-xlarge
crleona marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: ${{ github.actor }} permission check to do a release
uses: octokit/[email protected]
Expand All @@ -27,7 +27,7 @@ jobs:

release:
name: Release
runs-on: macos-13
runs-on: macos-13-xlarge
needs: [authorize, run-tests]
steps:
- name: Checkout
Expand All @@ -36,6 +36,11 @@ jobs:
run: |
sudo xcode-select -switch /Applications/Xcode_15.2.app

# Install missing sdk for pod lint
# Remove this step after the runner upgraded to macos-15
- name: Install visionOS simulator
run: xcodebuild -downloadPlatform visionOS -quiet

- name: Validate Podfile
run: pod lib lint --allow-warnings

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
xcode: 15.2
test-destination-os: latest
device: "Apple Watch Series 8 (41mm)"

- runs-on: macos-13
platform: visionOS
xcode: 15.2
test-destination-os: latest
device: "Apple Vision Pro"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -86,6 +92,13 @@ jobs:
-destination 'platform=watchOS Simulator,OS=${{ matrix.test-destination-os }},name=${{ matrix.device }}' \
test
;;
visionOS)
xcodebuild \
-scheme Amplitude-Swift-Package \
-sdk xrsimulator \
-destination 'platform=visionOS Simulator,OS=${{ matrix.test-destination-os }},name=${{ matrix.device }}' \
test
;;
esac
objc-example-test:
runs-on: macos-13
Expand Down
20 changes: 16 additions & 4 deletions Amplitude-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -870,12 +870,15 @@
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)NoUIKit";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)NoUIKit";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) AMPLITUDE_DISABLE_UIKIT";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 7;
TARGET_NAME = AmplitudeSwift;
TVOS_DEPLOYMENT_TARGET = 13.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.3;
};
name = ReleaseDisableUIKit;
};
Expand Down Expand Up @@ -967,12 +970,15 @@
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)NoUIKit";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)NoUIKit";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) AMPLITUDE_DISABLE_UIKIT";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 7;
TARGET_NAME = AmplitudeSwift;
TVOS_DEPLOYMENT_TARGET = 13.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.3;
};
name = DebugDisableUIKiit;
};
Expand Down Expand Up @@ -1151,12 +1157,15 @@
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 7;
TARGET_NAME = AmplitudeSwift;
TVOS_DEPLOYMENT_TARGET = 13.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.3;
};
name = Debug;
};
Expand Down Expand Up @@ -1188,12 +1197,15 @@
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 7;
TARGET_NAME = AmplitudeSwift;
TVOS_DEPLOYMENT_TARGET = 13.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.3;
};
name = Release;
};
Expand Down
8 changes: 6 additions & 2 deletions AmplitudeSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Pod::Spec.new do |s|
s.author = { "Amplitude" => "[email protected]" }
s.source = { :git => "https://github.com/amplitude/Amplitude-Swift.git", :tag => "v#{s.version}" }

s.swift_version = '5.7'
s.swift_version = '5.9'

s.ios.deployment_target = '13.0'
s.ios.source_files = 'Sources/Amplitude/**/*.{h,swift}'
Expand All @@ -29,7 +29,11 @@ Pod::Spec.new do |s|
# s.watchos.source_files = 'Sources/Amplitude/**/*.{h,swift}'
# s.watchos.resource_bundle = { 'Amplitude': ['Sources/Amplitude/PrivacyInfo.xcprivacy'] }

s.dependency 'AnalyticsConnector', '~> 1.0.1'
s.visionos.deployment_target = '1.0'
s.visionos.source_files = 'Sources/Amplitude/**/*.{h,swift}'
s.visionos.resource_bundle = { 'Amplitude': ['Sources/Amplitude/PrivacyInfo.xcprivacy'] }

s.dependency 'AnalyticsConnector', '~> 1.3.0'

s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
end
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/amplitude/analytics-connector-ios.git", from: "1.0.1")
.package(url: "https://github.com/amplitude/analytics-connector-ios.git", from: "1.3.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
43 changes: 43 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Amplitude-Swift",
platforms: [
.macOS("10.15"),
.iOS("13.0"),
.tvOS("13.0"),
.watchOS("7.0"),
.visionOS("1.0"),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "AmplitudeSwift",
targets: ["AmplitudeSwift"]
)
],
dependencies: [
.package(url: "https://github.com/amplitude/analytics-connector-ios.git", from: "1.3.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "AmplitudeSwift",
dependencies: [
.product(name: "AnalyticsConnector", package: "analytics-connector-ios")
],
path: "Sources/Amplitude",
exclude: ["../../Examples/", "../../Tests/"],
resources: [.copy("PrivacyInfo.xcprivacy")]
),
.testTarget(
name: "Amplitude-SwiftTests",
dependencies: ["AmplitudeSwift"],
path: "Tests/AmplitudeTests"
),
]
)
4 changes: 3 additions & 1 deletion Sources/Amplitude/Plugins/Vendors/AppUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import Foundation

#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
import SystemConfiguration
import UIKit

Expand Down Expand Up @@ -35,6 +35,8 @@ import Foundation
override var platform: String {
#if os(tvOS)
return "tvOS"
#elseif os(visionOS)
return "visionOS"
#elseif targetEnvironment(macCatalyst)
return "macOS"
#else
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Plugins/Vendors/VendorSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class VendorSystem {
}

static var current: VendorSystem = {
#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
return IOSVendorSystem()
#elseif os(macOS)
return MacOSVendorSystem()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Plugins/iOS/IOSLifecycleMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Hao Yu on 11/15/22.
//

#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT

import Foundation
import SwiftUI
Expand Down
4 changes: 3 additions & 1 deletion Sources/Amplitude/Plugins/iOS/UIKitElementInteractions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
import UIKit

class UIKitElementInteractions {
Expand Down Expand Up @@ -148,6 +148,8 @@ extension UIGestureRecognizer {
gestureAction = "pinch"
case is UIRotationGestureRecognizer:
gestureAction = "rotation"
#endif
#if !os(tvOS) && !os(visionOS)
case is UIScreenEdgePanGestureRecognizer:
gestureAction = "screenEdgePan"
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Plugins/iOS/UIKitScreenViews.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
#if (os(iOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)) && !AMPLITUDE_DISABLE_UIKIT
import UIKit

class UIKitScreenViews {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

SCHEME="Amplitude-Swift-Package"
BUILD_DIR="./.build/artifacts"
PLATFORMS=("iOS" "iOS Simulator" "macOS" "macOS Cataylst" "watchOS" "watchOS Simulator" "tvOS" "tvOS Simulator")
PLATFORMS=("iOS" "iOS Simulator" "macOS" "macOS Cataylst" "watchOS" "watchOS Simulator" "tvOS" "tvOS Simulator" "visionOS" "visionOS Simulator")

build_framework_with_configuration_and_name() {
CONFIGURATION=${1}
Expand Down
Loading