Skip to content

Commit

Permalink
Merge pull request #204 from cashapp/bradfol/single-package
Browse files Browse the repository at this point in the history
Revert back to single SPM package manifest
  • Loading branch information
bradfol authored Oct 2, 2024
2 parents 9ce3064 + 1ab8dd0 commit 91ee52a
Show file tree
Hide file tree
Showing 45 changed files with 63 additions and 117 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
git config user.email "noreply@github.com"
# Build the binary
swift build -c release --arch x86_64 --arch arm64 --product knit-cli --package-path CLI
mv CLI/.build/apple/Products/Release/knit-cli knit
swift build -c release --arch x86_64 --arch arm64 --product knit-cli
mv .build/apple/Products/Release/knit-cli knit
# Archive the repository
# Considerations:
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,3 @@ jobs:
run: swift build -v
- name: Run Knit tests
run: swift test -v

build-knit-cli:

runs-on: macos-latest

steps:
- uses: actions/checkout@v4.1.7
- uses: swift-actions/setup-swift@v2.1.0
with:
swift-version: "5.10"
- name: Build Knit CLI
run:
swift build -v --package-path CLI
- name: Run Knit CLI tests
run:
swift test -v --package-path CLI
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@ DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

#CLI Package
CLI/.build
CLI/.swiftpm/config/registries.json
CLI/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
24 changes: 0 additions & 24 deletions CLI/Package.resolved

This file was deleted.

42 changes: 0 additions & 42 deletions CLI/Package.swift

This file was deleted.

2 changes: 1 addition & 1 deletion CLI/README.md → Docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ along with source files.
For projects that do not have complex or custom build configurations, you can use the vended build plugin.
If your project has a complex build system or custom needs, please use the `knit-cli` executable.

