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

Unclear Readme #1

Open
BokaTano opened this issue May 29, 2024 · 4 comments
Open

Unclear Readme #1

BokaTano opened this issue May 29, 2024 · 4 comments

Comments

@BokaTano
Copy link

Hi, just saw your video.
This looks awesome!
How can I get it working, so that I can see warnings in Xcode? I do not fully understand the ReadMe. Do I need to add the RendererPlugin somewhere?
Thanks a lot 👏

@rock88
Copy link
Owner

rock88 commented May 30, 2024

Hi @BokaTano,

This repository contains two examples where you can see how to use this plugin: ExamplePackage and ExampleXcode (Plugin added to Xcode project, used tuist to generate Xcode project/workspace).

But let's add this plugin to the existing package, step by step. For example I want to add this plugin to The Composable Architecture, I will be using the latest version 1.10.4:

  1. First need to add PeripheryPlugin to the package dependency as a regular package (since ComposableArchitecture contains Package@swift-5.9.swift, I'll add the plugin there, but usually adding it to Package.swift is enough):
  dependencies: [
    .package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "1.1.0"),
    .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.1.0"),
+   .package(url: "https://github.com/rock88/PeripheryPlugin", from: "1.0.0"),
  ],

After resolving/reloading the package dependencies, you may see PeripheryPlugin in the package dependencies:
Screenshot 2024-05-30 at 21 23 00
2. Now need to build the whole package or some specific target (for creating an Index/DataStore), let's build swift-composable-architecture-Package:

Cmd+B (Trust and enable macros if necessary):

Screenshot 2024-05-30 at 21 29 41
  1. At this step we can run Periphery plugin, right click on the package and choose Periphery plugin from the PeripheryPlugin section:
Screenshot 2024-05-30 at 21 33 17

You can select some specific targets or all of them, let's select all and click Run:
Screenshot 2024-05-30 at 21 36 34

  1. In the Report Navigator tab, we can select the Package/Plug-in command invocation and see the Periphery output:
Screenshot 2024-05-30 at 21 42 43

This is all about basic integration. Also I have no idea how to pass this output into the ComposableArchitecture build output (I think it's not possible at the moment), so let's move on.

  1. To handle the output of Periphery during the ComposableArchitecture build phase and display all warnings in Xcode, need to add another plugin - PeripheryPlugin to the target.plugin section. Change Package@swift-5.9.swift as follows:
    .target(
      name: "ComposableArchitecture",
      dependencies: [
        ...
      ],
      resources: [
        .process("Resources/PrivacyInfo.xcprivacy")
-     ]
+     ],
+      plugins: [
+        .plugin(name: "PeripheryPlugin", package: "PeripheryPlugin")
+      ]
    ),
  1. Build again and the Periphery output should appear in Xcode (may have to run Periphery again or reopen the package to have Xcode apply the PeripheryPlugin to the ComposableArchitecture target):
Screenshot 2024-05-30 at 22 02 08
  1. For provide a config for the Periphery we can create a .periphery.yml at root directory of the package with the following content:
retain_public: true
disable_redundant_public_analysis: true
retain_codable_properties: true
Screenshot 2024-05-30 at 22 06 45

Run the Periphery plugin and build the package, we now see fewer warnings (48 vs 92):
Screenshot 2024-05-30 at 22 10 54

  1. For clean the Periphery output use the Periphery (Clean) plugin:
Screenshot 2024-05-30 at 22 12 48

As you can see, in order to see new warnings, you need to build the package, run the Periphery plugin manually and build the package again. This is intentional and I'm not sure that the Periphery will work correctly if converted it from a command to a buildTool plugin (due to changes in the Index/DataStore, the build time will also be affected).

This is all about PeripheryPlugins 😁

@BokaTano
Copy link
Author

BokaTano commented Jun 4, 2024

Hello 👋,
thanks so much for the energy you put into explaining.
Unfortunately my colleagues and I could not really figure out how to follow your guide. Perhaps because we have a simpler setup. Just a Xcode Project generated by Xcode.
We also can not see 7 of your screenshots. I guess they are not sourced remotely.

What we were able to do:

  1. Install periphery via homebrew and then the scan command in the terminal does work.
  2. We installed your plugin as a new package via this repo: https://github.com/rock88/PeripheryPlugin
  3. We ran the plugin via ctrl click on the project and our report tab, gave us "Activity Log Complete"
    Bildschirmfoto 2024-06-04 um 17 30 13

So where or what is the missing peace, that we can see the warnings in our project?
We tried cleaning, building, scaning, reopening Xcode in all different combinations :D

We also downloaded your example project and it did not work on our machines.

I hope we are not bothering, and thanks again for your interesting explanations :)

@rock88
Copy link
Owner

rock88 commented Jun 4, 2024

Hi @BokaTano,

Please make sure you select the Periphery command (not Periphery (Clean)).
After that, please attach the logs of the command invocation.

Currently, Periphery has one limitation that may prevent it from launching (if you use local Package.swift), all errors will be shown in the logs that I wrote about above.

@BokaTano
Copy link
Author

BokaTano commented Jun 7, 2024

On my machine I could not get further than invoking the plugin, it only gives the "Activity Log complete" when I close Xcode.

Plug-in command “Periphery”…_2024-06-07T10-46-56_2.txt

When my colleague has different logs I will add them :)

Edit: My colleagues also have the ever running plugin Problem.

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

No branches or pull requests

2 participants