Skip to content

Commit 1cfdc65

Browse files
committed
Fix Swift 6.2 build blockers and concurrency issues
1 parent 85568dc commit 1cfdc65

29 files changed

+713
-214
lines changed

.plan/IMPLEMENTATION_PLAN.md

Lines changed: 320 additions & 0 deletions
Large diffs are not rendered by default.

.swift-format

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version": 1,
3+
"lineLength": 120,
4+
"indentation": { "spaces": 4 },
5+
"tabWidth": 4,
6+
"maximumBlankLines": 1,
7+
"respectsExistingLineBreaks": true,
8+
"lineBreakBeforeControlFlowKeywords": false,
9+
"lineBreakBeforeEachArgument": false,
10+
"lineBreakBeforeEachGenericRequirement": false,
11+
"prioritizeKeepingFunctionOutputTogether": false,
12+
"indentConditionalCompilationBlocks": true,
13+
"lineBreakAroundMultilineExpressionChainComponents": false,
14+
"fileScopedDeclarationPrivacy": { "accessLevel": "private" },
15+
"indentSwitchCaseLabels": false,
16+
"spacesAroundRangeFormationOperators": false,
17+
"multiElementCollectionTrailingCommas": true,
18+
"rules": {
19+
"AllPublicDeclarationsHaveDocumentation": false,
20+
"AlwaysUseLiteralForEmptyCollectionInit": true,
21+
"AlwaysUseLowerCamelCase": true,
22+
"AmbiguousTrailingClosureOverload": true,
23+
"AvoidRetroactiveConformances": true,
24+
"BeginDocumentationCommentWithOneLineSummary": false,
25+
"DoNotUseSemicolons": true,
26+
"DontRepeatTypeInStaticProperties": true,
27+
"FileScopedDeclarationPrivacy": true,
28+
"FullyIndirectEnum": true,
29+
"GroupNumericLiterals": true,
30+
"IdentifiersMustBeASCII": true,
31+
"NeverForceUnwrap": true,
32+
"NeverUseForceTry": true,
33+
"NeverUseImplicitlyUnwrappedOptionals": true,
34+
"NoAccessLevelOnExtensionDeclaration": true,
35+
"NoAssignmentInExpressions": true,
36+
"NoBlockComments": true,
37+
"NoCasesWithOnlyFallthrough": true,
38+
"NoEmptyLinesOpeningClosingBraces": true,
39+
"NoEmptyTrailingClosureParentheses": true,
40+
"NoLabelsInCasePatterns": true,
41+
"NoLeadingUnderscores": false,
42+
"NoParensAroundConditions": true,
43+
"NoPlaygroundLiterals": true,
44+
"NoVoidReturnOnFunctionSignature": true,
45+
"OmitExplicitReturns": false,
46+
"OneCasePerLine": true,
47+
"OneVariableDeclarationPerLine": true,
48+
"OnlyOneTrailingClosureArgument": true,
49+
"OrderedImports": true,
50+
"ReplaceForEachWithForLoop": true,
51+
"ReturnVoidInsteadOfEmptyTuple": true,
52+
"TypeNamesShouldBeCapitalized": true,
53+
"UseEarlyExits": false,
54+
"UseExplicitNilCheckInConditions": false,
55+
"UseLetInEveryBoundCaseVariable": true,
56+
"UseShorthandTypeNames": true,
57+
"UseSingleLinePropertyGetter": true,
58+
"UseSynthesizedInitializer": false,
59+
"UseTripleSlashForDocumentationComments": true,
60+
"UseWhereClausesInForLoops": false,
61+
"ValidateDocumentationComments": false
62+
}
63+
}

