Skip to content

Commit

Permalink
Update SDK to support swift 6
Browse files Browse the repository at this point in the history
* Update TCA to latest
* incorporate Anycodable
* fix many concurrency issues
  • Loading branch information
ndurell committed Nov 27, 2024
1 parent b283644 commit aee9f46
Show file tree
Hide file tree
Showing 158 changed files with 14,028 additions and 5,092 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,40 @@ concurrency:
cancel-in-progress: true

jobs:
library:
library-macos-14:
name: Build and Run Unit Tests
runs-on: macos-14
strategy:
matrix:
xcode: ['15.2', '15.4', '16.0']
xcode: ['15.2', '15.4']
config: ['debug', 'release']
steps:
- uses: actions/checkout@v3
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Run ${{ matrix.config }} tests
run: make CONFIG=${{ matrix.config }} test-library
run: make XCODE=${{ matrix.xcode }} CONFIG=${{ matrix.config }} test-library

- uses: conradev/xcresulttool@v1.8.0
- uses: slidoapp/xcresulttool@v3.1.0
with:
path: TestResults.xcresult
path: TestResults-${{ matrix.xcode }}-${{ matrix.config }}.xcresult
if: success() || failure()

library-macos-15:
name: Build and Run Unit Tests
runs-on: macos-15
strategy:
matrix:
xcode: ['16.0']
config: ['debug', 'release']
steps:
- uses: actions/checkout@v3
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Run ${{ matrix.config }} tests
run: make XCODE=${{ matrix.xcode }} CONFIG=${{ matrix.config }} test-library

- uses: slidoapp/[email protected]
with:
path: TestResults-${{ matrix.xcode }}-${{ matrix.config }}.xcresult
if: success() || failure()
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# format options

--exclude Sources/KlaviyoSwift/Vendor,Tests/KlaviyoSwiftTests/Vendor,Tests/KlaviyoSwiftTests/__Snapshots__
--exclude Sources/KlaviyoSDKDependencies,Sources/KlaviyoSwift/Vendor,Tests/KlaviyoSwiftTests/Vendor,Tests/KlaviyoSwiftTests/__Snapshots__
--closingparen same-line
--commas inline
--comments indent
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ excluded: # paths to ignore during linting. Takes precedence over `included`.
- Sources/KlaviyoSwift/Vendor
- Tests/KlaviyoSwiftTests/Vendor
- Tests/KlaviyoSwiftTests/__Snapshots__
- Sources/KlaviyoSDKDependencies
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
- explicit_self

