Skip to content

Commit

Permalink
Update case studies to run in Swift 6 mode. (#3394)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw authored Sep 18, 2024
1 parent 6dc5f98 commit 52258dc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
18 changes: 7 additions & 11 deletions Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1150;
LastUpgradeCheck = 1520;
LastUpgradeCheck = 1600;
ORGANIZATIONNAME = "Point-Free";
TargetAttributes = {
CAF88E6F24B8E26D00539345 = {
Expand Down Expand Up @@ -880,7 +880,6 @@
CAF88E8C24B8E26E00539345 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = tvOSCaseStudies/Info.plist;
Expand All @@ -901,7 +900,6 @@
CAF88E8D24B8E26E00539345 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = tvOSCaseStudies/Info.plist;
Expand Down Expand Up @@ -960,7 +958,6 @@
DC4C6EC72450DD390066A05D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = UIKitCaseStudies/Info.plist;
Expand All @@ -980,7 +977,6 @@
DC4C6EC82450DD390066A05D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = UIKitCaseStudies/Info.plist;
Expand All @@ -1001,6 +997,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1063,6 +1060,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1128,7 +1126,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1146,15 +1144,14 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
DC89C43624460F96006900B9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = SwiftUICaseStudies/Info.plist;
Expand All @@ -1165,7 +1162,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICaseStudies.app/SwiftUICaseStudies";
};
Expand All @@ -1174,7 +1171,6 @@
DC89C43724460F96006900B9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = SwiftUICaseStudies/Info.plist;
Expand All @@ -1185,7 +1181,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICaseStudies.app/SwiftUICaseStudies";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extension DependencyValues {

private enum ScreenshotsKey: DependencyKey {
static let liveValue: @Sendable () async -> AsyncStream<Void> = {
await AsyncStream(
AsyncStream(
NotificationCenter.default
.notifications(named: UIApplication.userDidTakeScreenshotNotification)
.map { _ in }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct DownloadComponent {
@ObservableState
struct State: Equatable {
@Presents var alert: AlertState<Action.Alert>?
let id: AnyHashable
let id: AnyHashableSendable
var mode: Mode = .notDownloaded
let url: URL
}
Expand Down Expand Up @@ -185,7 +185,7 @@ struct DownloadComponentView: View {
DownloadComponentView(
store: Store(
initialState: DownloadComponent.State(
id: "deadbeef",
id: AnyHashableSendable("deadbeef"),
mode: .notDownloaded,
url: URL(fileURLWithPath: "/")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct CityMap {
init(download: Download) {
self.download = download
self.downloadComponent = DownloadComponent.State(
id: download.id,
id: AnyHashableSendable(download.id),
url: download.downloadVideoUrl
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ enum FavoritingAction {
struct Favoriting<ID: Hashable & Sendable> {
let favorite: @Sendable (ID, Bool) async throws -> Bool

private struct CancelID: Hashable {
let id: AnyHashable
private struct CancelID: Hashable, Sendable {
let id: AnyHashableSendable
}

var body: some Reducer<FavoritingState<ID>, FavoritingAction> {
Expand All @@ -55,7 +55,7 @@ struct Favoriting<ID: Hashable & Sendable> {
return .run { [id = state.id, isFavorite = state.isFavorite, favorite] send in
await send(.response(Result { try await favorite(id, isFavorite) }))
}
.cancellable(id: CancelID(id: state.id), cancelInFlight: true)
.cancellable(id: CancelID(id: AnyHashableSendable(state.id)), cancelInFlight: true)

case let .response(.failure(error)):
state.alert = AlertState { TextState(error.localizedDescription) }
Expand Down
7 changes: 7 additions & 0 deletions Examples/CaseStudies/SwiftUICaseStudies/FactClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ extension FactClient: DependencyKey {
/// to prove do not need the dependency.
static let testValue = Self()
}

struct AnyHashableSendable: Hashable, @unchecked Sendable {
let base: AnyHashable
init<Base: Hashable & Sendable>(_ base: Base) {
self.base = base
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = await TestStore(
initialState: DownloadComponent.State(
id: 1,
id: AnyHashableSendable(1),
mode: .notDownloaded,
url: URL(string: "https://www.pointfree.co")!
)
Expand Down Expand Up @@ -38,7 +38,7 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = await TestStore(
initialState: DownloadComponent.State(
id: 1,
id: AnyHashableSendable(1),
mode: .notDownloaded,
url: URL(string: "https://www.pointfree.co")!
)
Expand Down Expand Up @@ -80,7 +80,7 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = await TestStore(
initialState: DownloadComponent.State(
id: 1,
id: AnyHashableSendable(1),
mode: .notDownloaded,
url: URL(string: "https://www.pointfree.co")!
)
Expand Down Expand Up @@ -121,7 +121,7 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = await TestStore(
initialState: DownloadComponent.State(
id: 1,
id: AnyHashableSendable(1),
mode: .downloaded,
url: URL(string: "https://www.pointfree.co")!
)
Expand Down

0 comments on commit 52258dc

Please sign in to comment.