Pasitea.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@
679679
PRODUCT_BUNDLE_IDENTIFIER = studio.aemi.ada23.Pasitea;
680680
PRODUCT_NAME = "$(TARGET_NAME)";
681681
SWIFT_EMIT_LOC_STRINGS = YES;
682-
SWIFT_VERSION = 5.0;
682+
SWIFT_VERSION = 6.2;
683683
TARGETED_DEVICE_FAMILY = "1,2";
684684
};
685685
name = Debug;
@@ -712,7 +712,7 @@
712712
PRODUCT_BUNDLE_IDENTIFIER = studio.aemi.ada23.Pasitea;
713713
PRODUCT_NAME = "$(TARGET_NAME)";
714714
SWIFT_EMIT_LOC_STRINGS = YES;
715-
SWIFT_VERSION = 5.0;
715+
SWIFT_VERSION = 6.2;
716716
TARGETED_DEVICE_FAMILY = "1,2";
717717
};
718718
name = Release;

Pasitea/Model/TopBarIconSet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct TopBarIconSet: OptionSet {
1111
let rawValue: Int
1212

1313
static let close = TopBarIconSet(rawValue: 1 << 0)
14-
static let info = TopBarIconSet(rawValue: 1 << 1)
15-
static let add = TopBarIconSet(rawValue: 1 << 2)
14+
static let info = TopBarIconSet(rawValue: 1 << 1)
15+
static let add = TopBarIconSet(rawValue: 1 << 2)
1616

1717
static let none: TopBarIconSet = []
1818
}

Pasitea/Model/TrackItem.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftUI
1111

