peripheryapp / periphery

A tool to identify unused code in Swift projects.
MIT License
5.26k stars 193 forks source link

Embedded Swift packages are not recognised anymore in 2.21.0 version #768

Closed amseddi closed 4 months ago

amseddi commented 4 months ago

To demonstrate this issue, I created a new project with an embedded Swift package: image

The embedded Swift package used to be recognised and could be analysed. Please find the output of the scan --setup command below:

Using periphery@2.21.0

➜  PeripherySPMIssue mint run periphery scan --setup
Welcome to Periphery!
This guided setup will help you select the appropriate configuration for your project.

* Inspecting project...

Select build targets to analyze:
? Delimit choices with a single space, e.g: 1 2 3, or 'all' to select all options
1 PeripherySPMIssue
> 

Using periphery@2.20.0

➜  PeripherySPMIssue mint run periphery scan --setup
Welcome to Periphery!
This guided setup will help you select the appropriate configuration for your project.

* Inspecting project...

Select build targets to analyze:
? Delimit choices with a single space, e.g: 1 2 3, or 'all' to select all options
1 EmbeddedPackage.EmbeddedPackage
2 PeripherySPMIssue
> 
ileitch commented 4 months ago

Can you check that these packages are also listed as package dependencies in the project settings?

amseddi commented 4 months ago

Can you check that these packages are also listed as package dependencies in the project settings?

It was not listed at first. And when I added it to the projects settings, the embedded package was included in the results of the scan command:

➜  PeripherySPMIssue mint run periphery scan --setup           
Welcome to Periphery!
This guided setup will help you select the appropriate configuration for your project.

* Inspecting project...

Select build targets to analyze:
? Delimit choices with a single space, e.g: 1 2 3, or 'all' to select all options
1 EmbeddedPackage.EmbeddedPackage
2 PeripherySPMIssue

Does this mean we mean we will need to add all local packages to the dependencies in the project settings?

ileitch commented 4 months ago

It does, yes.

Servus7 commented 3 months ago

We can't add our local package to project dependencies because Xcode denies it. The Package.swift is in the same root folder as it's example app.

ileitch commented 3 months ago

@Servus7 Is there any way you can restructure your project to workaround this? This sounds more like an Xcode issue. SPM support prior to 2.21.0 was very much a hack. It was implemented befofe Xcode's pbxproj explicitly declared SPM dependencies. 2.21.0 now only uses the explicit SPM dependecies declared in the pbxproj, which requires local packages to be added via the Xcode UI.