diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4829a00..b6be6bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ on: jobs: authorize: name: Authorize - runs-on: macos-13 + runs-on: macos-13-xlarge steps: - name: ${{ github.actor }} permission check to do a release uses: octokit/request-action@v2.1.9 @@ -27,7 +27,7 @@ jobs: release: name: Release - runs-on: macos-13 + runs-on: macos-13-xlarge needs: [authorize, run-tests] steps: - name: Checkout @@ -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 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 49fb4f6..f1cd351 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -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 @@ -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 diff --git a/Amplitude-Swift.xcodeproj/project.pbxproj b/Amplitude-Swift.xcodeproj/project.pbxproj index 999ca39..56d6059 100644 --- a/Amplitude-Swift.xcodeproj/project.pbxproj +++ b/Amplitude-Swift.xcodeproj/project.pbxproj @@ -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; }; @@ -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; }; @@ -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; }; @@ -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; }; diff --git a/AmplitudeSwift.podspec b/AmplitudeSwift.podspec index 42af87a..9f7ed86 100644 --- a/AmplitudeSwift.podspec +++ b/AmplitudeSwift.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.author = { "Amplitude" => "dev@amplitude.com" } 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}' @@ -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 diff --git a/Package.swift b/Package.swift index f009c74..7a7058e 100644 --- a/Package.swift +++ b/Package.swift @@ -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. diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift new file mode 100644 index 0000000..8bd0a76 --- /dev/null +++ b/Package@swift-5.9.swift @@ -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" + ), + ] +) diff --git a/Sources/Amplitude/Plugins/Vendors/AppUtil.swift b/Sources/Amplitude/Plugins/Vendors/AppUtil.swift index 3a2225f..99b2504 100644 --- a/Sources/Amplitude/Plugins/Vendors/AppUtil.swift +++ b/Sources/Amplitude/Plugins/Vendors/AppUtil.swift @@ -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 @@ -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 diff --git a/Sources/Amplitude/Plugins/Vendors/VendorSystem.swift b/Sources/Amplitude/Plugins/Vendors/VendorSystem.swift index fb58f39..a086d46 100644 --- a/Sources/Amplitude/Plugins/Vendors/VendorSystem.swift +++ b/Sources/Amplitude/Plugins/Vendors/VendorSystem.swift @@ -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() diff --git a/Sources/Amplitude/Plugins/iOS/IOSLifecycleMonitor.swift b/Sources/Amplitude/Plugins/iOS/IOSLifecycleMonitor.swift index cef0e04..156f4ff 100644 --- a/Sources/Amplitude/Plugins/iOS/IOSLifecycleMonitor.swift +++ b/Sources/Amplitude/Plugins/iOS/IOSLifecycleMonitor.swift @@ -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 diff --git a/Sources/Amplitude/Plugins/iOS/UIKitElementInteractions.swift b/Sources/Amplitude/Plugins/iOS/UIKitElementInteractions.swift index 52e3d3b..2c813f6 100644 --- a/Sources/Amplitude/Plugins/iOS/UIKitElementInteractions.swift +++ b/Sources/Amplitude/Plugins/iOS/UIKitElementInteractions.swift @@ -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 { @@ -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 diff --git a/Sources/Amplitude/Plugins/iOS/UIKitScreenViews.swift b/Sources/Amplitude/Plugins/iOS/UIKitScreenViews.swift index 7899a37..decbdeb 100644 --- a/Sources/Amplitude/Plugins/iOS/UIKitScreenViews.swift +++ b/Sources/Amplitude/Plugins/iOS/UIKitScreenViews.swift @@ -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 { diff --git a/scripts/build_framework.sh b/scripts/build_framework.sh index d02f5a6..f3029a1 100755 --- a/scripts/build_framework.sh +++ b/scripts/build_framework.sh @@ -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}