Skip to content

Commit abf7e46

Browse files
authored
Adding Reference packages (#7)
1 parent e8eda7a commit abf7e46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+557
-14
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/build-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Select latest Xcode
2121
uses: maxim-lobanov/setup-xcode@v1
2222
with:
23-
xcode-version: '15.1'
23+
xcode-version: '15.4'
2424

2525
- name: 🛠️ Build with release configuration
2626
run: |

.github/workflows/run-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
- name: Select latest Xcode
1919
uses: maxim-lobanov/setup-xcode@v1
2020
with:
21-
xcode-version: '15.1'
21+
xcode-version: '15.4'
2222

23-
- name: 🛠️ Run Tests
23+
- name: 🛠️ Run All Tests
2424
run: |
25-
xcodebuild test -scheme public-api-diff -destination "platform=iOS,name=Any iOS Device" | xcpretty --utf --color && exit
25+
xcodebuild test -scheme public-api-diff -destination "platform=iOS,name=Any iOS Device" | xcpretty --utf --color && exit ${PIPESTATUS[0]}

Package.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
path: "Sources"
2424
),
2525
.testTarget(
26-
name: "PublicApiDiffTests",
26+
name: "UnitTests",
2727
dependencies: ["public-api-diff"],
2828
resources: [
2929
// Copy Tests/ExampleTests/Resources directories as-is.
@@ -32,6 +32,16 @@ let package = Package(
3232
.copy("Resources/dummy.abi.json"),
3333
.copy("Resources/dummi-abi-flat-definition.md")
3434
]
35+
),
36+
.testTarget(
37+
name: "IntegrationTests",
38+
dependencies: ["public-api-diff"],
39+
resources: [
40+
// Copy Tests/ExampleTests/Resources directories as-is.
41+
// Use to retain directory structure.
42+
// Will be at top level in bundle.
43+
.copy("Resources/expected-reference-changes.md")
44+
]
3545
)
3646
]
3747
)

ReferencePackages/.DS_Store

6 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// swift-tools-version: 5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "ReferencePackage",
8+
platforms: [.iOS(.v17)],
9+
products: [
10+
// Products define the executables and libraries a package produces, making them visible to other packages.
11+
.library(
12+
name: "ReferencePackage",
13+
targets: ["ReferencePackage"]
14+
)
15+
],
16+
targets: [
17+
// Targets are the basic building blocks of a package, defining a module or a test suite.
18+
// Targets can depend on other targets in this package and products from dependencies.
19+
.target(
20+
name: "ReferencePackage")
21+
]
22+
)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
//
2+
// Copyright (c) 2024 Adyen N.V.
3+
//
4+
// This file is open source and available under the MIT license. See the LICENSE file for more info.
5+
//
6+
7+
import Foundation
8+
9+
/**
10+
An attempt of using all swift language features to make sure that all types of different projects are supported.
11+
12+
Missing information using Swift 5.10
13+
- No information about `async`, `@MainActor`
14+
- `class func` is missing a unique feature and only shows as `static`
15+
*/
16+
17+
/**
18+
TODOs:
19+
- macro
20+
- subscriptDeclaration
21+
*/
22+
23+
// MARK: - Protocol with associatedtype
24+
25+
public protocol CustomProtocol {
26+
typealias CustomAssociatedType = Equatable
27+
28+
var getSetVar: any CustomAssociatedType { get set }
29+
var getVar: any CustomAssociatedType { get }
30+
func function() -> any CustomAssociatedType
31+
}
32+
33+
public struct CustomStruct: CustomProtocol {
34+
public var getSetVar: any Equatable
35+
public var getVar: any Equatable
36+
@discardableResult
37+
public func function() -> any Equatable { fatalError() }
38+
}
39+
40+
// MARK: - Generic public class
41+
42+
public class CustomClass<T: Equatable> {
43+
44+
public weak var weakObject: CustomClass?
45+
lazy var lazyVar: String = { "I am a lazy" }()
46+
@_spi(SomeSpi)
47+
@_spi(AnotherSpi)
48+
open var computedVar: String { "I am computed" }
49+
package let constantLet: String = "I'm a let"
50+
public var optionalVar: T?
51+
52+
@MainActor
53+
public func asyncThrowingFunc() async throws {}
54+
public func rethrowingFunc(throwingArg: @escaping () throws -> String) rethrows {}
55+
56+
public init(weakObject: CustomClass? = nil, optionalVar: T? = nil) {
57+
self.weakObject = weakObject
58+
self.optionalVar = optionalVar
59+
}
60+
61+
public init() {}
62+
63+
public convenience init(value: T) {
64+
self.init(optionalVar: value)
65+
}
66+
}
67+
68+
// MARK: - Generic open class with Protocol conformance and @_spi constraint
69+
70+
@_spi(SystemProgrammingInterface)
71+
open class OpenSpiConformingClass: CustomProtocol {
72+
public typealias CustomAssociatedType = any Equatable
73+
74+
public var getSetVar: CustomAssociatedType
75+
public var getVar: CustomAssociatedType
76+
@inlinable
77+
public func function() -> CustomAssociatedType { fatalError() }
78+
79+
public init(getSetVar: CustomAssociatedType, getVar: CustomAssociatedType) {
80+
self.getSetVar = getSetVar
81+
self.getVar = getVar
82+
}
83+
}
84+
85+
// MARK: - Package only class
86+
87+
package class PackageOnlyClass {
88+
public class func classFunc() -> String { "I'm classy" }
89+
public static func staticFunc() -> String { "I'm static" }
90+
public static var staticVar: String = "I'm static too"
91+
}
92+
93+
// MARK: - Objc
94+
95+
@_spi(ObjCSpi)
96+
@objc
97+
public class ObjcClass: NSObject {
98+
public dynamic var dynamicVar: String = "I'm dynamic"
99+
}
100+
101+
// MARK: - Actor
102+
103+
public actor CustomActor {}
104+
105+
// MARK: - Operators
106+
107+
public enum OperatorNamespace: String {
108+
case someValue = "1"
109+
110+
public static prefix func ++ (_ counter: OperatorNamespace) -> String {
111+
counter.rawValue
112+
}
113+
114+
public static postfix func ++ (_ counter: OperatorNamespace) -> String {
115+
counter.rawValue
116+
}
117+
}
118+
119+
// MARK: Infix operator with custom precedencegroup
120+
121+
postfix operator &&
122+
prefix operator &&
123+
124+
infix operator &&: CustomPrecedence
125+
126+
precedencegroup CustomPrecedence {
127+
higherThan: AdditionPrecedence
128+
lowerThan: MultiplicationPrecedence
129+
assignment: false
130+
associativity: left
131+
}
132+
133+
// MARK: - Enums
134+
135+
public enum CustomEnum {
136+
case normalCase
137+
case caseWithString(String)
138+
case caseWithTuple(String, Int)
139+
case caseWithBlock((Int) throws -> Void)
140+
141+
indirect case recursive(CustomEnum)
142+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// swift-tools-version: 5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "ReferencePackage",
8+
platforms: [.iOS(.v17)],
9+
products: [
10+
// Products define the executables and libraries a package produces, making them visible to other packages.
11+
.library(
12+
name: "ReferencePackage",
13+
targets: ["ReferencePackage"]
14+
)
15+
],
16+
targets: [
17+
// Targets are the basic building blocks of a package, defining a module or a test suite.
18+
// Targets can depend on other targets in this package and products from dependencies.
19+
.target(
20+
name: "ReferencePackage")
21+
]
22+
)

0 commit comments

Comments
 (0)