Skip to content

Commit

Permalink
Merge pull request #11 from cybozu/xcode-16
Browse files Browse the repository at this point in the history
Migrate to Xcode 16
  • Loading branch information
Kyome22 authored Dec 26, 2024
2 parents 1cd308e + 61db9c0 commit f8fda5c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-artifact-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: macos-14
timeout-minutes: 20
env:
DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer"
ARTIFACT_BUNDLE: "license-checker.artifactbundle"

steps:
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: macos-14
timeout-minutes: 20
env:
DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer"

steps:
- name: Checkout
Expand All @@ -25,9 +25,3 @@ jobs:
-destination "platform=macOS" \
-resultBundlePath TestsResult | \
xcpretty -c && exit ${PIPESTATUS[0]}
- name: Archive unit test results
if: success() || failure()
uses: kishikawakatsumi/xcresulttool@v1
with:
path: TestsResult.xcresult
18 changes: 13 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// swift-tools-version: 5.10
// swift-tools-version: 6.0

import PackageDescription

let swiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
]

let package = Package(
name: "LicenseChecker",
platforms: [
Expand All @@ -27,11 +31,13 @@ let package = Package(
dependencies: [
.target(name: "LicenseCheckerModule"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
]
],
swiftSettings: swiftSettings
),
.target(
name: "TestResources",
resources: [.copy("Resources/")]
resources: [.copy("Resources/")],
swiftSettings: swiftSettings
),
.testTarget(
name: "LicenseCheckerModuleTests",
Expand All @@ -41,14 +47,16 @@ let package = Package(
],
resources: [
.process("Resources")
]
],
swiftSettings: swiftSettings
),
.testTarget(
name: "LicenseCheckerTests",
dependencies: [
.target(name: "license-checker"),
.target(name: "TestResources")
]
],
swiftSettings: swiftSettings
),
.plugin(
name: "LicenseCheckerPlugin",
Expand Down
44 changes: 22 additions & 22 deletions Plugins/LicenseCheckerPlugin/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ struct LicenseCheckerPlugin: BuildToolPlugin {
let description: String = "SourcePackages not found"
}

func sourcePackages(_ pluginWorkDirectory: Path) throws -> Path {
var tmpPath = pluginWorkDirectory
guard pluginWorkDirectory.string.contains("SourcePackages") else {
func sourcePackages(_ pluginWorkDirectory: URL) throws -> URL {
var tmpURL = pluginWorkDirectory
guard pluginWorkDirectory.absoluteURL.path().contains("SourcePackages") else {
throw SourcePackagesNotFoundError()
}
while tmpPath.lastComponent != "SourcePackages" {
tmpPath = tmpPath.removingLastComponent()
while tmpURL.lastPathComponent != "SourcePackages" {
tmpURL = tmpURL.deletingLastPathComponent()
}
return tmpPath
return tmpURL
}

func makeBuildCommand(executablePath: Path, sourcePackagesPath: Path, whiteListPath: Path, outputPath: Path) -> Command {
return .buildCommand(
func makeBuildCommand(executableURL: URL, sourcePackagesURL: URL, whiteListURL: URL, outputURL: URL) -> Command {
.buildCommand(
displayName: "Check License",
executable: executablePath,
executable: executableURL,
arguments: [
"--source-packages-path",
sourcePackagesPath.string,
sourcePackagesURL.absoluteURL.path(),
"--white-list-path",
whiteListPath.string
whiteListURL.absoluteURL.path()
],
outputFiles: [
outputPath
outputURL
]
)
}

func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
return [
[
makeBuildCommand(
executablePath: try context.tool(named: "license-checker").path,
sourcePackagesPath: try sourcePackages(context.pluginWorkDirectory),
whiteListPath: context.package.directory.appending(subpath: "white-list.json"),
outputPath: context.pluginWorkDirectory
executableURL: try context.tool(named: "license-checker").url,
sourcePackagesURL: try sourcePackages(context.pluginWorkDirectoryURL),
whiteListURL: context.package.directoryURL.appending(path: "white-list.json"),
outputURL: context.pluginWorkDirectoryURL
)
]
}
Expand All @@ -53,12 +53,12 @@ import XcodeProjectPlugin
/// This command works with `Run Build Tool Plug-ins` in Xcode `Build Phase`.
extension LicenseCheckerPlugin: XcodeBuildToolPlugin {
func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] {
return [
[
makeBuildCommand(
executablePath: try context.tool(named: "license-checker").path,
sourcePackagesPath: try sourcePackages(context.pluginWorkDirectory),
whiteListPath: context.xcodeProject.directory.appending(subpath: "white-list.json"),
outputPath: context.pluginWorkDirectory
executableURL: try context.tool(named: "license-checker").url,
sourcePackagesURL: try sourcePackages(context.pluginWorkDirectoryURL),
whiteListURL: context.xcodeProject.directoryURL.appending(path: "white-list.json"),
outputURL: context.pluginWorkDirectoryURL
)
]
}
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ $

## Requirements

- Written in Swift 5.10
- Written in Swift 6.0
- Compatible with macOS 14.0+
- Development with Xcode 15.4+
- Development with Xcode 16.0+

## How to Use

Expand Down Expand Up @@ -147,10 +147,9 @@ If your project directory structure is special and you want to specify the path
@main
struct LicenseCheckerCommand: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) async throws {
let licenseCheckerPath = try context.tool(named: "license-checker").path
let commandURL = URL(fileURLWithPath: licenseCheckerPath.string, isDirectory: false)
let tool = try context.tool(named: "license-checker")

let process = try Process.run(commandURL, arguments: arguments)
let process = try Process.run(tool.url, arguments: arguments)
process.waitUntilExit()

guard process.terminationReason == .exit else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/license-checker/LicenseChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct LicenseChecker: ParsableCommand {
static let configuration = CommandConfiguration(
commandName: "license-checker",
abstract: "A tool to check license of swift package libraries.",
version: "1.0.0"
version: "2.0.0"
)

@Option(
Expand Down

0 comments on commit f8fda5c

Please sign in to comment.