Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 13, 2025

This PR extends the PackageGeneratorPlugin to support all Swift Package Manager target types, addressing the limitation where only .target and .testTarget were previously supported.

Changes Made

Core Implementation

  • Added TargetType enum with support for all five target types: target, testTarget, executableTarget, systemLibrary, and binaryTarget
  • Enhanced ParsedPackage struct to include a targetType field with backward-compatible auto-detection based on the existing isTest flag
  • Updated target generation logic in fakeTargetToSwiftCode to generate appropriate Swift Package Manager target declarations

Smart Detection & Configuration

  • Auto-detection for executable targets: Automatically detects executable targets by checking for the presence of a main.swift file
  • Configuration override support: Added targetTypes configuration field allowing manual specification of target types for specific targets
  • Enhanced product generation: Generates .executable products for executable targets and .library products for regular targets, while excluding system libraries and binary targets from product generation

Validation & Error Handling

  • Configuration validation: Warns users about invalid target type values and unused target type configurations
  • Comprehensive error checking: Validates that specified target types are valid enum values

Documentation & Examples

Updated README with comprehensive documentation including:

  • Description of the new targetTypes configuration option
  • Example configuration showing how to specify different target types
  • Clear explanation of valid target type values

Example Usage

{
  "targetTypes": {
    "MyApp": "executableTarget",
    "SystemWrapper": "systemLibrary", 
    "PrecompiledFramework": "binaryTarget"
  },
  "targetsParameters": {
    "SystemWrapper": [
      "pkgConfig: \"libxml-2.0\"",
      "providers: [.brew([\"libxml2\"]), .apt([\"libxml2-dev\"])]"
    ]
  }
}

This generates appropriate Swift Package Manager declarations:

.executableTarget(name: "MyApp", dependencies: [...], path: "..."),
.systemLibrary(name: "SystemWrapper", path: "...", pkgConfig: "libxml-2.0", ...),
.binaryTarget(name: "PrecompiledFramework", path: "...")

Backward Compatibility

All existing configurations continue to work without modification. The implementation uses sensible defaults and maintains the existing behavior for projects that don't specify custom target types.

Fixes #8.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Sep 13, 2025

@mackoj 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

- Added TargetType enum with support for all 5 target types
- Updated ParsedPackage to include targetType field with auto-detection
- Modified target generation logic to support all target types
- Added configuration support via targetTypes field
- Auto-detects executable targets by checking for main.swift file
- Updated product generation for executable targets
- Added validation for target type configuration
- Updated documentation with examples

Co-authored-by: mackoj <[email protected]>
Copilot AI changed the title [WIP] Add support for other types of targets Add support for systemLibrary and executableTarget types Sep 13, 2025
Copilot AI requested a review from mackoj September 13, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for other types of targets

2 participants