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

Migrate to Swift 6 #20

Merged
merged 3 commits into from
Sep 24, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '^15.2.0'
xcode-version: '^16.0.0'
- uses: actions/checkout@v4
- run: swift build -c ${{ matrix.configuration }} -Xswiftc -enable-testing
- run: swift build -c ${{ matrix.configuration }} -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc 6
podspec:
strategy:
matrix:
Expand All @@ -27,7 +27,7 @@ jobs:
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '^15.2.0'
xcode-version: '^16.0.0'
- uses: actions/checkout@v4
- run: bundle install
- run: bundle exec pod lib lint --platforms=${{ matrix.platform }} --configuration=${{ matrix.configuration }}
10 changes: 7 additions & 3 deletions BuildHelper/BuildHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1600;
TargetAttributes = {
63A746952AFDD742003FA3AC = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -219,6 +219,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -282,6 +283,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -312,6 +314,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -326,7 +329,7 @@
PRODUCT_BUNDLE_IDENTIFIER = jp.banjun.SwiftHotReload.BuildHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand All @@ -339,6 +342,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -353,7 +357,7 @@
PRODUCT_BUNDLE_IDENTIFIER = jp.banjun.SwiftHotReload.BuildHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Release;
};
Expand Down
5 changes: 3 additions & 2 deletions BuildHelper/Sources/BuildHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
// Release build is not disabled as BuildHelper.app is to be buildable for generating a mac helper app.
// TODO: BuildHelper may be separated into sub- spec/package
import Foundation
import Combine
@preconcurrency import Combine

@MainActor
public final class BuildHelper: ObservableObject {
let proxyBrowser = ProxyBrowser()

Expand All @@ -17,7 +18,7 @@ public final class BuildHelper: ObservableObject {
private var fileMonitor: FileMonitor? {
didSet {
Task {
fileMonitorCancellable = await fileMonitor?.$fileChanges.compactMap {$0}.sink { [weak self] _ in
fileMonitorCancellable = await fileMonitor?.fileChanges.compactMap {$0}.sink { [weak self] _ in
self?.reload()
}
}
Expand Down
5 changes: 4 additions & 1 deletion BuildHelper/Sources/BuildHelperApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct BuildHelperApp: SwiftUI.App {

struct ContentView: View {
@EnvironmentObject var buildHelper: BuildHelper
@State private var browserView: MCBrowserViewControllerView?

var body: some View {
VStack(spacing: 20) {
Expand All @@ -38,7 +39,9 @@ struct BuildHelperApp: SwiftUI.App {
Text("Date Reloaded" + "\n" + (buildHelper.dateReloaded?.formatted(date: .numeric, time: .complete) ?? "Never"))
.multilineTextAlignment(.center)

buildHelper.proxyBrowser.browserView
if let browserView { browserView } else { ProgressView().task {
browserView = await buildHelper.proxyBrowser.browserView()
}}
}
.padding()
}
Expand Down
23 changes: 13 additions & 10 deletions BuildHelper/Sources/ProxyBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
// Release build is not disabled as BuildHelper.app is to be buildable for generating a mac helper app.
// TODO: BuildHelper may be separated into sub- spec/package
import Foundation
import MultipeerConnectivity
@preconcurrency import MultipeerConnectivity
@testable import SwiftHotReload // NOTE: use internal methods. SPM does not allow overlapping sources for a single Package.swift
import SwiftUI

final actor ProxyBrowser {
@Published private(set) var runtimePeers: [RuntimePeer] = []
private let peerID: MCPeerID
private let session: MCSession
private let browser: MCNearbyServiceBrowser
private let sessionDelegate: SessionDelegate = .init()
let browserView: MCBrowserViewControllerView
private(set) var browserView: @Sendable () async -> MCBrowserViewControllerView

init(hostName: String = ProcessInfo().hostName, bundleID: String? = Env.shared.CFBundleIdentifier, processID: Int32 = ProcessInfo().processIdentifier) {
init(hostName: String = ProcessInfo().hostName, bundleID: String? = Env.host.CFBundleIdentifier, processID: Int32 = ProcessInfo().processIdentifier) {
let displayName = String("Client[\(hostName)] \(bundleID ?? "cli")(\(processID))".utf8.prefix(63))!
self.peerID = MCPeerID(displayName: displayName)
self.session = MCSession(peer: peerID, securityIdentity: nil, encryptionPreference: .required)
self.browser = MCNearbyServiceBrowser(peer: peerID, serviceType: MultipeerConnectivityConstants.serviceType)
self.browserView = MCBrowserViewControllerView(browser: browser, session: session)
let session = MCSession(peer: peerID, securityIdentity: nil, encryptionPreference: .required)
self.session = session
let browser = MCNearbyServiceBrowser(peer: peerID, serviceType: MultipeerConnectivityConstants.serviceType)
self.browser = browser
self.browserView = { await MCBrowserViewControllerView(browser: browser, session: session) }

// Task {
session.delegate = sessionDelegate
Expand Down Expand Up @@ -69,16 +72,16 @@ final actor ProxyBrowser {
}

private extension ProxyBrowser {
private final class SessionDelegate: NSObject, MCSessionDelegate {
unowned var owner: ProxyBrowser?
private final class SessionDelegate: NSObject, MCSessionDelegate, Sendable {
unowned nonisolated(unsafe) var owner: ProxyBrowser?
override init() { super.init() }

func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {
Task { await owner?.session(session, peer: peerID, didChange: state) }
Task { @Sendable in await self.owner?.session(session, peer: peerID, didChange: state) }
}

func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {
Task { await owner?.session(session, didReceive: data, fromPeer: peerID) }
Task { @Sendable in await self.owner?.session(session, didReceive: data, fromPeer: peerID) }
}

func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {
Expand Down
10 changes: 7 additions & 3 deletions Example/SwiftHotReloadExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1600;
TargetAttributes = {
63980F422AEA8DA50099B122 = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -209,6 +209,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -270,6 +271,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -297,6 +299,7 @@
CODE_SIGN_ENTITLEMENTS = SwiftHotReloadExample.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -325,7 +328,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
Expand All @@ -338,6 +341,7 @@
CODE_SIGN_ENTITLEMENTS = SwiftHotReloadExample.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -366,7 +370,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
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 = "1500"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 7 additions & 3 deletions FrameworkTarget/SwiftHotReload.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1600;
TargetAttributes = {
63980F702AEA93310099B122 = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -254,6 +254,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -318,6 +319,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -345,6 +347,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -375,7 +378,7 @@
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
Expand All @@ -386,6 +389,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -414,7 +418,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
Expand Down
Loading