Skip to content

Commit f4cd125

Browse files
committed
feat: Update package manifest
1 parent 86299d6 commit f4cd125

File tree

2 files changed

+107
-83
lines changed

2 files changed

+107
-83
lines changed

Package.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:5.6
22

33
import PackageDescription
44

55
let package = Package(
66
name: "swift-declarative-configuration",
7+
platforms: [
8+
.iOS(.v11),
9+
.macOS(.v10_13),
10+
.tvOS(.v11),
11+
.macCatalyst(.v13),
12+
.watchOS(.v4),
13+
],
714
products: [
815
.library(
916
name: "DeclarativeConfiguration",
@@ -57,7 +64,12 @@ let package = Package(
5764
]
5865
),
5966
.target(name: "FunctionalClosures"),
60-
.target(name: "FunctionalKeyPath"),
67+
.target(
68+
name: "FunctionalKeyPath",
69+
dependencies: [
70+
.target(name: "FunctionalModification")
71+
]
72+
),
6173
.target(name: "FunctionalModification"),
6274
.testTarget(
6375
name: "DeclarativeConfigurationTests",

README.md

Lines changed: 93 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
> **Note**:
2-
> The framework moved to https://github.com/capturecontext/swift-declarative-configuration
3-
41
# Swift Declarative Configuration
52

6-
[![SwiftPM 5.3](https://img.shields.io/badge/spm-5.3-ED523F.svg?style=flat)](https://swift.org/download/) [![@maximkrouk](https://img.shields.io/badge/contact-@maximkrouk-1DA1F2.svg?style=flat&logo=twitter)](https://twitter.com/maximkrouk)
3+
[![SwiftPM 5.6](https://img.shields.io/badge/swiftpm-5.6-ED523F.svg?style=flat)](https://swift.org/download/) ![Platforms](https://img.shields.io/badge/Platforms-iOS_11_|_macOS_10.13_|_tvOS_11_|_watchOS_4_|_Catalyst_13-ED523F.svg?style=flat) [![@capture_context](https://img.shields.io/badge/contact-@capturecontext-1DA1F2.svg?style=flat&logo=twitter)](https://twitter.com/capture_context)
74

85
Swift Declarative Configuration (SDC, for short) is a tiny library, that enables you to configure your objects in a declarative, consistent and understandable way, with ergonomics in mind. It can be used to configure any objects on any platform, including server-side-swift.
96

@@ -43,66 +40,65 @@ Swift Declarative Configuration (SDC, for short) is a tiny library, that enables
4340

4441
```swift
4542
class ImageViewController: UIViewController {
43+
let imageView: UIImageView = {
4644
let imageView = UIImageView()
45+
imageView.contentMode = .scaleAspectFit
46+
imageView.backgroundColor = .black
47+
imageView.layer.masksToBounds = true
48+
imageView.layer.cornerRadius = 10
49+
return imageView
50+
}()
4751

48-
override func loadView() {
49-
self.view = imageView
50-
}
51-
52-
override func viewDidLoad() {
53-
super.viewDidLoad()
54-
imageView.contentMode = .scaleAspectFit
55-
imageView.backgroundColor = .black
56-
imageView.layer.masksToBounds = true
57-
imageView.layer.cornerRadius = 10
58-
}
52+
override func loadView() {
53+
self.view = imageView
54+
}
5955
}
6056
```
6157

6258
### FunctionalConfigurator
6359

60+
> **Note:** This way is **recommended**, but remember, that custom types **MUST** implement initializer with no parameters even if the superclass already has it or you will get a crash otherwise.
61+
6462
```swift
6563
import FunctionalConfigurator
6664

6765
class ImageViewController: UIViewController {
68-
69-
let imageView = UIImageView { $0
70-
.contentMode(.scaleAspectFit)
71-
.backgroundColor(.black)
72-
.layer.masksToBounds(true)
73-
.layer.cornerRadius(10)
66+
let imageView = UIImageView { $0
67+
.contentMode(.scaleAspectFit)
68+
.backgroundColor(.black)
69+
.layer.scope { $0
70+
.masksToBounds(true)
71+
.cornerRadius(10)
7472
}
73+
}
7574

76-
override func loadView() {
77-
self.view = imageView
78-
}
79-
75+
override func loadView() {
76+
self.view = imageView
77+
}
8078
}
8179
```
8280

83-
**Note:** This way is **recommended**, but remember, that custom types **MUST** implement initializer with no parameters even if the superclass already has it or you will get a crash otherwise.
84-
8581
### FunctionalBuilder
8682

83+
> **Note:** This way is recommended too, and it is more **safe**, because it modifies existing objects.
84+
8785
```swift
8886
import FunctionalBuilder
8987

9088
class ImageViewController: UIViewController {
91-
let imageView = UIImageView().builder
92-
.contentMode(.scaleAspectFit)
93-
.backgroundColor(.black)
94-
.layer.masksToBounds(true)
95-
.layer.cornerRadius(10)
96-
.build()
89+
let imageView = UIImageView().builder
90+
.contentMode(.scaleAspectFit)
91+
.backgroundColor(.black)
92+
.layer.masksToBounds(true)
93+
.layer.cornerRadius(10)
94+
.build()
9795

98-
override func loadView() {
99-
self.view = imageView
100-
}
96+
override func loadView() {
97+
self.view = imageView
98+
}
10199
}
102100
```
103101

104-
Note: This way is recommended too, and it is more **safe**, because it modifies existing objects.
105-
106102
### FunctionalClosures
107103

108104
### No SDC
@@ -111,25 +107,25 @@ Note: This way is recommended too, and it is more **safe**, because it modifies
111107

112108
```swift
113109
public class TapGestureRecognizer: UITapGestureRecognizer {
114-
var onTapGesture: ((TapGestureRecognizer) -> Void)?
110+
var onTapGesture: ((TapGestureRecognizer) -> Void)?
115111

116-
init() {
117-
super.init(target: nil, action: nil)
118-
commonInit()
119-
}
112+
init() {
113+
super.init(target: nil, action: nil)
114+
commonInit()
115+
}
120116

121-
override public init(target: Any?, action: Selector?) {
122-
super.init(target: target, action: action)
123-
commonInit()
124-
}
117+
override public init(target: Any?, action: Selector?) {
118+
super.init(target: target, action: action)
119+
commonInit()
120+
}
125121

126-
private func commonInit() {
127-
self.addTarget(self, action: #selector(handleTap))
128-
}
122+
private func commonInit() {
123+
self.addTarget(self, action: #selector(handleTap))
124+
}
129125

130-
@objc private func handleTap(_ recognizer: TapGestureRecognizer) {
131-
onTapGesture?(recognizer)
132-
}
126+
@objc private func handleTap(_ recognizer: TapGestureRecognizer) {
127+
onTapGesture?(recognizer)
128+
}
133129
}
134130
```
135131

@@ -153,26 +149,26 @@ tapRecognizer.onTapGesture?(tapRecognizer)
153149

154150
```swift
155151
public class TapGestureRecognizer: UITapGestureRecognizer {
156-
@Handler<TapGestureRecognizer>
157-
var onTapGesture
152+
@Handler<TapGestureRecognizer>
153+
var onTapGesture
158154

159-
init() {
160-
super.init(target: nil, action: nil)
161-
commonInit()
162-
}
155+
init() {
156+
super.init(target: nil, action: nil)
157+
commonInit()
158+
}
163159

164-
override public init(target: Any?, action: Selector?) {
165-
super.init(target: target, action: action)
166-
commonInit()
167-
}
160+
override public init(target: Any?, action: Selector?) {
161+
super.init(target: target, action: action)
162+
commonInit()
163+
}
168164

169-
private func commonInit() {
170-
self.addTarget(self, action: #selector(handleTap))
171-
}
165+
private func commonInit() {
166+
self.addTarget(self, action: #selector(handleTap))
167+
}
172168

173-
@objc private func handleTap(_ recognizer: TapGestureRecognizer) {
174-
_onTapGesture(recognizer)
175-
}
169+
@objc private func handleTap(_ recognizer: TapGestureRecognizer) {
170+
_onTapGesture(recognizer)
171+
}
176172
}
177173
```
178174

@@ -197,9 +193,9 @@ Also you can create such an instance with `Configurator`:
197193

198194
```swift
199195
let tapRecognizer = TapGestureRecognizer { $0
200-
.$onTapGesture { recognizer in
201-
// ...
202-
}
196+
.$onTapGesture { recognizer in
197+
// ...
198+
}
203199
}
204200
```
205201

@@ -211,19 +207,29 @@ Customize any object by passing initial value to a builder
211207

212208
```swift
213209
let object = Builder(Object())
214-
.property.subproperty(value)
215-
.build() // Returns modified object
210+
.property.subproperty(value)
211+
.build() // Returns modified object
216212
```
217213

218214
For classes you can avoid returning a value by calling `apply` method, instead of `build`
219215

220216
```swift
221217
let _class = _Class()
222218
Builder(_class)
223-
.property.subproperty(value)
224-
.apply() // Returns Void
219+
.property.subproperty(value)
220+
.apply() // Returns Void
221+
```
222+
223+
In both Builders and Configurators you can use scoping
224+
225+
```swift
226+
let object = Object { $0
227+
.property.subproperty(value)
228+
}
225229
```
226230

231+
232+
227233
Conform your own types to `BuilderProvider` protocol to access builder property.
228234

229235
```swift
@@ -240,7 +246,7 @@ extension CLLocationCoordinate2D: BuilderProvider {}
240246
241247
#### DataSource
242248

243-
`OptiomalDataSource` and `DataSource` types are very similar to the `Handler`, but if `Handler<Input>` is kinda `OptionalDataSource<Input, Void>`, the second one may have different types of an output. Usage is similar, different types are provided just for better semantics.
249+
`OptionalDataSource` and `DataSource` types are very similar to the `Handler`, but if `Handler<Input>` is kinda `OptionalDataSource<Input, Void>`, the second one may have different types of an output. Usage is similar, different types are provided just for better semantics.
244250

245251
## Installation
246252

@@ -254,15 +260,21 @@ You can add DeclarativeConfiguration to an Xcode project by adding it as a packa
254260

255261
### Recommended
256262

257-
If you use SwiftPM for your project, you can add DeclarativeConfiguration to your package file. Also my advice will be to use SSH.
263+
If you use SwiftPM for your project structure, add DeclarativeConfiguration to your package file.
258264

259265
```swift
260-
.package(url: "git@github.com:makeupstudio/swift-declarative-configuration.git", .branch("main"))
266+
.package(
267+
url: "git@github.com:capturecontext/swift-declarative-configuration.git",
268+
.upToNextMinor(from: "0.3.0")
269+
)
261270
```
262-
or
271+
or via HTTPS
263272

264273
```swift
265-
.package(url: "git@github.com:makeupstudio/swift-declarative-configuration.git", .exact("0.2.0"))
274+
.package(
275+
url: "https://github.com:capturecontext/swift-declarative-configuration.git",
276+
.exact("0.3.0")
277+
)
266278
```
267279

268280
Do not forget about target dependencies:

0 commit comments

Comments
 (0)