Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ Cross-compilation for Android requires installing three separate components:
{% assign platform = site.data.builds.swift_releases.last.platforms | where: 'name', 'Android SDK'| first %}
{% assign tag = site.data.builds.swift_releases.last.tag %}
{% assign version = site.data.builds.swift_releases.last.name %}
{% assign previous_releases = site.data.builds.swift_releases | offset:1 %}
{% assign previous_sdk_name = previous_releases.last.name | append: "_android" %}
{% assign release_count = site.data.builds.swift_releases.size %}
{% assign previous_release = site.data.builds.swift_releases | slice: release_count - 2 %}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

2 because these arrays are zero-indexed.

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.

Good catch on the zero-indexing.
slice returns an array here, not a single release object, so I am not sure if previous_release.name would work as expected.
Can you try:

{% assign release_count = site.data.builds.swift_releases.size %}
{% assign previous_release = site.data.builds.swift_releases[release_count | minus: 2] %}
{% assign previous_sdk_name = previous_release.name | append: "_android" %}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

slice returns an array here, not a single release object, so I am not sure if previous_release.name would work as expected.

Are you sure? The doc indicates otherwise when a single number is specified, like I do here, but I have not tested it locally.

If you have a local setup you can try this out on, that would be great. 👍

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.

You may be right — I was thinking of the general array slicing behavior. Looking at the Liquid docs again, it does seem that passing a single index may return the element directly rather than a sub-array.
I have not tested it locally yet, so I cannot say with certainty.
I didn't test it locally for time constraints, but I would highly recommend to test changes locally

{% assign previous_sdk_name = previous_release.tag | append: "_android" %}
{% assign tag_downcase = site.data.builds.swift_releases.last.tag | downcase %}
{% assign base_url = "https://download.swift.org/" | append: tag_downcase | append: "/android-sdk/" | append: tag | append: "/" | append: tag %}
{% assign command = "swift sdk install " | append: base_url | append: "_android" | append: ".artifactbundle.tar.gz --checksum " | append: platform.checksum %}
Expand Down
Loading