xcgrapher icon indicating copy to clipboard operation
xcgrapher copied to clipboard

Let's add the possibility to set custom checkoutsDir

Open salyasev opened this issue 3 years ago • 18 comments

faced with the issue because have custom pods_install steps with moving folders Got message: [main] The folder “checkouts” doesn’t exist.

Seems need a param for setting let checkoutsDir = derivedDataDir.appending("/SourcePackages/checkouts")

salyasev avatar Apr 19 '21 12:04 salyasev

Ah okay, this sounds like a good idea - are you able to share your pod install steps so that I can test before releasing?

maxchuquimia avatar Apr 19 '21 22:04 maxchuquimia

Hi, i'm facing same issue. Is there a temp code change that I can make until this fix is released?

shahzadmajeed avatar Jul 05 '21 04:07 shahzadmajeed

Hu @shahzadmajeed, I haven't started work on this as I'm not sure how these custom pods steps work. If you're able to give me an example of the code that changes the pods checkout directory then I can take a look!

maxchuquimia avatar Jul 05 '21 06:07 maxchuquimia

@maxchuquimia in my case the problem was SPM checkouts that Xcode put under deriveddata directory for example

/Users/my_user/Library/Developer/Xcode/DerivedData/ProjectABC-dplbttsrwvxakmcyjcbmjrnmcxnv/SourcePackages/checkouts

I fixed this issue by manually pointing xcgrapher to this path. I am not sure how Xcode generates this path per project (maybe there is some macro at project level that can be used from build settings?)

shahzadmajeed avatar Jul 05 '21 06:07 shahzadmajeed

Unfortunately xcgrapher is still throwing error for a file that does exits in one of swift package

[main] The file “AccessibilityAdapter.swift” couldn’t be opened because there is no such file.

shahzadmajeed avatar Jul 05 '21 06:07 shahzadmajeed

I was also facing the [main] The folder “checkouts” doesn’t exist. error 😬 So I decided to play around with this project.

After clearing Derived Data I noticed that in fact the checkouts folder wasn't there. Turns out it's because we build only the .xcodeproj file, whereas we should build the .xcworkspace file if we're using one:

https://github.com/maxchuquimia/xcgrapher/blob/fa36ffcb7a63d09160d59c21225d93ca19fe36b6/Sources/XCGrapherLib/ShellTasks/Xcodebuild.swift#L39

So I modified that line and hardcoded my xcworkspace like this:

"xcodebuild -workspace \"../path/to/app.xcworkspace\" -scheme \"my-scheme-here\" -showBuildSettings"

And it goes past the [main] The folder “checkouts” doesn’t exist. point but later it throws another error here:

