Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Build Tool Plug-ins support #784

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

BarredEwe
Copy link
Contributor

@BarredEwe BarredEwe commented Jul 11, 2023

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
Copy link

netlify bot commented Jul 11, 2023

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
Copy link
Contributor Author

BarredEwe commented Jul 11, 2023

You can try how it works with XcodeGen 😊: Usage

@VVannafly
Copy link

cool

Copy link
Collaborator

@kwridan kwridan left a comment

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.

@BarredEwe
Copy link
Contributor Author

BarredEwe commented Jul 14, 2023

@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.

Copy link
Collaborator

@kwridan kwridan left a comment

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

…pendency.swift


A more readable plugin definition

Co-authored-by: Kas <[email protected]>
Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

thanks @BarredEwe

@BarredEwe
Copy link
Contributor Author

BarredEwe commented Jul 17, 2023

@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

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

Copy link
Collaborator

@yonaskolb yonaskolb left a comment

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
9 checks passed
@BarredEwe BarredEwe mentioned this pull request Aug 14, 2023
@mgray88
Copy link

mgray88 commented Apr 25, 2024

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
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