Skip to content

Commit

Permalink
combine dependencies into one place
Browse files Browse the repository at this point in the history
  • Loading branch information
ndurell committed Nov 12, 2024
1 parent 92612fe commit 97e9526
Show file tree
Hide file tree
Showing 115 changed files with 132 additions and 195 deletions.
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/CustomDump,Sources/CasePaths,Sources/ConcurrencyExtras,Sources/IssueReporting,Sources/Perception,Sources/IdentifiedCollections,Sources/InternalCollectionsUtilities,Sources/OrderedCollections,Sources/ComposableArchitecture,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
12 changes: 1 addition & 11 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ excluded: # paths to ignore during linting. Takes precedence over `included`.
- Sources/KlaviyoSwift/Vendor
- Tests/KlaviyoSwiftTests/Vendor
- Tests/KlaviyoSwiftTests/__Snapshots__
- Sources/AnyCodable
- Sources/Collections
- Sources/ComposableArchitecture
- Sources/IdentifiedCollections
- Sources/InternalCollectionsUtilities
- Sources/OrderedCollections
- Sources/Perception
- Sources/IssueReporting
- Sources/ConcurrencyExtras
- Sources/CasePaths
- Sources/CustomDump
- Sources/KlaviyoSDKDependencies
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
- explicit_self

