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 language mode support #1474

Open
wants to merge 4 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
19 changes: 10 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "0c8c0017d472c5597b7cc8792d28815383d1ad3b06694e0f377e0c0261862bd4",
"pins" : [
{
"identity" : "liveview-native-core-swift",
Expand All @@ -14,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
Expand All @@ -32,8 +33,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "40773cbaf8d71ed5357f297b1ba4073f5b24faaa",
"version" : "1.1.0"
"revision" : "bc92c4b27f9a84bfb498cdbfdf35d5a357e9161f",
"version" : "1.5.6"
}
},
{
Expand Down Expand Up @@ -77,8 +78,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax.git",
"state" : {
"revision" : "64889f0c732f210a935a0ad7cda38f77f876262d",
"version" : "509.1.1"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
{
Expand All @@ -104,10 +105,10 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "23cbf2294e350076ea4dbd7d5d047c1e76b03631",
"version" : "1.0.2"
"revision" : "770f990d3e4eececb57ac04a6076e22f8c97daeb",
"version" : "1.4.2"
}
}
],
"version" : 2
"version" : 3
}
16 changes: 3 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down Expand Up @@ -29,10 +29,10 @@ let package = Package(
.package(url: "https://github.com/apple/swift-async-algorithms", from: "0.1.0"),
.package(url: "https://github.com/liveview-native/liveview-native-core-swift.git", exact: "0.2.1"),

.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
.package(url: "https://github.com/swiftlang/swift-markdown.git", from: "0.2.0"),

.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "509.0.2"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),

.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.13.0"),
],
Expand Down Expand Up @@ -109,16 +109,6 @@ let package = Package(
),
dependencies: []
),

// Unfortunately, this tool cannot be a plugin due to limitations on network access.
// Once SwiftPM supports plugins with network access, this can become a plugin again.
.executableTarget(
name: "TutorialRepoGenerator",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Markdown", package: "swift-markdown"),
]
),

.macro(
name: "LiveViewNativeMacros",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,36 @@ import Foundation
@main
struct BuiltinRegistryGeneratorPlugin: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
guard let target = target as? SourceModuleTarget else { return [] }
guard let target = target as? SwiftSourceModuleTarget else { return [] }
let tool = try context.tool(named: "BuiltinRegistryGenerator")
let output = context.pluginWorkDirectory.appending("BuiltinRegistry+Views.swift")
let output = context.pluginWorkDirectoryURL.appending(path: "BuiltinRegistry+Views.swift")
let viewFiles = target.sourceFiles
.filter({ $0.path.string.starts(with: target.directory.appending("Views").string) })
.filter({ $0.url.pathComponents.starts(with: target.directoryURL.appending(path: "Views").pathComponents) })
.filter({ $0.type == .source })
.map(\.path)
.map(\.url)
let modifierFiles = target.sourceFiles
.filter({ $0.path.string.hasSuffix("_GeneratedModifiers.swift") })
.filter({ $0.url.lastPathComponent == "_GeneratedModifiers.swift" })
.filter({ $0.type == .source })
.map(\.path)
.map(\.url)
let arguments: [String] = [target.directoryURL.path(percentEncoded: false), output.path(percentEncoded: false)] +
viewFiles
.reduce(into: [String]()) { partialResult, url in
partialResult.append("--view")
partialResult.append(url.path(percentEncoded: false))
}
+ modifierFiles
.reduce(into: [String]()) { partialResult, url in
partialResult.append("--modifier")
partialResult.append(url.path(percentEncoded: false))
}
print(viewFiles)
print(modifierFiles)
print(arguments)
return [
.buildCommand(
displayName: tool.name,
executable: tool.path,
arguments: [target.directory.string, output.string] +
viewFiles
.reduce(into: [String]()) { partialResult, path in
partialResult.append("--view")
partialResult.append(path.string)
}
+ modifierFiles
.reduce(into: [String]()) { partialResult, path in
partialResult.append("--modifier")
partialResult.append(path.string)
},
executable: tool.url,
arguments: arguments,
environment: [:],
inputFiles: viewFiles + modifierFiles,
outputFiles: [output]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import Foundation
struct DocumentationExtensionGeneratorPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) throws {
let process = Process()
process.executableURL = URL(fileURLWithPath: try context.tool(named: "DocumentationExtensionGenerator").path.string)
process.executableURL = try context.tool(named: "DocumentationExtensionGenerator").url

let target = context.package.targets.first(where: { $0.name == "LiveViewNative" })! as! SourceModuleTarget
let target = context.package.targets.first(where: { $0.name == "LiveViewNative" })! as! SwiftSourceModuleTarget
let viewFiles = target.sourceFiles
.filter({ $0.path.string.starts(with: target.directory.appending("Views").string) })
.filter({ $0.url.pathComponents.starts(with: target.directoryURL.appending(path: "Views").pathComponents) })
.filter({ $0.type == .source })
.map(\.path)
.map(\.url)

process.arguments = arguments
+ viewFiles
.reduce(into: [String]()) { partialResult, path in
.reduce(into: [String]()) { partialResult, url in
partialResult.append("--view")
partialResult.append(path.string)
partialResult.append(url.path())
}

try process.run()
Expand Down
1 change: 1 addition & 0 deletions Sources/LiveViewNative/BuiltinRegistry+applyBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum _EventBinding: String {
}

extension BuiltinRegistry {
@MainActor
@ViewBuilder
static func applyBinding(
_ binding: _EventBinding,
Expand Down
4 changes: 2 additions & 2 deletions Sources/LiveViewNative/Coordinators/LiveConnectionError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import SwiftPhoenixClient
@preconcurrency import SwiftPhoenixClient

/// An error that occurred when connecting to a live view.
public enum LiveConnectionError: Error, LocalizedError {
Expand Down Expand Up @@ -43,7 +43,7 @@ public enum LiveConnectionError: Error, LocalizedError {
}
}

public enum InitialParseComponent: CustomStringConvertible {
public enum InitialParseComponent: CustomStringConvertible, Sendable {
case document
case csrfToken
case phxMain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public struct LiveSessionConfiguration {
self.reconnectBehavior = reconnectBehavior
}

public struct ReconnectBehavior {
let delay: ((_ tries: Int) -> TimeInterval)?
public struct ReconnectBehavior: Sendable {
let delay: (@Sendable (_ tries: Int) -> TimeInterval)?

public init(_ delay: @escaping (_ tries: Int) -> TimeInterval) {
public init(_ delay: @escaping @Sendable (_ tries: Int) -> TimeInterval) {
self.delay = delay
}

Expand Down
Loading
Loading