Skip to content

Commit 4d2869c

Browse files
committed
Lower deployment targets
1 parent 1433f7f commit 4d2869c

File tree

8 files changed

+86
-131
lines changed

8 files changed

+86
-131
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
9919E4A62C1A185300B507E7 /* DecibelsAnalyzer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9919E4A52C1A185300B507E7 /* DecibelsAnalyzer.swift */; };
11-
9919E4A82C1A2F0F00B507E7 /* DecibelsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9919E4A72C1A2F0F00B507E7 /* DecibelsViewModel.swift */; };
1210
995EF5ED2B815F17000B5E39 /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 995EF5EC2B815F17000B5E39 /* ExampleApp.swift */; };
1311
995EF5F12B815F1C000B5E39 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 995EF5F02B815F1C000B5E39 /* Assets.xcassets */; };
1412
998CCB872BEABC03007E0F27 /* sample.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 998CCB862BEABC03007E0F27 /* sample.mp3 */; };
@@ -21,8 +19,6 @@
2119
/* End PBXBuildFile section */
2220

2321
/* Begin PBXFileReference section */
24-
9919E4A52C1A185300B507E7 /* DecibelsAnalyzer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecibelsAnalyzer.swift; sourceTree = "<group>"; };
25-
9919E4A72C1A2F0F00B507E7 /* DecibelsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecibelsViewModel.swift; sourceTree = "<group>"; };
2622
995EF5E92B815F17000B5E39 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
2723
995EF5EC2B815F17000B5E39 /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = "<group>"; };
2824
995EF5F02B815F1C000B5E39 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -74,8 +70,6 @@
7470
998CCB932BEABF26007E0F27 /* LocalFileView.swift */,
7571
999D3F652BED40A1005A0619 /* AudioControlsView.swift */,
7672
998CCB8E2BEABCFB007E0F27 /* OpenAI.swift */,
77-
9919E4A52C1A185300B507E7 /* DecibelsAnalyzer.swift */,
78-
9919E4A72C1A2F0F00B507E7 /* DecibelsViewModel.swift */,
7973
);
8074
path = Example;
8175
sourceTree = "<group>";
@@ -174,12 +168,10 @@
174168
buildActionMask = 2147483647;
175169
files = (
176170
998CCB942BEABF26007E0F27 /* LocalFileView.swift in Sources */,
177-
9919E4A82C1A2F0F00B507E7 /* DecibelsViewModel.swift in Sources */,
178171
998CCB922BEABCFB007E0F27 /* OpenAI.swift in Sources */,
179172
998CCB8F2BEABCFB007E0F27 /* TextToSpeechView.swift in Sources */,
180173
995EF5ED2B815F17000B5E39 /* ExampleApp.swift in Sources */,
181174
999D3F662BED40A1005A0619 /* AudioControlsView.swift in Sources */,
182-
9919E4A62C1A185300B507E7 /* DecibelsAnalyzer.swift in Sources */,
183175
998CCB962BEABFF9007E0F27 /* RootView.swift in Sources */,
184176
);
185177
runOnlyForDeploymentPostprocessing = 0;
@@ -326,10 +318,10 @@
326318
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
327319
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
328320
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
329-
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
321+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
330322
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
331323
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
332-
MACOSX_DEPLOYMENT_TARGET = 14.0;
324+
MACOSX_DEPLOYMENT_TARGET = 12.0;
333325
MARKETING_VERSION = 1.0;
334326
PRODUCT_BUNDLE_IDENTIFIER = "com.mseremet.chunked-audio-player-example";
335327
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -341,7 +333,7 @@
341333
SWIFT_EMIT_LOC_STRINGS = YES;
342334
SWIFT_VERSION = 5.0;
343335
TARGETED_DEVICE_FAMILY = "1,2,3,7";
344-
TVOS_DEPLOYMENT_TARGET = 17.0;
336+
TVOS_DEPLOYMENT_TARGET = 15.0;
345337
XROS_DEPLOYMENT_TARGET = 1.0;
346338
};
347339
name = Debug;
@@ -369,10 +361,10 @@
369361
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
370362
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
371363
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
372-
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
364+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
373365
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
374366
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
375-
MACOSX_DEPLOYMENT_TARGET = 14.0;
367+
MACOSX_DEPLOYMENT_TARGET = 12.0;
376368
MARKETING_VERSION = 1.0;
377369
PRODUCT_BUNDLE_IDENTIFIER = "com.mseremet.chunked-audio-player-example";
378370
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -384,7 +376,7 @@
384376
SWIFT_EMIT_LOC_STRINGS = YES;
385377
SWIFT_VERSION = 5.0;
386378
TARGETED_DEVICE_FAMILY = "1,2,3,7";
387-
TVOS_DEPLOYMENT_TARGET = 17.0;
379+
TVOS_DEPLOYMENT_TARGET = 15.0;
388380
XROS_DEPLOYMENT_TARGET = 1.0;
389381
};
390382
name = Release;

