Skip to content

Added Build Tool Plug-ins support - #784

Merged
kwridan merged 3 commits into
tuist:mainfrom
BarredEwe:feature/build-tool-plugin
Jul 27, 2023
Merged

Added Build Tool Plug-ins support#784
kwridan merged 3 commits into
tuist:mainfrom
BarredEwe:feature/build-tool-plugin

Conversation

@BarredEwe

@BarredEwe BarredEwe commented Jul 11, 2023

Copy link
Copy Markdown
Contributor

Short description 📝

This is a continuation of #733, to support Build Tool Plug-ins. (Thanks to @technocidal)

Solution 📦

Added the difference between plugins and dependencies. Added correction of temporary identifiers for plugins.

Implementation 👩‍💻👨‍💻

  • Now we can separate the Dependency from plug-in:
// file: XCSwiftPackageProductDependency

/// Is it a Plugin.
var isPlugin: Bool {
    productName.hasPrefix("plugin:")
}
  • After separation, we need to fix TEMP identifiers:
// file: ReferenceGenerator

// Build Tool Plug-ins
target.dependencies.forEach {
    guard let product = $0.product, product.isPlugin else { return }

    var identifiers = identifiers
    identifiers.append(product.productName)
    fixReference(for: product, identifiers: identifiers)
}
  • And of course, some tests for classes: ReferenceGenerator, XCSwiftPackageProductDependency

@netlify

netlify Bot commented Jul 11, 2023

Copy link
Copy Markdown

Deploy Preview for xcodeproj ready!

Name Link
🔨 Latest commit 371857a
🔍 Latest deploy log https://app.netlify.com/sites/xcodeproj/deploys/64b1291a8cc6fa0008da27f7
😎 Deploy Preview https://deploy-preview-784--xcodeproj.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@BarredEwe

BarredEwe commented Jul 11, 2023

Copy link
Copy Markdown
Contributor Author

You can try how it works with XcodeGen 😊: Usage

@VVannafly

Copy link
Copy Markdown

cool

@kwridan kwridan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up @BarredEwe 🙏

I ran a small test locally by creating a project with a build plugin in Xcode then attempted to read / write the project using this PR and noticed the following diffs:

(left is vanilla Xcode, right is the one from XcodeProj)

diff-2
diff-1

I believe the productName needs to remove the plugin: prefix (and use that to infer isPlugin and only add it back when serialising productName in the XCSwiftPackageProductDependency section.

Comment thread Sources/XcodeProj/Objects/SwiftPackage/XCSwiftPackageProductDependency.swift Outdated
@BarredEwe
BarredEwe force-pushed the feature/build-tool-plugin branch from b5a80ee to bd3882a Compare July 14, 2023 08:32
@BarredEwe

BarredEwe commented Jul 14, 2023

Copy link
Copy Markdown
Contributor Author

@kwridan Thanks for reviewing 😊
I noticed it too, but I didn't pay attention. I have already corrected and posted the changes.

Here is what is generated now when adding a plugin:

dependencies = (
    975D5D662A613C2200317422 /* PBXTargetDependency */,
);
975D5D662A613C2200317422 /* PBXTargetDependency */ = {
    isa = PBXTargetDependency;
    productRef = 975D5D652A613C2200317422 /* SomePluginName */;
};
975D5D652A613C2200317422 /* SomePluginName */ = {
    isa = XCSwiftPackageProductDependency;
    productName = "plugin:SomePluginName";
};

As far as I've been able to verify, this is exactly the same as what Xcode generates.

@kwridan kwridan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @BarredEwe

Comment thread Sources/XcodeProj/Objects/SwiftPackage/XCSwiftPackageProductDependency.swift Outdated
…pendency.swift


A more readable plugin definition

Co-authored-by: Kas <kwridan@users.noreply.github.com>

@kwridan kwridan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @BarredEwe

@BarredEwe

BarredEwe commented Jul 17, 2023

Copy link
Copy Markdown
Contributor Author

@pepicrft @yonaskolb Could you please review?)

@BarredEwe BarredEwe changed the title Added build tool plugin support Added Build Tool Plug-ins support Jul 19, 2023
@iteracticman

Copy link
Copy Markdown

Could someone from the core team (or whoever can make the Merge button turn green) please review this?

@yonaskolb yonaskolb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't been in this codebase in a while, but looks ok to me. Thanks @BarredEwe

@kwridan
kwridan merged commit 6e60fb5 into tuist:main Jul 27, 2023
@BarredEwe BarredEwe mentioned this pull request Aug 14, 2023
@mgray88

mgray88 commented Apr 25, 2024

Copy link
Copy Markdown

Is this functionality available in Tuist? I can't seem to find any documentation

Eta: Specifically I'm trying to integrate Cuckoo via SPM instead of cocoapods

@luispadron

Copy link
Copy Markdown
Collaborator

@mgray88 XcodeProj is used by Tuist but its not the only tool that uses this project. I'd open an issue in the Tuist repository

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.

7 participants