1. Add the Package Dependency for Knit CLI to your Xcode project
1. Add the Package Dependency for Knit to your Xcode project
1. Add the vended plugin to both the main application target and unit test target (if it exists).
1. Create a `knitconfig.json` file and add it to the Xcode project (it does not need to be added to any targets).
36 changes: 18 additions & 18 deletions Example/KnitExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
2C360AEA2B4E1A2C00C88B99 /* Knit in Frameworks */ = {isa = PBXBuildFile; productRef = 2C360AE92B4E1A2C00C88B99 /* Knit */; };
2CF2570E2CACB3300017B59A /* Knit in Frameworks */ = {isa = PBXBuildFile; productRef = 2CF2570D2CACB3300017B59A /* Knit */; };
C40D0D1F2A838D140095AC59 /* KnitExampleUserAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40D0D1E2A838D140095AC59 /* KnitExampleUserAssembly.swift */; };
C43334F32A3FDD43003BA9E3 /* KnitExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43334F22A3FDD43003BA9E3 /* KnitExampleApp.swift */; };
C43334F52A3FDD43003BA9E3 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43334F42A3FDD43003BA9E3 /* ContentView.swift */; };
Expand Down Expand Up @@ -45,7 +45,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2C360AEA2B4E1A2C00C88B99 /* Knit in Frameworks */,
2CF2570E2CACB3300017B59A /* Knit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -129,11 +129,11 @@
buildRules = (
);
dependencies = (
2C1CC8BA2C76939F00B1CD49 /* PBXTargetDependency */,
2CF257102CACB3500017B59A /* PBXTargetDependency */,
);
name = KnitExample;
packageProductDependencies = (
2C360AE92B4E1A2C00C88B99 /* Knit */,
2CF2570D2CACB3300017B59A /* Knit */,
);
productName = KnitExample;
productReference = C43334EF2A3FDD43003BA9E3 /* KnitExample.app */;
Expand All @@ -150,7 +150,7 @@
buildRules = (
);
dependencies = (
2C1CC8BC2C7693A400B1CD49 /* PBXTargetDependency */,
2C579C7F2CACB92B00A26E71 /* PBXTargetDependency */,
C44755122A3FEA120072333A /* PBXTargetDependency */,
);
name = KnitExampleTests;
Expand Down Expand Up @@ -189,7 +189,7 @@
);
mainGroup = C43334E62A3FDD43003BA9E3;
packageReferences = (
2C1CC8B62C7692F000B1CD49 /* XCLocalSwiftPackageReference "../../knit" */,
2CF2570C2CACB3300017B59A /* XCLocalSwiftPackageReference "../../knit" */,
);
productRefGroup = C43334F02A3FDD43003BA9E3 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -243,13 +243,13 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
2C1CC8BA2C76939F00B1CD49 /* PBXTargetDependency */ = {
2C579C7F2CACB92B00A26E71 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 2C1CC8B92C76939F00B1CD49 /* KnitBuildPlugin */;
productRef = 2C579C7E2CACB92B00A26E71 /* KnitBuildPlugin */;
};
2C1CC8BC2C7693A400B1CD49 /* PBXTargetDependency */ = {
2CF257102CACB3500017B59A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 2C1CC8BB2C7693A400B1CD49 /* KnitBuildPlugin */;
productRef = 2CF2570F2CACB3500017B59A /* KnitBuildPlugin */;
};
C44755122A3FEA120072333A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
Expand Down Expand Up @@ -506,26 +506,26 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
2C1CC8B62C7692F000B1CD49 /* XCLocalSwiftPackageReference "../../knit" */ = {
2CF2570C2CACB3300017B59A /* XCLocalSwiftPackageReference "../../knit" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../../knit;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
2C1CC8B92C76939F00B1CD49 /* KnitBuildPlugin */ = {
2C579C7E2CACB92B00A26E71 /* KnitBuildPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = 2C1CC8B62C7692F000B1CD49 /* XCLocalSwiftPackageReference "../../knit" */;
package = 2CF2570C2CACB3300017B59A /* XCLocalSwiftPackageReference "../../knit" */;
productName = "plugin:KnitBuildPlugin";
};
2C1CC8BB2C7693A400B1CD49 /* KnitBuildPlugin */ = {
2CF2570D2CACB3300017B59A /* Knit */ = {
isa = XCSwiftPackageProductDependency;
package = 2C1CC8B62C7692F000B1CD49 /* XCLocalSwiftPackageReference "../../knit" */;
productName = "plugin:KnitBuildPlugin";
productName = Knit;
};
2C360AE92B4E1A2C00C88B99 /* Knit */ = {
2CF2570F2CACB3500017B59A /* KnitBuildPlugin */ = {
isa = XCSwiftPackageProductDependency;
productName = Knit;
package = 2CF2570C2CACB3300017B59A /* XCLocalSwiftPackageReference "../../knit" */;
productName = "plugin:KnitBuildPlugin";
};
/* End XCSwiftPackageProductDependency section */
};
Expand Down
7 changes: 6 additions & 1 deletion Example/KnitExample/KnitExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import Knit
@main
struct KnitExampleApp: App {

let resolver = ModuleAssembler([KnitExampleAssembly()]).resolver
let resolver: Resolver

@MainActor
init() {
resolver = ModuleAssembler([KnitExampleAssembly()]).resolver
}

var body: some Scene {
WindowGroup {
Expand Down
10 changes: 6 additions & 4 deletions Example/KnitExampleTests/TestModuleAssembler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import Knit
@testable import KnitExample

extension KnitExampleAssembly {
static func makeAssemblerForTests() -> Assembler {
Assembler([KnitExampleAssembly()])
@MainActor
static func makeAssemblerForTests() -> ModuleAssembler {
ModuleAssembler([KnitExampleAssembly()])
}

static func makeArgumentsForTests() -> KnitExampleRegistrationTestArguments {
Expand All @@ -23,7 +24,8 @@ extension KnitExampleAssembly {
}

extension KnitExampleUserAssembly {
static func makeAssemblerForTests() -> Assembler {
Assembler([KnitExampleUserAssembly(), KnitExampleAssembly()])
@MainActor
static func makeAssemblerForTests() -> ModuleAssembler {
ModuleAssembler([KnitExampleUserAssembly(), KnitExampleAssembly()])
}
}
32 changes: 29 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ let package = Package(
products: [
.library(name: "Knit", targets: ["Knit"]),
.plugin(name: "KnitBuildPlugin", targets: ["KnitBuildPlugin"]),
.executable(name: "knit-cli", targets: ["KnitCommand"]),
],
dependencies: [
.package(url: "https://github.com/Swinject/Swinject.git", from: "2.9.1"),
.package(url: "https://github.com/Swinject/SwinjectAutoregistration.git", from: "2.9.1"),
.package(name: "Knit-CLI", path: "CLI/"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "510.0.2"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.4.0"),
],
targets: [
.target(
Expand All @@ -30,14 +32,38 @@ let package = Package(
.testTarget(
name: "KnitTests",
dependencies: [
"Knit",
.target(name: "Knit"),
]
),
.plugin(
name: "KnitBuildPlugin",
capability: .buildTool,
dependencies: [
.product(name: "knit-cli", package: "Knit-CLI"),
.target(name: "KnitCommand"),
]
),

// MARK: - CLI
.executableTarget(
name: "KnitCommand",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.target(name: "KnitCodeGen"),
]
),
.target(
name: "KnitCodeGen",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
]
),
.testTarget(
name: "KnitCodeGenTests",
dependencies: [
"KnitCodeGen",
]
),
]
Expand Down
2 changes: 1 addition & 1 deletion Plugins/KnitBuildPlugin/KnitBuildPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extension XcodePluginContext {

return .buildCommand(
displayName: "Knit Plugin: Generate Knit files based on config \(configFilePath.description)",
executable: try self.tool(named: "knit-cli").path,
executable: try self.tool(named: "KnitCommand").path,
arguments: arguments,
inputFiles: assemblyInputPaths,
outputFiles: [typeSafetyOutputPath, unitTestOutputPath].compactMap { $0 }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 91ee52a

Please sign in to comment.