Skip to content

Commit

Permalink
feat: add visionOS Support (#9)
Browse files Browse the repository at this point in the history
* add visionOS support

* add visionos support to podspec

* add an separate swift package file

* fix for github workflow

* add visionos support for UT

* fix github workflow
  • Loading branch information
sojingle authored Nov 19, 2024
1 parent 2062191 commit 5f94bc8
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 17 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set Xcode 14.3.1
- name: Set Xcode 15.4
run: |
sudo xcode-select -switch /Applications/Xcode_14.3.1.app
sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: iOS Build
run: |
Expand All @@ -58,6 +58,14 @@ jobs:
-sdk appletvsimulator \
-destination 'platform=tvOS Simulator,name=Apple TV' \
- name: visionOS Build
run: |
xcodebuild \
-project AnalyticsConnector.xcodeproj \
-scheme AnalyticsConnector \
-sdk xrsimulator \
-destination 'platform=visionOS Simulator,name=Apple Vision Pro' \
- name: iOS Tests
run: |
xcodebuild test \
Expand All @@ -84,6 +92,20 @@ jobs:
-destination 'platform=tvOS Simulator,name=Apple TV' \
test
- name: visionOS Tests
run: |
xcodebuild \
-project AnalyticsConnector.xcodeproj \
-scheme AnalyticsConnector \
-sdk xrsimulator \
-destination 'platform=visionOS Simulator,name=Apple Vision Pro' \
test
# 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 All @@ -97,7 +119,9 @@ jobs:
- name: Update Checksum
run: |
CHECKSUM=$(xcrun swift package compute-checksum .build/artifacts/AnalyticsConnector.xcframework.zip) && \
sed -i '' -E "s/(checksum: \")[^\"]*(\")/\1$CHECKSUM\2/" Package.swift
sed -i '' -E "s/(checksum: \")[^\"]*(\")/\1$CHECKSUM\2/" Package.swift && \
sed -i '' -E "s/(checksum: \")[^\"]*(\")/\1$CHECKSUM\2/" [email protected]
- name: Semantic Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set Xcode 14.3.1
- name: Set Xcode 15.4
run: |
sudo xcode-select -switch /Applications/Xcode_14.3.1.app
sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: iOS Build
run: |
Expand All @@ -41,6 +41,14 @@ jobs:
-sdk appletvsimulator \
-destination 'platform=tvOS Simulator,name=Apple TV' \
- name: visionOS Build
run: |
xcodebuild \
-project AnalyticsConnector.xcodeproj \
-scheme AnalyticsConnector \
-sdk xrsimulator \
-destination 'platform=visionOS Simulator,name=Apple Vision Pro' \
- name: iOS Tests
run: |
xcodebuild test \
Expand All @@ -67,3 +75,11 @@ jobs:
-destination 'platform=tvOS Simulator,name=Apple TV' \
test
- name: visionOS Tests
run: |
xcodebuild \
-project AnalyticsConnector.xcodeproj \
-scheme AnalyticsConnector \
-sdk xrsimulator \
-destination 'platform=visionOS Simulator,name=Apple Vision Pro' \
test
3 changes: 3 additions & 0 deletions AnalyticsConnector.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Pod::Spec.new do |spec|
spec.watchos.deployment_target = '3.0'
spec.watchos.source_files = 'sources/AnalyticsConnector/**/*.{h,swift}'

spec.visionos.deployment_target = '1.0'
spec.visionos.source_files = 'sources/AnalyticsConnector/**/*.{h,swift}'

spec.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }

