periphery icon indicating copy to clipboard operation
periphery copied to clipboard

Run periphery for iOS-specific Swift Package

Open MarcoEidinger opened this issue 4 years ago • 10 comments

Hi,

I'd like to run periphery against a Swift package that is platform-specific to iOS and therefore should be built with xcodebuild and not swift build (which is chosen by periphery).

This Swift package does not have an Xcode project file as such cannot be generated with swift package generate-xcodeproj as the package uses binary targets.

Building this Swift package works with xcodebuild -scheme <PackageName> -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' build and therefore I was hoping that something similar like periphery scan -- -scheme <PackageName> -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' build would work but it doesn't :(

Is using periphery in such a scenario possible otherwise?

MarcoEidinger avatar Mar 12 '21 19:03 MarcoEidinger

Sorry for the late response. I did some digging into this, and it looks like it should be possible to support, though I haven't had time to finish off the implementation yet.

ileitch avatar Mar 27 '21 10:03 ileitch

@ileitch is there any update on this? Is there any way we can help? I would love to integrate periphery on our CI but this issue might be a blocker :\

MarcoCarnevali avatar Oct 26 '21 13:10 MarcoCarnevali

Sorry I've not looked into this any further. The first time I looked I think it looked like quite a lot of effort to implement. I've only had very limited time for Periphery recently, and I've spent that time focusing on fixing bugs. If this is blocking a lot of people, please speak up so that I can get a good signal how important this is.

ileitch avatar Dec 04 '21 20:12 ileitch

If this is blocking a lot of people, please speak up so that I can get a good signal how important this is.

Ideally I'd be able to do this, but it isn't exactly blocking.

tamc avatar Jan 31 '22 14:01 tamc

I am not using Periphery due to this limitation. I'd like to see this feature request comes to life but I understand that this might not happen if not enough people are interested in

MarcoEidinger avatar Jan 31 '22 21:01 MarcoEidinger

periphery scan -- -sdk iphonesimulator worked for me. (My workspace and scheme are specified in the .yml file)

aronhoff avatar Mar 01 '22 17:03 aronhoff

Thanks @aronhoff, that solution didn't work for me verbatim but it gave me inspiration to try some other build parameters.

I managed to get setup and working with this command:

swift run periphery scan --setup -- -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios15.0-simulator"

Of course, once setup (and the information is stored in the .yml file) then I can simply run swift periphery scan and it all works 🎉

Sherlouk avatar May 07 '22 15:05 Sherlouk

Had similar issue, but none of the above worked cuz Periphery was using swift build instead of xcodebuild. The way I solved it:

Build the SPM package manually via xcodebuild specifying iOS destination and derived data path:

xcodebuild -scheme MyScheme -destination 'platform=iOS Simulator,OS=15.5,name=iPhone 13 Pro' -derivedDataPath "../dd"

Then use the combination of --skip-build and --index-store-path to target the produced index store:

periphery scan --skip-build --index-store-path "../dd/Index/DataStore/"

V8tr avatar Jul 06 '22 13:07 V8tr

@V8tr Thank you, for this! Your solution works great.

david-palmer79 avatar Jul 11 '22 17:07 david-palmer79

@V8tr many thanks to as those instructions also work for me !!

@ileitch I raised a PR to add such explanation to the README.

MarcoEidinger avatar Jul 11 '22 22:07 MarcoEidinger