Skip to content

Commit 472e4a6

Browse files
authored
Merge pull request #19 from manucodin/develop
Refactors project structure and generators
2 parents b1bf05d + 943a93b commit 472e4a6

File tree

14 files changed

+56
-32
lines changed

14 files changed

+56
-32
lines changed

Package.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ let package = Package(
77
.macOS(.v12),
88
],
99
products: [
10-
.executable(
11-
name: "swift-mock-generator",
12-
targets: ["SwiftMockGenerator"]
13-
),
14-
.library(
15-
name: "SwiftMockGeneratorLib",
16-
targets: ["SwiftMockGeneratorLib"]
17-
),
10+
.executable(name: "swift-mock-generator", targets: ["SwiftMockGenerator"])
1811
],
1912
dependencies: [
2013
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
@@ -23,21 +16,15 @@ let package = Package(
2316
targets: [
2417
.executableTarget(
2518
name: "SwiftMockGenerator",
26-
dependencies: [
27-
"SwiftMockGeneratorLib",
28-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
29-
]
30-
),
31-
.target(
32-
name: "SwiftMockGeneratorLib",
3319
dependencies: [
3420
.product(name: "SwiftSyntax", package: "swift-syntax"),
3521
.product(name: "SwiftParser", package: "swift-syntax"),
22+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
3623
]
3724
),
3825
.testTarget(
3926
name: "SwiftMockGeneratorTests",
40-
dependencies: ["SwiftMockGeneratorLib"]
27+
dependencies: ["SwiftMockGenerator"]
4128
),
4229
]
4330
)

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,39 @@ make clean # Clean build artifacts
308308

309309
## 🔧 Integration
310310

311+
### Running from Xcode
312+
313+
The project can be opened and executed directly from Xcode for development and debugging purposes.
314+
315+
#### Opening the Project
316+
317+
1. **Open Xcode**
318+
2. **File → Open**
319+
3. **Select the `Package.swift` file** in the project root
320+
4. **Click "Open"**
321+
322+
#### Configuring the Execution Scheme
323+
324+
To run the project with custom arguments:
325+
326+
1. **Product → Scheme → Edit Scheme...**
327+
2. **In the "Run" tab:**
328+
- Ensure the **Executable** is set to `SwiftMockGenerator`
329+
3. **In the "Arguments" tab:**
330+
- Add command line arguments as needed:
331+
- `--input "./Examples/Sources"` (input directory)
332+
- `--output "./Examples/Mocks"` (output directory)
333+
- `--verbose` (enable detailed logging)
334+
- `--clean` (clean output directory before generation)
335+
- `--module "MyModule"` (specify module name for @testable import)
336+
- `--use-result` (use Result<T, Error> for async methods)
337+
338+
#### Running the Project
339+
340+
1. **Press Cmd+R** to build and run
341+
2. **Or use Product → Run** from the menu
342+
3. **Check the console output** for generation results
343+
311344
### Xcode Build Phase
312345

313346
Add a build phase script to automatically generate mocks:

Sources/SwiftMockGeneratorLib/DummyGenerator.swift renamed to Sources/SwiftMockGenerator/Generators/Implementations/DummyGenerator.swift

File renamed without changes.

Sources/SwiftMockGeneratorLib/SpyGenerator.swift renamed to Sources/SwiftMockGenerator/Generators/Implementations/SpyGenerator.swift

File renamed without changes.

Sources/SwiftMockGeneratorLib/MockGenerators.swift renamed to Sources/SwiftMockGenerator/Generators/Implementations/StubGenerator.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import Foundation
22

3-
// MARK: - Mock Generator Protocol
4-
5-
/// Protocol for different types of mock generators
6-
public protocol MockGeneratorProtocol {
7-
func generateMock(for element: CodeElement, annotation: MockAnnotation, useResult: Bool) throws -> String
8-
func generateMockDefinition(for element: CodeElement, annotation: MockAnnotation, useResult: Bool) throws -> String
9-
}
10-
113
// MARK: - Stub Generator
124

135
/// Generates stub implementations with default return values
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
// MARK: - Mock Generator Protocol
4+
5+
/// Protocol for different types of mock generators
6+
public protocol MockGeneratorProtocol {
7+
func generateMock(for element: CodeElement, annotation: MockAnnotation, useResult: Bool) throws -> String
8+
func generateMockDefinition(for element: CodeElement, annotation: MockAnnotation, useResult: Bool) throws -> String
9+
}
File renamed without changes.
File renamed without changes.

Sources/SwiftMockGenerator/main.swift renamed to Sources/SwiftMockGenerator/SwiftMockGenerator.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Foundation
22
import ArgumentParser
3-
import SwiftMockGeneratorLib
43

54
@main
65
struct SwiftMockGenerator: AsyncParsableCommand {

0 commit comments

Comments
 (0)