Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 6 #158

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions DatWeatherDoe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
20B468192793989B00FC6050 /* HumidityTextBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B468182793989B00FC6050 /* HumidityTextBuilder.swift */; };
20B4681B2793A7E300FC6050 /* TemperatureTextBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B4681A2793A7E300FC6050 /* TemperatureTextBuilder.swift */; };
20B468222793B85900FC6050 /* SystemLocationWeatherRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B468212793B85900FC6050 /* SystemLocationWeatherRepository.swift */; };
20B857362CC3304C0098DB1D /* UVIndexTextBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B857352CC3304C0098DB1D /* UVIndexTextBuilder.swift */; };
20B9CDCD27B8325900C42508 /* WeatherSourceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B9CDCC27B8325900C42508 /* WeatherSourceTests.swift */; };
20B9CDCF27B8335A00C42508 /* TemperatureUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B9CDCE27B8335A00C42508 /* TemperatureUnitTests.swift */; };
20B9CDD127B833EE00C42508 /* RefreshIntervalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B9CDD027B833EE00C42508 /* RefreshIntervalTests.swift */; };
Expand Down Expand Up @@ -140,6 +141,7 @@
20B468182793989B00FC6050 /* HumidityTextBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HumidityTextBuilder.swift; sourceTree = "<group>"; };
20B4681A2793A7E300FC6050 /* TemperatureTextBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemperatureTextBuilder.swift; sourceTree = "<group>"; };
20B468212793B85900FC6050 /* SystemLocationWeatherRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemLocationWeatherRepository.swift; sourceTree = "<group>"; };
20B857352CC3304C0098DB1D /* UVIndexTextBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UVIndexTextBuilder.swift; sourceTree = "<group>"; };
20B9CDCC27B8325900C42508 /* WeatherSourceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherSourceTests.swift; sourceTree = "<group>"; };
20B9CDCE27B8335A00C42508 /* TemperatureUnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemperatureUnitTests.swift; sourceTree = "<group>"; };
20B9CDD027B833EE00C42508 /* RefreshIntervalTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshIntervalTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -408,6 +410,7 @@
20B468182793989B00FC6050 /* HumidityTextBuilder.swift */,
E3105BA52818805A00FB4C55 /* SunriseAndSunsetTextBuilder.swift */,
20B46813279394FB00FC6050 /* WeatherTextBuilder.swift */,
20B857352CC3304C0098DB1D /* UVIndexTextBuilder.swift */,
);
path = Text;
sourceTree = "<group>";
Expand Down Expand Up @@ -580,7 +583,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1330;
LastUpgradeCheck = 1520;
LastUpgradeCheck = 1600;
ORGANIZATIONNAME = "Inder Dhir";
TargetAttributes = {
2023EDA21C4ED09C0087FD67 = {
Expand Down Expand Up @@ -695,6 +698,7 @@
201C6C4620262E380065E795 /* WeatherAPIResponse.swift in Sources */,
206E15252A7C4C5C0096D33C /* ConfigOptions.swift in Sources */,
2039B3E72C2896BD006A6B6D /* WindData.swift in Sources */,
20B857362CC3304C0098DB1D /* UVIndexTextBuilder.swift in Sources */,
2005C059278CB5FC0067BBD1 /* WeatherURLBuilder.swift in Sources */,
20D857122A831802005727BB /* ConfigureWeatherOptionsView.swift in Sources */,
20D8571D2A831F40005727BB /* WeatherRepositoryFactory.swift in Sources */,
Expand Down Expand Up @@ -797,7 +801,7 @@
SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -851,20 +855,19 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Release;
};
2023EDB11C4ED09C0087FD67 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = DatWeatherDoe/Resources/DatWeatherDoe.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 49;
CURRENT_PROJECT_VERSION = 50;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DatWeatherDoe/Resources/DevelopmentAssets\" \"DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift\"";
DEVELOPMENT_TEAM = Q8X4D3A8MT;
Expand All @@ -876,7 +879,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 5.2.1;
MARKETING_VERSION = 5.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.inderdhir.DatWeatherDoe.debug;
PRODUCT_NAME = DatWeatherDoe;
PROVISIONING_PROFILE = "";
Expand All @@ -888,13 +891,12 @@
2023EDB21C4ED09C0087FD67 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = DatWeatherDoe/Resources/DatWeatherDoe.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 49;
CURRENT_PROJECT_VERSION = 50;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DatWeatherDoe/Resources/DevelopmentAssets\" \"DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift\"";
DEVELOPMENT_TEAM = Q8X4D3A8MT;
Expand All @@ -906,7 +908,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 5.2.1;
MARKETING_VERSION = 5.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.inderdhir.DatWeatherDoe;
PRODUCT_NAME = DatWeatherDoe;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -988,32 +990,32 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/nicklockwood/SwiftFormat";
requirement = {
kind = exactVersion;
version = 0.54.0;
kind = upToNextMajorVersion;
minimumVersion = 0.54.0;
};
};
20012FA4267980EE00553B60 /* XCRemoteSwiftPackageReference "Reachability" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ashleymills/Reachability.swift";
requirement = {
kind = exactVersion;
version = 5.2.3;
kind = upToNextMajorVersion;
minimumVersion = 5.2.3;
};
};
2039B4052C2920BF006A6B6D /* XCRemoteSwiftPackageReference "MenuBarExtraAccess" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/orchetect/MenuBarExtraAccess";
requirement = {
kind = exactVersion;
version = 1.0.5;
kind = upToNextMajorVersion;
minimumVersion = 1.0.5;
};
};
20CB68BC2A2D9029001C73B9 /* XCRemoteSwiftPackageReference "SwiftLint" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/realm/SwiftLint";
requirement = {
kind = exactVersion;
version = 0.55.1;
kind = upToNextMajorVersion;
minimumVersion = 0.55.1;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0",
"version" : "1.8.2"
"revision" : "678d442c6f7828def400a70ae15968aef67ef52d",
"version" : "1.8.3"
}
},
{
"identity" : "menubarextraaccess",
"kind" : "remoteSourceControl",
"location" : "https://github.com/orchetect/MenuBarExtraAccess",
"state" : {
"revision" : "f5896b47e15e114975897354c7e1082c51a2bffd",
"version" : "1.0.5"
"revision" : "9ff6cbb0ba373527a19832a0791cea4a41ad7a6f",
"version" : "1.1.3"
}
},
{
"identity" : "reachability.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ashleymills/Reachability.swift",
"state" : {
"revision" : "7cbd73f46a7dfaeca079e18df7324c6de6d1834a",
"version" : "5.2.3"
"revision" : "21d1dc412cfecbe6e34f1f4c4eb88d3f912654a6",
"version" : "5.2.4"
}
},
{
Expand All @@ -51,35 +51,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"location" : "https://github.com/swiftlang/swift-syntax.git",
"state" : {
"revision" : "303e5c5c36d6a558407d364878df131c3546fad8",
"version" : "510.0.2"
"revision" : "515f79b522918f83483068d99c68daeb5116342d",
"version" : "600.0.0-prerelease-2024-08-14"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "dd989a46d0c6f15c016484bab8afe5e7a67a4022",
"version" : "0.54.0"
"revision" : "86ed20990585f478c0daf309af645c2a528b59d8",
"version" : "0.54.6"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint",
"state" : {
"revision" : "b515723b16eba33f15c4677ee65f3fef2ce8c255",
"version" : "0.55.1"
"revision" : "168fb98ed1f3e343d703ecceaf518b6cf565207b",
"version" : "0.57.0"
}
},
{
Expand All @@ -105,8 +105,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "9234124cff5e22e178988c18d8b95a8ae8007f76",
"version" : "5.1.2"
"revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",
"version" : "5.1.3"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -61,15 +61,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2023EDA21C4ED09C0087FD67"
BuildableName = "DatWeatherDoe.app"
BlueprintName = "DatWeatherDoe"
ReferencedContainer = "container:DatWeatherDoe.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
14 changes: 7 additions & 7 deletions DatWeatherDoe/API/Response/AirQuality.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ enum AirQualityIndex: Int, Decodable {
case hazardous = 6

var description: String {
switch self {
return switch self {
case .good:
return NSLocalizedString(
NSLocalizedString(
"Good",
comment: "Air quality index: Good"
)
case .moderate:
return NSLocalizedString(
NSLocalizedString(
"Moderate",
comment: "Air quality index: Moderate"
)
case .unhealthyForSensitive:
return NSLocalizedString(
NSLocalizedString(
"Unhealthy for sensitive groups",
comment: "Air quality index: Unhealthy for sensitive groups"
)
case .unhealthy:
return NSLocalizedString(
NSLocalizedString(
"Unhealthy",
comment: "Air quality index: Unhealthy"
)
case .veryUnhealthy:
return NSLocalizedString(
NSLocalizedString(
"Very unhealthy",
comment: "Air quality index: Very unhealthy"
)
case .hazardous:
return NSLocalizedString(
NSLocalizedString(
"Hazardous",
comment: "Air quality index: Hazardous"
)
Expand Down
6 changes: 6 additions & 0 deletions DatWeatherDoe/API/Response/ForecastData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
struct ForecastDayData: Decodable {
let temp: ForecastTemperatureData
let astro: SunriseSunsetData
let hour: [HourlyUVIndex]

private enum CodingKeys: String, CodingKey {
case temp = "day"
case astro
case hour
}
}

struct HourlyUVIndex: Decodable {
let uv: Double

Check warning on line 32 in DatWeatherDoe/API/Response/ForecastData.swift

View workflow job for this annotation

GitHub Actions / lint

Identifier Name Violation: Variable name 'uv' should be between 3 and 40 characters long (identifier_name)
}
11 changes: 11 additions & 0 deletions DatWeatherDoe/API/Response/WeatherAPIResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
)
}

let airQualityContainer = try currentContainer.nestedContainer(keyedBy: AirQualityKeys.self, forKey: .airQuality)

Check warning on line 87 in DatWeatherDoe/API/Response/WeatherAPIResponse.swift

View workflow job for this annotation

GitHub Actions / lint

Line Length Violation: Line should be 110 characters or less; currently it has 121 characters (line_length)
airQualityIndex = try airQualityContainer.decode(AirQualityIndex.self, forKey: .usEpaIndex)
}

Expand All @@ -109,4 +109,15 @@
self.forecastDayData = forecastDayData
self.airQualityIndex = airQualityIndex
}

// hour = [0-23]
func getHourlyUVIndex(hour: Int) -> Double {
forecastDayData.hour[safe: hour]?.uv ?? uvIndex
}
}

private extension Array {
subscript(safe index: Index) -> Element? {
get { indices ~= index ? self[index] : nil }

Check warning on line 121 in DatWeatherDoe/API/Response/WeatherAPIResponse.swift

View workflow job for this annotation

GitHub Actions / lint

Implicit Getter Violation: Computed read-only subscripts should avoid using the get keyword (implicit_getter)
}
}
5 changes: 5 additions & 0 deletions DatWeatherDoe/Config/ConfigManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protocol ConfigManagerType: AnyObject {
var refreshInterval: TimeInterval { get set }
var isShowingWeatherIcon: Bool { get set }
var isShowingHumidity: Bool { get set }
var isShowingUVIndex: Bool { get set }
var isRoundingOffData: Bool { get set }
var isUnitLetterOff: Bool { get set }
var isUnitSymbolOff: Bool { get set }
Expand Down Expand Up @@ -47,6 +48,9 @@ final class ConfigManager: ConfigManagerType {

@AppStorage("isShowingHumidity")
public var isShowingHumidity = false

@AppStorage("isShowingUVIndex")
public var isShowingUVIndex = false

@AppStorage("isRoundingOffData")
public var isRoundingOffData = false
Expand Down Expand Up @@ -74,6 +78,7 @@ final class ConfigManager: ConfigManagerType {
func setConfigOptions(_ options: ConfigOptions) {
refreshInterval = options.refreshInterval.rawValue
isShowingHumidity = options.isShowingHumidity
isShowingUVIndex = options.isShowingUVIndex
isRoundingOffData = options.isRoundingOffData
isUnitLetterOff = options.isUnitLetterOff
isUnitSymbolOff = options.isUnitSymbolOff
Expand Down
1 change: 1 addition & 0 deletions DatWeatherDoe/Config/ConfigOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
struct ConfigOptions {
let refreshInterval: RefreshInterval
let isShowingHumidity: Bool
let isShowingUVIndex: Bool
let isRoundingOffData: Bool
let isUnitLetterOff: Bool
let isUnitSymbolOff: Bool
Expand Down
11 changes: 10 additions & 1 deletion DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

import Foundation

let uvIndicesFor24Hours: [HourlyUVIndex] = {
var arr: [HourlyUVIndex] = []
for i in 1...24 {

Check failure on line 13 in DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift

View workflow job for this annotation

GitHub Actions / lint

Identifier Name Violation: Variable name 'i' should be between 3 and 40 characters long (identifier_name)
arr.append(HourlyUVIndex(uv: 0))
}
return arr
}()

let response = WeatherAPIResponse(
locationName: "New York City",
temperatureData: .init(
Expand All @@ -25,7 +33,8 @@
temp: .init(
maxTempC: 32.8, maxTempF: 91.0, minTempC: 20.6, minTempF: 69.2
),
astro: .init(sunrise: "05:26 AM", sunset: "08:31 PM")
astro: .init(sunrise: "05:26 AM", sunset: "08:31 PM"),
hour: uvIndicesFor24Hours
),
airQualityIndex: .good
)
Loading
Loading