end
22 changes: 12 additions & 10 deletions AnalyticsConnector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 55;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -13,7 +13,7 @@
2001756927728E16001C341D /* IdentityStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2001756827728E16001C341D /* IdentityStore.swift */; };
2001756F2773B679001C341D /* EventBridgeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2001756E2773B679001C341D /* EventBridgeTests.swift */; };
200175752773D888001C341D /* IdentityStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 200175742773D888001C341D /* IdentityStoreTests.swift */; };
20C47A8E297A674F0084AC03 /* AnalyticsConnector.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 200174A52771569E001C341D /* AnalyticsConnector.framework */; };
20C47A8E297A674F0084AC03 /* AnalyticsConnector.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 200174A52771569E001C341D /* AnalyticsConnector.framework */; platformFilters = (ios, macos, tvos, xros, ); };
20C9FAB1278CB1C000A4D530 /* ObjectiveCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 20C9FAB0278CB1C000A4D530 /* ObjectiveCTests.m */; };
20C9FAD4278CBFAC00A4D530 /* AnalyticsConnector.h in Headers */ = {isa = PBXBuildFile; fileRef = 20866C9B27714900003D1705 /* AnalyticsConnector.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -270,12 +270,12 @@
PRODUCT_BUNDLE_IDENTIFIER = com.amplitude.AnalyticsConnector;
PRODUCT_NAME = "$(TARGET_NAME)";
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_INSTALL_OBJC_HEADER = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
TARGETED_DEVICE_FAMILY = "1,2,3,4,6,7";
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
Expand Down Expand Up @@ -304,11 +304,11 @@
PRODUCT_BUNDLE_IDENTIFIER = com.amplitude.AnalyticsConnector;
PRODUCT_NAME = "$(TARGET_NAME)";
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_INSTALL_OBJC_HEADER = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
TARGETED_DEVICE_FAMILY = "1,2,3,4,6,7";
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
Expand All @@ -331,11 +331,12 @@
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = com.amplitude.AnalyticsConnectorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TARGETED_DEVICE_FAMILY = "1,2,3,6,7";
TVOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
Expand All @@ -357,10 +358,11 @@
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = com.amplitude.AnalyticsConnectorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TARGETED_DEVICE_FAMILY = "1,2,3,6,7";
TVOS_DEPLOYMENT_TARGET = 10.0;
};
name = Release;
Expand Down
44 changes: 44 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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: "analytics-connector-ios",
platforms: [
.iOS(.v10),
.macOS(.v10_13),
.tvOS(.v9),
.watchOS(.v3),
.visionOS(.v1),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "AnalyticsConnector",
targets: ["AnalyticsConnector"]
),
.library(
name: "AnalyticsConnectorFramework",
targets: ["AnalyticsConnectorFramework"]
)
],
dependencies: [
// Dependencies declare other packages that this package depends on.
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
.target(
name: "AnalyticsConnector",
path: "Sources/AnalyticsConnector",
exclude: ["Info.plist"]),
.binaryTarget(name: "AnalyticsConnectorFramework",
url: "https://github.com/amplitude/analytics-connector-ios/releases/download/v1.2.4/AnalyticsConnector.xcframework.zip",
checksum: "605073ac7b478d9bd5fad41505377f50f3d10250771435dd2f04003bcaf9c820"),
.testTarget(
name: "AnalyticsConnectorTests",
dependencies: ["AnalyticsConnector"],
path: "Tests/AnalyticsConnectorTests",
exclude: ["Info.plist"]),
]
)
16 changes: 15 additions & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,25 @@ module.exports = {
],
"countMatches": true
},
{
"files": ["[email protected]"],
"from": "https://github.com/amplitude/analytics-connector-ios/releases/download/v.*/AnalyticsConnector.xcframework.zip",
"to": "https://github.com/amplitude/analytics-connector-ios/releases/download/v${nextRelease.version}/AnalyticsConnector.xcframework.zip",
"results": [
{
"file": "[email protected]",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
]
}
],
["@semantic-release/git", {
"assets": ["AnalyticsConnector.podspec", "CHANGELOG.md", "Package.swift"],
"assets": ["AnalyticsConnector.podspec", "CHANGELOG.md", "Package.swift", "[email protected]"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
["@semantic-release/exec", {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SCHEME="AnalyticsConnector"
FRAMEWORK="AnalyticsConnector"
BUILD_DIR="./.build/artifacts"
OUTPUT_PATH="$BUILD_DIR/$FRAMEWORK.xcframework"
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

0 comments on commit 5f94bc8

Please sign in to comment.