periphery
periphery copied to clipboard
Analysis across local swiftpm packages in xcodeproj
Can periphery support scanning across local SwiftPM Packages?
Test case
Example Project: PeripheryLocalPackage.zip
This project contains an xcodeproj with a mac app, which imports a local swiftPM package, and a couple of used & unused functions for testing periphery output.
periphery scan --project PeripheryLocalPackage.xcodeproj --targets PeripheryLocalPackage --schemes PeripheryLocalPackage
* No unused code detected.
.
I was hoping to have it detect the two unused functions in LocalPackage.swift
.
Scanning the individual package
cd LocalPackage; periphery scan;
Sources/LocalPackage/LocalPackage.swift:5:13: warning: Function 'unusedPublicFunction()' is unused
Sources/LocalPackage/LocalPackage.swift:9:6: warning: Function 'unusedInternalFunction()' is unused
Sources/LocalPackage/LocalPackage.swift:13:13: warning: Function 'usedPublicFunction()' is unused
Sources/LocalPackage/LocalPackage.swift:18:6: warning: Function 'usedInternalFunction()' is unused
cd LocalPackage; periphery scan --retain-public;
Sources/LocalPackage/LocalPackage.swift:9:6: warning: Function 'unusedInternalFunction()' is unused
Scanning the individual packages is insufficient as while we can --retain-public
to see the unused internal function, it cannot tell us if a public member is unused from the main target (or other modules), which is what we'd like to know.
Desired outcome from original test case:
LocalPackage/Sources/LocalPackage/LocalPackage.swift:5:13: warning: Function 'unusedPublicFunction()' is unused
LocalPackage/Sources/LocalPackage/LocalPackage.swift:9:6: warning: Function 'unusedInternalFunction()' is unused
Thanks for the detailed report, and the reproduction, @mjarvis. Yes I'm afraid Periphery doesn't support local packages yet, though I think it shouldn't be too hard to implement. I'll take a look when I next have some time.
Looking for this feature now, too! Thanks for the start, @ileitch !!
Looking forward to this being implemented 😁
YAY!
Should this work out of the box? It doesn't seem like it's looking in my local spm's :-) Do I need to add a parameter in my yml or something?