maxchuquimia / xcgrapher

Framework-level dependency graph generator for Xcode projects - with support for custom graphing
101 stars 8 forks source link

Add Support to Local Swift Packages from SPM, Xcode Project & Workspaces #10

Open rogerluan opened 3 years ago

rogerluan commented 3 years ago

Description

This PR resolves #8

NOTE: This PR branches off of #7 , please review that one first. Since I can only work off of GitHub Forks, I can't point this PR to that other branch 😞

Discussion

Feel free to ask as many questions as needed @maxchuquimia 🙇 There're a looot of changes haha

Please don't mind about code style issues (issues that would be caught by a linter) right now. We can fix those as we move forward with the linter PR 👍

Resources

These docs have helped me a lot: https://www.rubydoc.info/gems/xcodeproj/

Demo

xcgrapher --workspace="SomeApp.xcworkspace" --scheme="SomeAppScheme" --spm && open /tmp/xcgrapher
image
maxchuquimia commented 3 years ago

Okay, I had a play with it in Xcode and looked at the diffs - seems it's almost there!

A couple of things still to do:

On this last point, I compared what happens after manually deleting XCGrapher's derived data while the project is open in Xcode and then running File > Swift Packages > Resolve Package Versions. For master it seems that doing this correctly (?) places a XCGrapherModuleImportPlugin.framework inside $DERIVED_DATA/Build/Products/PackageFrameworks but for this branch it does not... the only thing I can think that's changed is the addition of resource processing... have you got any ideas why this is now happening?

rogerluan commented 3 years ago

Podfile

Nice catch!

sample-package-description.json

😳 what a newb mistake! haha but after thinking it through, there's no way to really mock a real path, right? What do you recommend changing it to?

the addition of resource processing

Hum, that's a good hunch. That may be the case, yeah. Idk how to reproduce that issue you just mentioned, though, but we can move the .json sample file to a simple string in the codebase - so no resources. What do you think @maxchuquimia ? Could you test if that change makes it work for you?

maxchuquimia commented 3 years ago

Oh man I went down a massive rabbit hole of going through commits to see which one introduced the issue -turns out the .framework wasn't there just because I had the xcgrapher scheme selected instead of the xcgrapher-Package scheme when hitting Command+U 😂 🤦 . I'm guessing this came around as part of 2557e1ab2b0d6160ea7c302e4778207a69ebca04 - can we add a point to the "Development Notes" section of the ReadMe about needing this scheme selected?

Regarding the json - maybe put a token like $TEST_PATH in it instead of the URL and perform substitution of TEST_PATH to what you expect on the second line of PackageDescriptionTests.testInitialization()?

Now that I can actually run tests, there seems to be a common failure: in XCGrapherWorkspaceTests, testSomeAppSPM, testSomeAppPodsAndSPM, testSomeAppAppleAndSPM and testSomeAppAppleAndSPMAndPods are all failing with the same error:

image

Is there some additional setup I am maybe missing before it should work?

Also, I have noticed another issue: it seems --help no longer prints help... I think it might have something to do with the validate() arguments function having an else? Maybe we need to have die throw instead of exit or something...

rogerluan commented 3 years ago

Hey @maxchuquimia sorry for the radio silence, I've been busy lately (but also on vacation 😂 ) so I've been MIA and will still be for some time. Feel free to address necessary changes if/when you can, and I'll review/come back to this when I can 🙏

maxchuquimia commented 3 years ago

No problem @rogerluan, millions of things going on here too so I haven't done any coding over the weekends at all, think it's gonna be a while until I get a good chunk of time to do anything anyway hahah

mthole commented 2 years ago

@rogerluan @maxchuquimia Any chance of wrapping this up sometime soon? Looks very useful!

maxchuquimia commented 2 years ago

Well, I was able to make a bit of progress in resolving the outstanding issues... see progress.patch.txt (resolves test paths and help not being printed)

I can't seem to get the same result as the sample png in this PR's description - mine simply ignores the local dependency.. so not sure that this is ready to be merged yet

maxchuquimia commented 2 years ago

Well, I was able to make a bit of progress in resolving the outstanding issues... see progress.patch.txt (resolves test paths and help not being printed)

I can't seem to get the same result as the sample png in this PR's description - mine simply ignores the local dependency.. so not sure that this is ready to be merged yet

rogerluan commented 2 years ago

I don't remember what state I left this PR in @maxchuquimia 😅 I'd have to revisit it...