Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let's add the possibility to set custom checkoutsDir #3

Open
salyasev opened this issue Apr 19, 2021 · 18 comments
Open

Let's add the possibility to set custom checkoutsDir #3

salyasev opened this issue Apr 19, 2021 · 18 comments

Comments

@salyasev
Copy link

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")

@maxchuquimia
Copy link
Owner

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

@shahzadmajeed
Copy link

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

@maxchuquimia
Copy link
Owner

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!

@shahzadmajeed
Copy link

@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
Copy link

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.

@rogerluan
Copy link
Collaborator

rogerluan commented Aug 28, 2021

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:

"xcodebuild -project \"\(projectFile)\" -target \"\(target)\" -showBuildSettings"

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
Copy link
Collaborator

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.

maxchuquimia pushed a commit that referenced this issue Aug 29, 2021
…no such file."

It seems perhaps the `swift package describe --json` command output changed recently as XCGrapher was not looking at absolute paths and therefore should never have worked in the past. Tests were failing when I began work on this today, and now they are passing again.

This commit doesn't resolve the custom checkouts dir issue, however it is related to other conversation on Github issue #3.
@maxchuquimia
Copy link
Owner

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...

@rogerluan
Copy link
Collaborator

rogerluan commented Aug 29, 2021

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
Copy link
Collaborator

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 ? 🤷

@maxchuquimia
Copy link
Owner

maxchuquimia commented Aug 30, 2021

@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?

@rogerluan
Copy link
Collaborator

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

maxchuquimia pushed a commit that referenced this issue Sep 4, 2021
…hanged recently as XCGrapher was not looking at absolute paths and therefore should never have worked in the past. Tests were failing when I began work on this today, and now they are passing again.

This commit doesn't resolve the custom checkouts dir issue, however it is related to other conversation on Github issue #3.

Note: the above message/s are left intact for historical purposes. This branch was rebased after merging #6 (which contained code originally from this branch)
maxchuquimia pushed a commit that referenced this issue Sep 4, 2021
@maxchuquimia
Copy link
Owner

maxchuquimia commented Sep 4, 2021

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 pushed a commit that referenced this issue Sep 4, 2021
@rogerluan
Copy link
Collaborator

rogerluan commented Sep 4, 2021

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 🙏

maxchuquimia pushed a commit that referenced this issue Sep 5, 2021
@maxchuquimia
Copy link
Owner

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

@rogerluan
Copy link
Collaborator

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
Copy link
Collaborator

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!

@maxchuquimia
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants