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

Repurpose Xcode and Swift sections to use native tools #1372

Open
tinder-cfuller opened this issue Jul 24, 2023 · 6 comments
Open

Repurpose Xcode and Swift sections to use native tools #1372

tinder-cfuller opened this issue Jul 24, 2023 · 6 comments
Labels
proposal An issue (rarely PR) for feature-requests, ideas, etc

Comments

@tinder-cfuller
Copy link

tinder-cfuller commented Jul 24, 2023

The problem

The Xcode and Swift sections depend upon 3rd party tools, namely xcenv and swiftenv, that require manual installation, are not strictly necessary and are not ubiquitious.

Describe the solution you'd like

Rename the Xcode section from "xcode" to "xcenv" and rename the Swift section from "swift" to "swiftenv" and move them both to the registry (likely also requiring moving them to another repo).

Then repurpose the "xcode" and "swift" names for brand new sections that rely solely on the 1st party Apple provided commands xed --version and swift --version.

The new sections will not support the local/global configs that the existing sections do. This means that this would be a breaking change for anyone using the local/global configs which would require manually switching to using the "xcenv" / "swiftenv" commands.

Describe alternatives you've considered

  1. Create new sections with new names (such as "xed" and "swiftc")
    • This is not an ideal solution since the names are not as clear as the correct names "xcode" and "swift".
  2. Modify the existing sections to fallback to using xed --version and swift --version when xcenv and swiftenv are not installed.
    • This is is not an ideal solution since the local/global configs do not apply when using the 1st party tools.

Documentation

The docs for the new sections would be almost identical to the existing sections with the following modifications:

  1. The local/global configs would be removed.
  2. Links to "xcenv" and "swiftenv" sections in the registry would be provided directing users to use those sections for compatibility with those 3rd party tools.
@tinder-cfuller tinder-cfuller added the proposal An issue (rarely PR) for feature-requests, ideas, etc label Jul 24, 2023
@tinder-cfuller
Copy link
Author

Examples of the new sections:

Xcode

#
# Xcode
#
# Xcode is a suite of tools developers use to build apps for Apple platforms.
# Link: https://developer.apple.com/xcode/

HAMMER=$'\xF0\x9F\x94\xA8'

# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------

SPACESHIP_XCODE_SHOW="${SPACESHIP_XCODE_SHOW=true}"
SPACESHIP_XCODE_ASYNC="${SPACESHIP_XCODE_ASYNC=true}"
SPACESHIP_XCODE_PREFIX="${SPACESHIP_XCODE_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_XCODE_SUFFIX="${SPACESHIP_XCODE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_XCODE_SYMBOL="${SPACESHIP_XCODE_SYMBOL="$HAMMER "}"
SPACESHIP_XCODE_COLOR="${SPACESHIP_XCODE_COLOR="blue"}"

# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------

spaceship_xcode() {
  [[ $SPACESHIP_XCODE_SHOW == false ]] && return

  spaceship::upsearch -s "*.xcworkspace" "*.xcodeproj" "Package.swift" || return

  spaceship::exists xed || return

  local xcode_version=$(xed --version | awk '{ print $NF }')

  [[ -z $xcode_version ]] && return

  spaceship::section::v4 \
    --color "$SPACESHIP_XCODE_COLOR" \
    --prefix "$SPACESHIP_XCODE_PREFIX" \
    --suffix "$SPACESHIP_XCODE_SUFFIX" \
    --symbol "$SPACESHIP_XCODE_SYMBOL" \
    "v$xcode_version"
}

Swift

#
# Swift
#
# Swift is a powerful and intuitive programming language for all Apple platforms.
# Link: https://developer.apple.com/swift/

BIRD=$'\xF0\x9F\x90\xA6'

# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------

SPACESHIP_SWIFT_SHOW="${SPACESHIP_SWIFT_SHOW=true}"
SPACESHIP_SWIFT_ASYNC="${SPACESHIP_SWIFT_ASYNC=true}"
SPACESHIP_SWIFT_PREFIX="${SPACESHIP_SWIFT_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_SWIFT_SUFFIX="${SPACESHIP_SWIFT_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_SWIFT_SYMBOL="${SPACESHIP_SWIFT_SYMBOL="$BIRD "}"
SPACESHIP_SWIFT_COLOR="${SPACESHIP_SWIFT_COLOR="yellow"}"

# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------

spaceship_swift() {
  [[ $SPACESHIP_SWIFT_SHOW == false ]] && return

  spaceship::upsearch -s "*.xcworkspace" "*.xcodeproj" "Package.swift" || return

  spaceship::exists swift || return

  local swift_version=$(swift --version 2>/dev/null | head -n 1 | sed -En 's/^.*Apple Swift version (([[:digit:]]+\.)*[[:digit:]]+).*$/\1/ip')

  [[ -z $swift_version ]] && return

  spaceship::section::v4 \
    --color "$SPACESHIP_SWIFT_COLOR" \
    --prefix "$SPACESHIP_SWIFT_PREFIX" \
    --suffix "$SPACESHIP_SWIFT_SUFFIX" \
    --symbol "$SPACESHIP_SWIFT_SYMBOL" \
    "v$swift_version"
}

@tinder-cfuller
Copy link
Author

The ✨ emoji should be considered as an alternative for the Swift section.

source: https://twitter.com/uint_min/status/1098628355539124224

Screenshot 2023-07-24 at 12 39 14 AM

@tinder-cfuller
Copy link
Author

Please let me know if this proposal is approved before I create the accompanying pull request. Thank you!

@tinder-cfuller
Copy link
Author

@denysdovhan May you please approve this proposal? I was not planning to submit pull requests until the proposal is approved so that I am able to incorporate your feedback before coding. Thank you!

@tinder-cfuller
Copy link
Author

@denysdovhan Would you kindly be able to please approve this proposal before I begin creating the accompanying pull request? Thank you!

@tinder-cfuller
Copy link
Author

@denysdovhan I am checking in again to see if you may approve this proposal. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal An issue (rarely PR) for feature-requests, ideas, etc
Development

No branches or pull requests

1 participant