1212
@Model
1313
public final class TrackItem: Identifiable {
14-
@Attribute(.unique) public let id: UUID
14+
@Attribute(.unique) public var id: UUID
1515
public var type: TrackType.RawValue = TrackType.none.rawValue
1616
public var desc: String = ""
1717
public var tags: [String] = []
@@ -48,7 +48,7 @@ public final class TrackItem: Identifiable {
4848
self.previousId = previousId ?? nil
4949
}
5050

51-
init(_ item: TrackItem ) {
51+
init(_ item: TrackItem) {
5252
self.id = UUID()
5353
self.type = item.type
5454
self.desc = item.desc
@@ -63,7 +63,7 @@ extension TrackItem {
6363
@Transient
6464
public var typeAsTrackType: TrackType {
6565
get {
66-
(TrackType(rawValue: self.type))!
66+
TrackType(rawValue: self.type) ?? .none
6767
}
6868
set(rawValue) {
6969
self.type = rawValue.rawValue

Pasitea/Model/TrackItemWrapper.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TrackItemWrapper {
1717

1818
public func reset(_ modelContext: ModelContext, tags: String...) -> TrackItemWrapper {
1919
for tag in tags {
20-
self.item.addTags( tag )
20+
self.item.addTags(tag)
2121
}
2222
self.item.endsNow().saveInto(modelContext)
2323
self.item = TrackItem(type: self.item.typeAsTrackType, previousId: self.item.previousId ?? self.item.id)
@@ -27,15 +27,15 @@ class TrackItemWrapper {
2727
public func startsNow(_ tags: String...) -> TrackItemWrapper {
2828
self.item.startsNow()
2929
for tag in tags {
30-
self.item.addTags( tag )
30+
self.item.addTags(tag)
3131
}
3232
return self
3333
}
3434

3535
public func endsNow(_ tags: String...) -> TrackItemWrapper {
3636
self.item.startsNow()
3737
for tag in tags {
38-
self.item.addTags( tag )
38+
self.item.addTags(tag)
3939
}
4040
return self
4141
}

Pasitea/PasiteaApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Created by Guillaume Coquard on 16/10/23.
66
//
77

8-
import SwiftUI
98
import SwiftData
9+
import SwiftUI
1010

1111
@main
1212
struct PasiteaApp: App {
@@ -16,7 +16,7 @@ struct PasiteaApp: App {
1616

1717
init() {
1818
do {
19-
container = try ModelContainer( for: TrackItem.self )
19+
container = try ModelContainer(for: TrackItem.self)
2020
} catch {
2121
#if DEBUG
2222
print(error.localizedDescription)

Pasitea/View/Calm/Calm - 5 Steps/CalmSingleStepView.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ struct CalmSingleStepView: View {
5353
}
5454
Spacer(minLength: 16)
5555
HStack(alignment: .center) {
56-
(
57-
calmStep.id != 4
58-
? Button("Next", systemImage: "arrow.right.circle.fill") { currentStep = getNextScreen().wrappedValue }
59-
: Button("Finish", systemImage: "checkmark.circle.fill") { currentStep = getNextScreen().wrappedValue }
60-
)
61-
.pasiteaButtonStyle(.borderedProminent)
62-
.customHaptic(currentStep)
56+
(calmStep.id != 4
57+
? Button("Next", systemImage: "arrow.right.circle.fill") {
58+
currentStep = getNextScreen().wrappedValue
59+
}
60+
: Button("Finish", systemImage: "checkmark.circle.fill") {
61+
currentStep = getNextScreen().wrappedValue
62+
})
63+
.pasiteaButtonStyle(.borderedProminent)
64+
.customHaptic(currentStep)
6365
}
6466
.frame(height: 128)
6567
Spacer()

Pasitea/View/Calm/Calm - 5 Steps/CalmStepsView.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77

88
import Foundation
9-
import SwiftUI
109
import SwiftData
10+
import SwiftUI
1111

1212
struct CalmStepsView: View {
1313
@Environment(ModelData.self) private var modelData
@@ -48,7 +48,7 @@ struct CalmStepsView: View {
4848
GradientView()
4949

5050
VStack(spacing: 10) {
51-
CalmSingleStepView( step: $currentStep, getNextScreen: getNextScreen )
51+
CalmSingleStepView(step: $currentStep, getNextScreen: getNextScreen)
5252
}
5353

5454
VStack {
@@ -65,19 +65,20 @@ struct CalmStepsView: View {
6565
.fontDesign(.serif)
6666
.fontWeight(.bold)
6767
Group {
68-
Text("""
69-
The 5-4-3-2-1 method is a scientifically proven quick anxiety and stress reduction technique.
68+
Text(
69+
"""
70+
The 5-4-3-2-1 method is a scientifically proven quick anxiety and stress reduction technique.
7071
71-
To calm down:
72+
To calm down:
7273
73-
1. See: Identify 5 things around you.
74-
2. Touch: Acknowledge 4 things you can physically feel.
75-
3. Hear: Note 3 sounds in your environment.
76-
4. Smell: Focus on 2 scents.
77-
5. Taste: Experience 1 taste, like a sip of water.
74+
1. See: Identify 5 things around you.
75+
2. Touch: Acknowledge 4 things you can physically feel.
76+
3. Hear: Note 3 sounds in your environment.
77+
4. Smell: Focus on 2 scents.
78+
5. Taste: Experience 1 taste, like a sip of water.
7879
79-
Engaging your senses this way helps you stay present and reduce anxiety.
80-
""")
80+
Engaging your senses this way helps you stay present and reduce anxiety.
81+
""")
8182
}
8283
.multilineTextAlignment(.leading)
8384
.fontWeight(.medium)
@@ -91,7 +92,7 @@ Engaging your senses this way helps you stay present and reduce anxiety.
9192
.ultraThinInterface()
9293
.customCover(isPresented: $exerciseFinished, transition: .blur, animation: .easeInOut(duration: 2)) {
9394
CalmExerciseFinishedView(
94-
trackItem: TrackItem( trackItem ).endsNow(),
95+
trackItem: TrackItem(trackItem).endsNow(),
9596
dismiss: dismiss,
9697
customDismiss: customDismiss
9798
)

Pasitea/View/Calm/Calm - Breathe/BreatheFlowerAnimation.swift

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Created by Antonio Abbatiello on 25/10/23.
66
//
77

8-
import SwiftUI
98
import Combine
9+
import SwiftUI
1010

1111
struct BreatheFlowerAnimation: View {
1212
@Environment(\.modelContext) var modelContext
@@ -62,22 +62,22 @@ struct BreatheFlowerAnimation: View {
6262
ZStack {
6363
// Middle Left Petal - Second
6464
Image("flower")
65-
.rotationEffect(.degrees( isFlowerOpen ? -25 : -5), anchor: .bottom)
65+
.rotationEffect(.degrees(isFlowerOpen ? -25 : -5), anchor: .bottom)
6666

6767
// Middle Right Petal - Fourth
6868
Image("flower")
69-
.rotationEffect(.degrees( isFlowerOpen ? 25 : 5), anchor: .bottom)
69+
.rotationEffect(.degrees(isFlowerOpen ? 25 : 5), anchor: .bottom)
7070

7171
// Middle Petal - Third
7272
Image("flower")
7373

7474
// Left Petal - First
7575
Image("flower")
76-
.rotationEffect(.degrees( isFlowerOpen ? -50 : -10), anchor: .bottom)
76+
.rotationEffect(.degrees(isFlowerOpen ? -50 : -10), anchor: .bottom)
7777

7878
// Right Petal - Fifth
7979
Image("flower")
80-
.rotationEffect(.degrees( isFlowerOpen ? 50 : 10), anchor: .bottom)
80+
.rotationEffect(.degrees(isFlowerOpen ? 50 : 10), anchor: .bottom)
8181
}
8282
.shadow(radius: isFlowerOpen ? 20 : 0)
8383
.hueRotation(Angle(degrees: isFlowerOpen ? -170 : 0))
@@ -87,7 +87,8 @@ struct BreatheFlowerAnimation: View {
8787
ZStack {
8888
if !isDone {
8989
Group {
90-
Text( !isPreparing
90+
Text(
91+
!isPreparing
9192
? isRunning
9293
? "Breathe Out"
9394
: "Restart when you're ready"
@@ -111,29 +112,27 @@ struct BreatheFlowerAnimation: View {
111112
.fontWeight(.bold)
112113

113114
Button("Placeholder") {
114-
DispatchQueue.global(qos: .background).async {
115-
if isPreparing {
116-
isPreparing = false
117-
started = true
118-
} else if !isRunning {
119-
breatheCount = 0
120-
}
115+
if isPreparing {
116+
isPreparing = false
117+
started = true
118+
} else if !isRunning {
119+
breatheCount = 0
120+
}
121121

122-
isRunning.toggle()
122+
isRunning.toggle()
123123

124-
if isRunning {
125-
trackItem.startsNow()
126-
} else {
127-
trackItem.reset(modelContext, tags: self.breatheCount.description)
128-
}
124+
if isRunning {
125+
trackItem.startsNow()
126+
} else {
127+
trackItem.reset(modelContext, tags: breatheCount.description)
128+
}
129129

130-
withAnimation( flowerAnimation ) {
131-
isFlowerOpen.toggle()
132-
}
130+
withAnimation(flowerAnimation) {
131+
isFlowerOpen.toggle()
132+
}
133133

134-
withAnimation( textAnimation ) {
135-
isFlowerOpenForText.toggle()
136-
}
134+
withAnimation(textAnimation) {
135+
isFlowerOpenForText.toggle()
137136
}
138137
}
139138
.foregroundStyle(.clear)
@@ -142,10 +141,12 @@ struct BreatheFlowerAnimation: View {
142141
.background {
143142
GeometryReader { geo in
144143
ProgressView(value: Double(breatheCount), total: Double(numberOrBreathing)) {
145-
Label(isPreparing ? "Start" : isRunning ? "Stop" : "Restart",
146-
systemImage: isPreparing ? "play" : isRunning ? "stop" : "arrow.clockwise")
147-
.font(.title3)
148-
.fontWeight(.semibold)
144+
Label(
145+
isPreparing ? "Start" : isRunning ? "Stop" : "Restart",
146+
systemImage: isPreparing ? "play" : isRunning ? "stop" : "arrow.clockwise"
147+
)
148+
.font(.title3)
149+
.fontWeight(.semibold)
149150
}
150151
.onReceive(timer) { _ in
151152
if isRunning {

0 commit comments

Comments
 (0)