Expand Down
4 changes: 2 additions & 2 deletions KlaviyoCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.author = { "Mobile @ Klaviyo" => "[email protected]" }
s.source = { :git => "https://github.com/klaviyo/klaviyo-swift-sdk.git", :tag => s.version.to_s }
s.swift_version = '5.7'
s.platform = :ios, '13.0'
s.platform = :ios, '15.0'
s.source_files = 'Sources/KlaviyoCore/**/*.swift'
s.dependency 'AnyCodable-FlightSchool'
s.dependency 'KlaviyoSDKDependencies', '~>4.0.0'
end
15 changes: 15 additions & 0 deletions KlaviyoSDKDependencies.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Pod::Spec.new do |s|
s.name = "KlaviyoSDKDependencies"
s.version = "4.0.0"
s.summary = "Dependency for the Klaviyo SDK"
s.description = <<-DESC
Klaviyo external dependencies all rolled in one package
DESC
s.homepage = "https://github.com/klaviyo/klaviyo-swift-sdk"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Mobile @ Klaviyo" => "[email protected]" }
s.source = { :git => "https://github.com/klaviyo/klaviyo-swift-sdk.git", :tag => s.version.to_s }
s.swift_version = '5.7'
s.platform = :ios, '15.0'
s.source_files = 'Sources/KlaviyoCore/**/*.swift'
end
4 changes: 2 additions & 2 deletions KlaviyoSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/klaviyo/klaviyo-swift-sdk.git", :tag => s.version.to_s }
s.swift_version = '5.7'
s.platform = :ios
s.ios.deployment_target = '13.0'
s.ios.deployment_target = '15.0'
s.source_files = 'Sources/KlaviyoSwift/**/*.swift'
s.resource_bundles = {"KlaviyoSwift" => ["Sources/KlaviyoSwift/PrivacyInfo.xcprivacy"]}
s.dependency 'KlaviyoCore', '~> 4.0.0'
s.dependency 'AnyCodable-FlightSchool'
s.dependency 'KlaviyoSDKDependencies', '~>4.0.0'
end
2 changes: 1 addition & 1 deletion KlaviyoSwiftExtension.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/klaviyo/klaviyo-swift-sdk.git", :tag => s.version.to_s }
s.swift_version = '5.7'
s.platform = :ios
s.ios.deployment_target = '13.0'
s.ios.deployment_target = '15.0'
s.source_files = 'Sources/KlaviyoSwiftExtension/**/*.swift'
end
2 changes: 1 addition & 1 deletion KlaviyoUI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.author = { "Mobile @ Klaviyo" => "[email protected]" }
s.source = { :git => "https://github.com/klaviyo/klaviyo-swift-sdk.git", :tag => s.version.to_s }
s.swift_version = '5.7'
s.platform = :ios, '13.0'
s.platform = :ios, '15.0'
s.source_files = 'Sources/KlaviyoUI/**/*.swift'
# update once modularization changes are merged in.
s.dependency 'KlaviyoSwift', '~> 4.0.0'
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG = debug
XCODE = 15.2
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])


Expand All @@ -10,7 +11,7 @@ test-all: $(MAKE) CONFIG=debug test-library
test-library:
for platform in "$(PLATFORM_IOS)"; do \
xcodebuild test \
-resultBundlePath TestResults \
-resultBundlePath TestResults-$(XCODE)-$(CONFIG) \
-enableCodeCoverage YES \
-configuration=$(CONFIG) \
-scheme klaviyo-swift-sdk-Package \
Expand Down
41 changes: 16 additions & 25 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,57 +1,48 @@
{
"pins" : [
{
"identity" : "anycodable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Flight-School/AnyCodable",
"state" : {
"revision" : "862808b2070cd908cb04f9aafe7de83d35f81b05",
"version" : "0.6.7"
}
},
{
"identity" : "combine-schedulers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/combine-schedulers",
"state" : {
"revision" : "882ac01eb7ef9e36d4467eb4b1151e74fcef85ab",
"version" : "0.9.1"
"revision" : "9fa31f4403da54855f1e2aeaeff478f4f0e40b13",
"version" : "1.0.2"
}
},
{
"identity" : "swift-case-paths",
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "bb436421f57269fbcfe7360735985321585a86e5",
"version" : "0.10.1"
"revision" : "6054df64b55186f08b6d0fd87152081b8ad8d613",
"version" : "1.2.0"
}
},
{
"identity" : "swift-custom-dump",
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "ead7d30cc224c3642c150b546f4f1080d1c411a8",
"version" : "0.6.1"
"revision" : "42a086182681cf661f5c47c9b7dc3931de18c6d7",
"version" : "1.17.6"
}
},
{
"identity" : "swift-snapshot-testing",
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "f29e2014f6230cf7d5138fc899da51c7f513d467",
"version" : "1.10.0"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "5a5457a744239896e9b0b03a8e1a5069c3e7b91f",
"version" : "0.6.0"
"revision" : "770f990d3e4eececb57ac04a6076e22f8c97daeb",
"version" : "1.4.2"
}
}
],
Expand Down
47 changes: 30 additions & 17 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// swift-tools-version: 5.6
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import CompilerPluginSupport
import PackageDescription

let package = Package(
name: "klaviyo-swift-sdk",
platforms: [.iOS(.v13)],
platforms: [.iOS(.v15), .macOS(.v10_15)],
products: [
.library(
name: "KlaviyoSwift",
Expand All @@ -19,40 +20,38 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.10.0"),
.package(
url: "https://github.com/Flight-School/AnyCodable",
from: "0.6.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.6.1"),
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.10.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "0.9.1")
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.2"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.3.0")
],
targets: [
.target(
name: "KlaviyoCore",
dependencies: [.product(name: "AnyCodable", package: "AnyCodable")],
dependencies: ["KlaviyoSDKDependencies"],
path: "Sources/KlaviyoCore"),
.testTarget(
name: "KlaviyoCoreTests",
dependencies: [
"KlaviyoCore",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "CasePaths", package: "swift-case-paths")
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwift",
dependencies: [.product(name: "AnyCodable", package: "AnyCodable"), "KlaviyoCore"],
dependencies: [
"KlaviyoCore",
"KlaviyoSDKDependencies"
],
path: "Sources/KlaviyoSwift",
resources: [.copy("PrivacyInfo.xcprivacy")]),
.testTarget(
name: "KlaviyoSwiftTests",
dependencies: [
"KlaviyoSwift",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "CasePaths", package: "swift-case-paths"),
"KlaviyoSDKDependencies",
.product(name: "CombineSchedulers", package: "combine-schedulers"),
"KlaviyoCore"
"KlaviyoCore",
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay")
],
exclude: [
"__Snapshots__"
Expand All @@ -66,10 +65,24 @@ let package = Package(
name: "KlaviyoUITests",
dependencies: [
"KlaviyoSwift",
"KlaviyoCore"
"KlaviyoCore",
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwiftExtension",
dependencies: [],
path: "Sources/KlaviyoSwiftExtension")
path: "Sources/KlaviyoSwiftExtension"),

// Vendorized Things
.target(
name: "KlaviyoSDKDependencies",
dependencies: [],
path: "Sources/KlaviyoSDKDependencies")
])

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(contentsOf: [
.enableExperimentalFeature("StrictConcurrency")
])
}
81 changes: 81 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// swift-tools-version:6.0

import CompilerPluginSupport
import PackageDescription

let package = Package(
name: "klaviyo-swift-sdk",
platforms: [.iOS(.v15), .macOS(.v10_15)],
products: [
.library(
name: "KlaviyoSwift",
targets: ["KlaviyoSwift"]),
.library(
name: "KlaviyoUI",
targets: ["KlaviyoUI"]),
.library(
name: "KlaviyoSwiftExtension",
targets: ["KlaviyoSwiftExtension"])
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.10.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.2"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.3.0")
],
targets: [
.target(
name: "KlaviyoCore",
dependencies: ["KlaviyoSDKDependencies"],
path: "Sources/KlaviyoCore"),
.testTarget(
name: "KlaviyoCoreTests",
dependencies: [
"KlaviyoCore",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwift",
dependencies: [
"KlaviyoSDKDependencies",
"KlaviyoCore"
],
path: "Sources/KlaviyoSwift",
resources: [.copy("PrivacyInfo.xcprivacy")]),
.testTarget(
name: "KlaviyoSwiftTests",
dependencies: [
"KlaviyoSwift",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"KlaviyoSDKDependencies",
.product(name: "CombineSchedulers", package: "combine-schedulers"),
"KlaviyoCore",
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay")
],
exclude: [
"__Snapshots__"
]),
.target(
name: "KlaviyoUI",
dependencies: ["KlaviyoSwift"],
path: "Sources/KlaviyoUI",
resources: [.process("KlaviyoWebView/Resources")]),
.testTarget(
name: "KlaviyoUITests",
dependencies: [
"KlaviyoSwift",
"KlaviyoCore",
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwiftExtension",
dependencies: [],
path: "Sources/KlaviyoSwiftExtension"),

// Vendorized Things
.target(
name: "KlaviyoSDKDependencies",
dependencies: [],
path: "Sources/KlaviyoSDKDependencies")
],
swiftLanguageModes: [.v6])
Loading

0 comments on commit aee9f46

Please sign in to comment.