[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/app-bkymdsrmhoowijgkdzpwvaxvmyzx/SourcePackages/checkouts/aws-sdk-ios-spm" describe --type json
[main] error: artifact not found for target 'AWSKinesisVideo'

It relates to https://github.com/aws-amplify/aws-sdk-ios-spm - but I don't know what's the problem there, I have no leads 😬

@maxchuquimia is it possible that "xcworkspace" ends up needing to be a new StartingPoint? 😅

Any help would be appreciated!

rogerluan avatar Aug 28 '21 18:08 rogerluan

Hm, perhaps the "workspace" VS "project" difference isn't the key problem here, since I realized the "SomeApp" demo project also contains a xcworkspace (since it uses CocoaPods).

I observed that the sample object contains only publicly-available Swift Packages, which's the not the case for my project at hand. In my case, the Swift Package dependencies are local packages - that could be the reason for other failures?

Nonetheless, when attempting to run xcgrapher against the demo project, I ended up facing this error:

[XCGrapher] Loading plugin /usr/local/lib/libXCGrapherModuleImportPlugin.dylib
[XCGrapher] Generating list of source files in SomeApp
[ShellTask] ruby -r xcodeproj -e 'Xcodeproj::Project.open("SomeApp.xcodeproj").targets.filter do |t| t.name == "SomeApp" end.first.source_build_phase.files.to_a.reject do |f| f.file_ref.nil? end.each do |f| puts f.file_ref.real_path.to_s end'
[XCGrapher] Building Swift Package list
[ShellTask] xcodebuild -project "SomeApp.xcodeproj" -target "SomeApp" -showBuildSettings
[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/SomeApp-abqntfajczwiimbuouvhorqktaqx/SourcePackages/checkouts/Charts" describe --type json
[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/SomeApp-abqntfajczwiimbuouvhorqktaqx/SourcePackages/checkouts/realm-core" describe --type json
[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/SomeApp-abqntfajczwiimbuouvhorqktaqx/SourcePackages/checkouts/swift-numerics" describe --type json
[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/SomeApp-abqntfajczwiimbuouvhorqktaqx/SourcePackages/checkouts/swift-algorithms" describe --type json
[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/SomeApp-abqntfajczwiimbuouvhorqktaqx/SourcePackages/checkouts/realm-cocoa" describe --type json
[ShellTask] swift package --package-path "/Users/rogerluan/Library/Developer/Xcode/DerivedData/SomeApp-abqntfajczwiimbuouvhorqktaqx/SourcePackages/checkouts/lottie-ios" describe --type json
[XCGrapher] Graphing...
[main] The file “Animator.swift” couldn’t be opened because there is no such file.

rogerluan avatar Aug 28 '21 18:08 rogerluan

Thanks for all the detailed info @rogerluan! cc1ae06 hopefully fixes both yours and @shahzadmajeed's no such file error.. and yes, I use other xcworkspaces with XCGrapher and it's fine so not too sure what's going on there... though if you reckon that passing a workspace somehow allows you to proceed further then I'm happy to add a --workspace and --scheme flag as you described.

The artifact not found for target 'AWSKinesisVideo' error seems to be coming directly from the swift package --package-path xxx/aws-sdk-ios-spm describe --type json command (what happens if you run that line directly?), I have seen it/similar before (with Firebase I think) so not sure if there's much we can do about it...

maxchuquimia avatar Aug 29 '21 01:08 maxchuquimia

Hey @maxchuquimia! I hadn't seen that commit of yours earlier, so I debugged the "no such file" error and yesterday I came up with a solution for it, which's significantly different from yours in that commit 😅 I'll open a PR with it soon, so you can take a look at my approach.

I've been working on finishing up the --package support that you started, and managed to make it work. I'm finishing up its tests now should be opening a PR later today.

Next for me will be add support to local swift packages, so hit the ultimate goal I've been seeking with this tool. During that process I'll probably have to check what's up with that artifact not found for target… issue 👍 I'll keep you posted :)

rogerluan avatar Aug 29 '21 14:08 rogerluan

Just to keep you on the loop, I was able to implement the support for local swift packages 🎉 but I still need to write proper tests for it. Bad news is that I simply ignored the fact that aws-sdk-ios-spm was throwing that error... In fact, running swift package --package-path xxx/aws-sdk-ios-spm describe --type json directly on Terminal throws the same error, so it's either an issue with SPM itself, or with that package. I suppose it's because it contains prebuilt binaries (.xcframeworks), and for some reason swift package describe doesn't support describing those 😬 I have yet to think of a good solution around this... To make my project work, I literally removed that dependency from it, just for testing purpose. I'm thinking of ignoring such errors and logging them (something like "skip this package if it's problematic, and log the problem, but proceed") - thoughts @maxchuquimia ? 🤷

rogerluan avatar Aug 30 '21 04:08 rogerluan

@rogerluan

I hadn't seen that commit of yours earlier

Ah I just added that commit after seeing your comment!

I've been working on finishing up the --package support

🎉🎉🎉🎉 Saw a few PRs come through, will take a peek now

I suppose it's because it contains prebuilt binaries

Oh that might just be the case eh - yeah, the only thing we can do is work around it... I'd be a bit worried about a general flag to ignore problematic packages in case it just gets enabled and causes problems in the future: perhaps we could have --ignore-package aws-sdk-ios-spm to purposely stop looking into a package or maybe even detect that specific artifact issue, print an error saying it's an SPM bug and ignore the package?

maxchuquimia avatar Aug 30 '21 10:08 maxchuquimia

I'd be happy with either of those solutions @maxchuquimia 😊

rogerluan avatar Aug 31 '21 02:08 rogerluan

Okay, I pushed ef3aa06 just now (it's the second solution), please let me know if it works (I had some trouble adding AWS into the sample project so couldn't test it) and if so I'll figure out the best way to write tests for it!

maxchuquimia avatar Sep 04 '21 05:09 maxchuquimia

I happen to have also had trouble adding AWS into the sample project, actually. Its "Nimble" dependency conflicts in a weird way with the other dependencies 😬

I replied to some of the comments there 🙏

rogerluan avatar Sep 04 '21 11:09 rogerluan

Hmm okay - are you able to give it a run against whatever project you mentioned in your first comment on this issue?

maxchuquimia avatar Sep 05 '21 02:09 maxchuquimia

I couldn't test this, even after merging current master into your branch. I ran into an error that I've fixed for sure in #10 but I can't remember what it was exactly now 😅 I'll probably need to wait until #10 gets merged before I can test your solution 🙇

rogerluan avatar Sep 05 '21 12:09 rogerluan

I actually added a new remote to my fork, merged all the changes together in a local branch and tested it out:

image

Seems to be working great 🙌 Neat message coloring btw!

rogerluan avatar Sep 06 '21 19:09 rogerluan

Thanks for checking! I'll work on writing tests for it then merge 🎉

maxchuquimia avatar Sep 11 '21 02:09 maxchuquimia