Skip to content

Migrate examples to snippets#1069

Open
fwcd wants to merge 3 commits into
swiftlang:mainfrom
fwcd:fwcd/snippets
Open

Migrate examples to snippets#1069
fwcd wants to merge 3 commits into
swiftlang:mainfrom
fwcd:fwcd/snippets

Conversation

@fwcd

@fwcd fwcd commented Nov 9, 2022

Copy link
Copy Markdown
Member

Now that Xcode 14.1 has been released, there shouldn't be any issues with SwiftPM snippets anymore, therefore this PR migrates the examples folder to snippets again (thus superseding #531).

Additionally this PR renames the buildProduct method to snake_case again, as per the Python convention, and fixes a minor issue where the build script would throw an error when invoked without arguments (instead of producing a proper help message).

cc @ahoppen @SimplyDanny

@fwcd fwcd requested a review from ahoppen as a code owner November 9, 2022 20:34
@fwcd

fwcd commented Nov 9, 2022

Copy link
Copy Markdown
Member Author

@swift-ci please test

@SimplyDanny

Copy link
Copy Markdown
Contributor

What about the main functions? Can they be removed/replaced?

@fwcd

fwcd commented Nov 11, 2022

Copy link
Copy Markdown
Member Author

We can probably just remove them, to make the scripts a bit less noisy. Not sure about the CI failure, the build script builds the snippets just fine on my machine.

@fwcd

fwcd commented Nov 11, 2022

Copy link
Copy Markdown
Member Author

There's also something strange going on with the libraries snippets link with. When I run swift run CodeGenerationUsingSwiftSyntaxBuilder it builds fine, but fails at runtime, noting that libXCTestSwiftSupport.dylib could not be found:

$ swift run CodeGenerationUsingSwiftSyntaxBuilder
Building for debugging...
[3/3] Linking CodeGenerationUsingSwiftSyntaxBuilder
Build complete! (0.71s)
dyld[23402]: Library not loaded: @rpath/libXCTestSwiftSupport.dylib
  Referenced from: <B2F88FC4-45E7-3E80-ADCC-75B7F64F9907> /Users/<user>/git/swift-syntax/.build/arm64-apple-macosx/debug/CodeGenerationUsingSwiftSyntaxBuilder
  Reason: tried: '/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file), '/Users/<user>/git/swift-syntax/.build/arm64-apple-macosx/debug/libXCTestSwiftSupport.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file), '/Users/<user>/git/swift-syntax/.build/arm64-apple-macosx/debug/libXCTestSwiftSupport.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libXCTestSwiftSupport.dylib' (no such file), '/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file), '/Users/<user>/git/swift-syntax/.build/arm64-apple-macosx/debug/libXCTestSwiftSupport.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libXCTestSwiftSupport.dylib' (no such file), '/Users/<user>/git/swift-syntax/.build/arm64-apple-macosx/debug/libXCTestSwiftSupport.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libXCTestSwiftSupport.dylib' (no such file), '/usr/local/lib/libXCTestSwiftSupport.dylib' (no such file), '/usr/lib/libXCTestSwiftSupport.dylib' (no such file, not in dyld cache)
zsh: abort      swift run CodeGenerationUsingSwiftSyntaxBuilder

I think the issue could be that snippets always try to link all targets, which in this case includes the test support target.

@ahoppen

ahoppen commented Nov 24, 2022

Copy link
Copy Markdown
Member

I think the issue could be that snippets always try to link all targets, which in this case includes the test support target.

Oh, this is super annoying. @bitjammer Do you know if there is any way to make the snippets only link against specific targets to avoid this issue?

@bitjammer

Copy link
Copy Markdown

There isn’t currently a way to specify that. However, is the test support target a product? I recently ran into this issue and I have a todo item to only automatically link product libraries in this way. Would that help here?

@ahoppen

ahoppen commented Nov 24, 2022

Copy link
Copy Markdown
Member

I think that would solve the problem here.

@bitjammer

Copy link
Copy Markdown

I've opened swiftlang/swift-package-manager#5929 to address this problem if you would like to give it a spin with this PR.

fwcd added 3 commits November 29, 2022 12:34
As per the Python convention
This fixes an error when invoking the build script without arguments.
@ahoppen

ahoppen commented Nov 29, 2022

Copy link
Copy Markdown
Member

@bitjammer

bitjammer commented Nov 29, 2022

Copy link
Copy Markdown

Looks like we uncovered another issue, I believe this may have been caused by c1bfac62d536d8cfce6cd6e7b85d2bd7ec2b98a9 – looking into it now.

@bitjammer

Copy link
Copy Markdown

@bitjammer

Copy link
Copy Markdown

Cool, looks like swiftlang/swift-package-manager#5931 will unblock you. Thanks for your patience while I worked out those issues.

@bitjammer

Copy link
Copy Markdown

✅ All swiftpm blockers landed on main.

@fwcd

fwcd commented Nov 30, 2022

Copy link
Copy Markdown
Member Author

Very nice, thanks for looking into this!

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need to wait for the SwiftPM changes to land in Xcode before we can merge this. I’m marking the PR as ”Request changes” to make sure we don’t accidentally merge it.

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

Successfully merging this pull request may close these issues.

5 participants