Expand Down
1 change: 1 addition & 0 deletions KlaviyoCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Pod::Spec.new do |s|
s.swift_version = '5.7'
s.platform = :ios, '13.0'
s.source_files = 'Sources/KlaviyoCore/**/*.swift'
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, '13.0'
s.source_files = 'Sources/KlaviyoCore/**/*.swift'
end
1 change: 1 addition & 0 deletions KlaviyoSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Pod::Spec.new do |s|
s.source_files = 'Sources/KlaviyoSwift/**/*.swift'
s.resource_bundles = {"KlaviyoSwift" => ["Sources/KlaviyoSwift/PrivacyInfo.xcprivacy"]}
s.dependency 'KlaviyoCore', '~> 4.0.0'
s.dependency 'KlaviyoSDKDependencies', '~>4.0.0'
end
42 changes: 7 additions & 35 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@ let package = Package(
targets: [
.target(
name: "KlaviyoCore",
dependencies: ["AnyCodable"],
dependencies: ["KlaviyoSDKDependencies"],
path: "Sources/KlaviyoCore"),
.testTarget(
name: "KlaviyoCoreTests",
dependencies: [
"KlaviyoCore",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"KCustomDump"
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwift",
dependencies: [
"KlaviyoCore",
"KComposableArchitecture",
"AnyCodable"
"KlaviyoSDKDependencies"
],
path: "Sources/KlaviyoSwift",
resources: [.copy("PrivacyInfo.xcprivacy")]),
Expand All @@ -49,12 +48,9 @@ let package = Package(
dependencies: [
"KlaviyoSwift",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"KCustomDump",
"KlaviyoSDKDependencies",
.product(name: "CombineSchedulers", package: "combine-schedulers"),
"KlaviyoCore",
"KComposableArchitecture",
"KIssueReporting",
"KCasePaths",
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay")
],
exclude: [
Expand All @@ -70,8 +66,7 @@ let package = Package(
dependencies: [
"KlaviyoSwift",
"KlaviyoCore",
"KIssueReporting",
"KCustomDump"
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwiftExtension",
Expand All @@ -80,30 +75,7 @@ let package = Package(

// Vendorized Things
.target(
name: "KComposableArchitecture",
dependencies: [
"KCustomDump",
"KConcurrencyExtras",
"KCasePaths"
],
path: "Sources/ComposableArchitecture"),
.target(
name: "AnyCodable",
dependencies: [],
path: "Sources/AnyCodable"),
.target(
name: "KConcurrencyExtras",
dependencies: [],
path: "Sources/ConcurrencyExtras"),
.target(
name: "KIssueReporting",
name: "KlaviyoSDKDependencies",
dependencies: [],
path: "Sources/IssueReporting"),
.target(name: "KCasePaths",
dependencies: ["KIssueReporting"],
path: "Sources/CasePaths"),
.target(name: "KCustomDump",
dependencies: ["KIssueReporting"],
path: "Sources/CustomDump")

path: "Sources/KlaviyoSDKDependencies")
])
43 changes: 8 additions & 35 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@ let package = Package(
targets: [
.target(
name: "KlaviyoCore",
dependencies: ["AnyCodable"],
dependencies: ["KlaviyoSDKDependencies"],
path: "Sources/KlaviyoCore"),
.testTarget(
name: "KlaviyoCoreTests",
dependencies: [
"KlaviyoCore",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"KCustomDump"
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwift",
dependencies: [
"AnyCodable",
"KlaviyoCore",
"KComposableArchitecture"
"KlaviyoSDKDependencies",
"KlaviyoCore"
],
path: "Sources/KlaviyoSwift",
resources: [.copy("PrivacyInfo.xcprivacy")]),
Expand All @@ -48,12 +47,9 @@ let package = Package(
dependencies: [
"KlaviyoSwift",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"KCustomDump",
"KlaviyoSDKDependencies",
.product(name: "CombineSchedulers", package: "combine-schedulers"),
"KlaviyoCore",
"KComposableArchitecture",
"KIssueReporting",
"KCasePaths",
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay")
],
exclude: [
Expand All @@ -69,8 +65,7 @@ let package = Package(
dependencies: [
"KlaviyoSwift",
"KlaviyoCore",
"KIssueReporting",
"KCustomDump"
"KlaviyoSDKDependencies"
]),
.target(
name: "KlaviyoSwiftExtension",
Expand All @@ -79,30 +74,8 @@ let package = Package(

// Vendorized Things
.target(
name: "KComposableArchitecture",
dependencies: [
"KCustomDump",
"KConcurrencyExtras",
"KCasePaths"
],
path: "Sources/ComposableArchitecture"),
.target(
name: "AnyCodable",
dependencies: [],
path: "Sources/AnyCodable"),
.target(
name: "KConcurrencyExtras",
dependencies: [],
path: "Sources/ConcurrencyExtras"),
.target(
name: "KIssueReporting",
name: "KlaviyoSDKDependencies",
dependencies: [],
path: "Sources/IssueReporting"),
.target(name: "KCasePaths",
dependencies: ["KIssueReporting"],
path: "Sources/CasePaths"),
.target(name: "KCustomDump",
dependencies: ["KIssueReporting"],
path: "Sources/CustomDump")
path: "Sources/KlaviyoSDKDependencies")
],
swiftLanguageModes: [.v6])
2 changes: 1 addition & 1 deletion Sources/KlaviyoCore/KlaviyoEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Noah Durell on 9/28/22.
//

import AnyCodable
import Combine
import Foundation
import KlaviyoSDKDependencies
import UIKit

// Though this is a var it should never be modified outside of tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Ajay Subramanya on 8/5/24.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

public struct CreateEventPayload: Equatable, Codable, Sendable {
public struct Event: Equatable, Codable, Sendable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Ajay Subramanya on 8/5/24.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

public struct CreateProfilePayload: Equatable, Codable, Sendable {
public init(data: ProfilePayload) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/KlaviyoCore/Models/APIModels/ProfilePayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Ajay Subramanya on 8/6/24.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

/**
Internal structure which has details not needed by the API.
Expand Down
2 changes: 1 addition & 1 deletion Sources/KlaviyoCore/Networking/KlaviyoAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Noah Durell on 11/8/22.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

public struct KlaviyoAPI: Sendable {
public var send: @Sendable (NetworkSession, KlaviyoRequest, Int) async -> Result<Data, KlaviyoAPIError>
Expand Down
2 changes: 1 addition & 1 deletion Sources/KlaviyoCore/Networking/KlaviyoEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Created by Noah Durell on 11/25/22.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

public enum KlaviyoEndpoint: Equatable, Codable, Sendable {
case createProfile(CreateProfilePayload)
Expand Down
2 changes: 1 addition & 1 deletion Sources/KlaviyoCore/Networking/KlaviyoRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Ajay Subramanya on 8/5/24.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

public struct KlaviyoRequest: Equatable, Codable, Sendable {
public let apiKey: String
Expand Down
2 changes: 1 addition & 1 deletion Sources/KlaviyoCore/Networking/SDKRequestIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Noah Durell on 2/13/23.
//

import AnyCodable
import Foundation
import KlaviyoSDKDependencies

@_spi(KlaviyoPrivate)
public struct SDKRequest: Identifiable, Equatable {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public struct AnyCasePath<Root, Value>: Sendable {
nonisolated(unsafe) let embed = embed
return Self(embed: { embed($0) }, extract: extract)
#else
@UncheckedSendable var embed = embed
@CasePathsUncheckedSendable var embed = embed
return Self(embed: { [$embed] in $embed.wrappedValue($0) }, extract: extract)
#endif
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import KIssueReporting
import KlaviyoSDKDependencies

/// A type that provides a collection of all of its case paths.
///
Expand Down Expand Up @@ -85,7 +85,7 @@ extension Case {
dynamicMember keyPath: KeyPath<Value.AllCasePaths, AnyCasePath<Value, AppendedValue>>
) -> Case<AppendedValue>
where Value: CasePathable {
@UncheckedSendable var keyPath = keyPath
@CasePathsUncheckedSendable var keyPath = keyPath
return Case<AppendedValue>(
embed: { [$keyPath] in
embed(Value.allCasePaths[keyPath: $keyPath.wrappedValue].embed($0))
Expand Down Expand Up @@ -549,7 +549,7 @@ extension AnyCasePath where Value: CasePathable {
public subscript<AppendedValue>(
dynamicMember keyPath: KeyPath<Value.AllCasePaths, AnyCasePath<Value, AppendedValue>>
) -> AnyCasePath<Root, AppendedValue> {
@UncheckedSendable var keyPath = keyPath
@CasePathsUncheckedSendable var keyPath = keyPath
return AnyCasePath<Root, AppendedValue>(
embed: { [$keyPath] in
embed(Value.allCasePaths[keyPath: $keyPath.wrappedValue].embed($0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension AnyCasePath {
optionalPromotedExtractHelp(unsafeBitCast(embed, to: (@Sendable (Value) -> Wrapped?).self))
as! @Sendable (Root) -> Value?
}
@UncheckedSendable var embed = embed
@CasePathsUncheckedSendable var embed = embed
let extract =
((_Witness<Root>.self as? _AnyOptional.Type)?.wrappedType)
.map { _openExistential($0, do: open) }
Expand Down Expand Up @@ -73,7 +73,7 @@ func extractHelp<Root, Value>(
return { _ in nil }
}

let cache = LockIsolated(Cache())
let cache = CasePathsLockIsolated(Cache())

return { root in
let rootTag = metadata.tag(of: root)
Expand Down Expand Up @@ -119,7 +119,7 @@ func optionalPromotedExtractHelp<Root, Value>(
return { _ in nil }
}

let cachedTag = LockIsolated<UInt32?>(nil)
let cachedTag = CasePathsLockIsolated<UInt32?>(nil)

return { optionalRoot in
guard let root = optionalRoot else { return nil }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

final class LockIsolated<Value>: @unchecked Sendable {
final class CasePathsLockIsolated<Value>: @unchecked Sendable {
private var _value: Value
private let lock = NSRecursiveLock()
init(_ value: @autoclosure @Sendable () throws -> Value) rethrows {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@propertyWrapper
struct UncheckedSendable<Value>: @unchecked Sendable {
struct CasePathsUncheckedSendable<Value>: @unchecked Sendable {
var wrappedValue: Value
init(wrappedValue value: Value) {
self.wrappedValue = value
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@preconcurrency import Combine
import KConcurrencyExtras
import KCustomDump
import KlaviyoSDKDependencies
import Foundation
import KIssueReporting
import SwiftUI

public struct Effect<Action>: Sendable {
Expand Down
Loading

0 comments on commit 97e9526

Please sign in to comment.