Example/Example/AudioControlsView.swift

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,46 @@ struct AudioControlButton: View {
3232
onTap()
3333
}
3434
} label: {
35-
image()
36-
.contentTransition(.symbolEffect(.replace))
35+
if #available(iOS 17.0, tvOS 17.0, macOS 14.0, *) {
36+
image()
37+
.contentTransition(.symbolEffect(.replace))
38+
} else {
39+
image()
40+
}
3741
}
3842
.buttonStyle(AudioControlButtonStyle())
3943
}
4044
}
4145

4246
struct AudioControlsView: View {
43-
let timeFormat = Duration.TimeFormatStyle(pattern: .minuteSecond(padMinuteToLength: 2))
44-
4547
@StateObject var player: AudioPlayer
4648
let onPlayPause: () -> Void
4749
let onStop: () -> Void
4850
let onRewind: () -> Void
4951
let onForward: () -> Void
5052

51-
private var currentTime: Duration {
52-
Duration.seconds(player.currentTime.seconds)
53+
private var currentTime: TimeInterval {
54+
player.currentTime.seconds
5355
}
5456

55-
private var currentDuration: Duration {
56-
Duration.seconds(player.currentDuration.seconds)
57+
private var currentDuration: TimeInterval {
58+
player.currentDuration.seconds
5759
}
5860

5961
private var formattedTime: String {
60-
currentTime.formatted(timeFormat) + " / " + currentDuration.formatted(timeFormat)
62+
if #available(iOS 16.0, tvOS 16.0, macOS 13.0, *) {
63+
let format = Duration.TimeFormatStyle(pattern: .minuteSecond(padMinuteToLength: 2))
64+
let formattedCurrentTime = Duration.seconds(currentTime).formatted(format)
65+
let formattedCurrentDuration = Duration.seconds(currentDuration).formatted(format)
66+
return formattedCurrentTime + " / " + formattedCurrentDuration
67+
} else {
68+
let formatter = DateComponentsFormatter()
69+
formatter.allowedUnits = [.minute, .second]
70+
formatter.zeroFormattingBehavior = .pad
71+
let formattedCurrentTime = formatter.string(from: currentTime)!
72+
let formattedCurrentDuration = formatter.string(for: currentDuration)!
73+
return formattedCurrentTime + " / " + formattedCurrentDuration
74+
}
6175
}
6276

6377
#if os(macOS)
@@ -78,8 +92,7 @@ struct AudioControlsView: View {
7892
}, onTap: onPlayPause)
7993
Text(formattedTime)
8094
.padding()
81-
.font(.headline.monospaced())
82-
.fontWeight(.bold)
95+
.font(.headline.monospaced().bold())
8396
.foregroundStyle(Color.primary.opacity(player.currentState.isActive ? 1.0 : 0.3))
8497
AudioControlButton(image: Image(systemName: "stop.fill"), onTap: onStop)
8598
.disabled(!player.currentState.isActive)

Example/Example/DecibelsAnalyzer.swift

Lines changed: 0 additions & 33 deletions
This file was deleted.

Example/Example/DecibelsViewModel.swift

Lines changed: 0 additions & 41 deletions
This file was deleted.

Example/Example/LocalFileView.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ struct LocalFileView: View {
5252
} message: {
5353
Text(errorMessage ?? "")
5454
}
55-
.onChange(of: player.currentError) { _, error in
55+
.onChange(of: player.currentError) { error in
5656
handleError(error)
5757
print("Error = \(error.flatMap { $0.debugDescription } ?? "nil")")
5858
}
59-
.onChange(of: player.currentTime) { _, time in
59+
.onChange(of: player.currentTime) { time in
6060
print("Time = \(time.seconds)")
6161
}
62-
.onChange(of: player.currentDuration) { _, duration in
62+
.onChange(of: player.currentDuration) { duration in
6363
print("Duration = \(duration.seconds)")
6464
}
65-
.onChange(of: player.currentRate) { _, rate in
65+
.onChange(of: player.currentRate) { rate in
6666
print("Rate = \(rate)")
6767
}
68-
.onChange(of: player.currentState) { _, state in
68+
.onChange(of: player.currentState) { state in
6969
print("State = \(state)")
7070
}
7171
#if os(iOS) || os(visionOS)
@@ -81,8 +81,7 @@ struct LocalFileView: View {
8181
} icon: {
8282
Image(systemName: "speaker.wave.2.circle.fill")
8383
}
84-
.font(.title3)
85-
.fontDesign(.monospaced)
84+
.font(.title3.monospaced())
8685
.multilineTextAlignment(.center)
8786
.lineLimit(nil)
8887
}

Example/Example/RootView.swift

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,28 @@ import SwiftUI
33
struct RootView: View {
44
var body: some View {
55
TabView {
6-
NavigationStack {
7-
TextToSpeechView()
8-
}.tabItem {
9-
Label("Remote", systemImage: "network")
10-
}
11-
NavigationStack {
12-
LocalFileView()
13-
}.tabItem {
14-
Label("Local", systemImage: "doc")
6+
if #available(iOS 16.0, tvOS 16.0, macOS 13.0, *) {
7+
NavigationStack {
8+
TextToSpeechView()
9+
}.tabItem {
10+
Label("Remote", systemImage: "network")
11+
}
12+
NavigationStack {
13+
LocalFileView()
14+
}.tabItem {
15+
Label("Local", systemImage: "doc")
16+
}
17+
} else {
18+
NavigationView {
19+
TextToSpeechView()
20+
}.tabItem {
21+
Label("Remote", systemImage: "network")
22+
}
23+
NavigationView {
24+
LocalFileView()
25+
}.tabItem {
26+
Label("Local", systemImage: "doc")
27+
}
1528
}
1629
}
1730
}

Example/Example/TextToSpeechView.swift

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct TextToSpeechView: View {
4747

4848
var body: some View {
4949
VStack(alignment: .center, spacing: 24) {
50-
inputTextField
50+
textInputView
5151
controlsView
5252
volumeView
5353
rateView
@@ -78,26 +78,30 @@ struct TextToSpeechView: View {
7878
apiKeyButton
7979
}
8080
ToolbarItem(placement: .navigation) {
81-
settingsMenu
82-
#if !os(macOS)
83-
.menuActionDismissBehavior(.disabled)
84-
#endif
81+
if #available(iOS 16.4, tvOS 16.4, macOS 13.3, *) {
82+
settingsMenu
83+
#if !os(macOS)
84+
.menuActionDismissBehavior(.disabled)
85+
#endif
86+
} else {
87+
settingsMenu
88+
}
8589
}
8690
}
87-
.onChange(of: player.currentError) { _, error in
91+
.onChange(of: player.currentError) { error in
8892
handleError(error)
8993
print("Error = \(error.flatMap { $0.debugDescription } ?? "nil")")
9094
}
91-
.onChange(of: player.currentTime) { _, time in
95+
.onChange(of: player.currentTime) { time in
9296
print("Time = \(time.seconds)")
9397
}
94-
.onChange(of: player.currentDuration) { _, duration in
98+
.onChange(of: player.currentDuration) { duration in
9599
print("Duration = \(duration.seconds)")
96100
}
97-
.onChange(of: player.currentRate) { _, rate in
101+
.onChange(of: player.currentRate) { rate in
98102
print("Rate = \(rate)")
99103
}
100-
.onChange(of: player.currentState) { _, state in
104+
.onChange(of: player.currentState) { state in
101105
print("State = \(state)")
102106
}
103107
#if os(iOS) || os(visionOS)
@@ -107,18 +111,26 @@ struct TextToSpeechView: View {
107111
}
108112

109113
@ViewBuilder
110-
private var inputTextField: some View {
111-
TextField("Enter your input", text: $text, axis: .vertical)
114+
private var textInputView: some View {
115+
inputTextField
112116
.focused($isFocused, equals: true)
113-
.font(.title3)
114-
.fontDesign(.monospaced)
117+
.font(.title3.monospaced())
115118
.multilineTextAlignment(.center)
116119
.lineLimit(nil)
117120
.submitLabel(.return)
118121
.autocorrectionDisabled()
119122
.modifier(Shake(animatableData: CGFloat(attempts)))
120123
}
121124

125+
@ViewBuilder
126+
private var inputTextField: some View {
127+
if #available(iOS 16.0, tvOS 16.0, macOS 13.0, *) {
128+
TextField("Enter your input", text: $text, axis: .vertical)
129+
} else {
130+
TextField("Enter your input", text: $text)
131+
}
132+
}
133+
122134
@ViewBuilder
123135
private var controlsView: some View {
124136
AudioControlsView(player: player) {

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import PackageDescription
44
let package = Package(
55
name: "swift-chunked-audio-player",
66
platforms: [
7-
.iOS(.v16),
7+
.iOS(.v15),
88
.macOS(.v12),
9-
.tvOS(.v16),
9+
.tvOS(.v15),
1010
.visionOS(.v1)
1111
],
1212
products: [

0 commit comments

Comments
 (0)