diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ed7e251..12f09b9 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,13 +1 @@ -# These are supported funding model platforms - github: [danielsaidi] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 055b174..d47e93c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,12 +5,9 @@ name: Build Runner on: push: - branches: ["master"] + branches: ["main"] pull_request: - branches: ["master"] - -env: - SCHEME: DeckKit + branches: ["main"] jobs: build: @@ -21,6 +18,6 @@ jobs: with: xcode-version: '16.0' - name: Build all platforms - run: bash scripts/build.sh $SCHEME + run: bash scripts/build.sh ${{ github.event.repository.name }} - name: Test iOS - run: bash scripts/test.sh $SCHEME + run: bash scripts/test.sh ${{ github.event.repository.name }} diff --git a/.github/workflows/docc.yml b/.github/workflows/docc.yml index 2417210..dae09c0 100644 --- a/.github/workflows/docc.yml +++ b/.github/workflows/docc.yml @@ -8,9 +8,6 @@ on: push: branches: ["master"] -env: - SCHEME: DeckKit - # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read @@ -39,18 +36,7 @@ jobs: with: xcode-version: '16.0' - name: Build DocC - run: | - swift package resolve; - - xcodebuild docbuild -scheme DeckKit -derivedDataPath /tmp/docbuild -destination 'generic/platform=iOS'; - - $(xcrun --find docc) process-archive \ - transform-for-static-hosting /tmp/docbuild/Build/Products/Debug-iphoneos/DeckKit.doccarchive \ - --output-path .build/docs \ - --hosting-base-path 'DeckKit'; - - echo "" > .build/docs/index.html; - + run: bash scripts/docc.sh ${{ github.event.repository.name }} - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/.gitignore b/.gitignore index eb77383..e4c9567 100644 --- a/.gitignore +++ b/.gitignore @@ -9,11 +9,4 @@ Docs documentation downloads -videos - -# Fastlane -Fastlane/report.xml -Fastlane/Preview.html -Fastlane/screenshots -Fastlane/test_output -Fastlane/README.md +videos \ No newline at end of file diff --git a/README.md b/README.md index 9c836a9..edc6430 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

Version - Swift 5.9 + Swift 6.0 Swift UI MIT License Twitter: @danielsaidi @@ -12,18 +12,17 @@

- ## About DeckKit -DeckKit is a Swift SDK that helps you build deck-based apps in SwiftUI. +DeckKit is a SwiftUI SDK that helps you build deck-based apps. -DeckKit has a `DeckView` that can render any item collection, with support for swipe gestures, edge swipe detection, shuffling, etc. The result can look like this or completely different: +DeckKit has a `DeckView` component that can render any ``DeckItem`` collection, with support for swipe gestures, edge swipes, shuffling, etc. The result can look like this, or completely different:

Demo video

-DeckKit has other views as well, and can be customized to great extent. You can change colors, fonts, etc. and use completely custom views. It also has tools to manage favorite items. +DeckKit can be customized to great extent. You can change colors, fonts, etc. and use completely custom views. It also has tools to manage favorites. @@ -39,7 +38,7 @@ https://github.com/danielsaidi/DeckKit.git ## Getting started -With DeckKit, you can create a `Deck` of any model that implement the `DeckItem` protocol: +With DeckKit, you can create a `Deck` of any model that conform to `DeckItem`: ```swift struct Hobby: DeckItem { @@ -70,19 +69,19 @@ struct MyView: View { } ``` -For more information, see the [getting started guide][Getting-Started]. +See the online [getting started guide][Getting-Started] for more information. ## Documentation -The [online documentation][Documentation] has more information, articles, code examples, etc. +The online [documentation][Documentation] has more information, articles, code examples, etc. ## Demo Application -The demo app lets you explore the library with iOS, macOS, and visionOS. To try it out, just open and run the `Demo` project. +The `Demo` folder has an app that lets you test the library on iOS, macOS, and visionOS. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 28e884e..0825a1b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,6 +10,13 @@ DeckKit tries to honor semantic versioning: These release notes only cover the current major version. + +## 1.4 + +This version makes the SDK use Swift 6. + + + ## 1.3 This version has breaking changes for the favorite context/service setup, to make favorites easier to use. diff --git a/Sources/DeckKit/DeckKit.docc/DeckKit.md b/Sources/DeckKit/DeckKit.docc/DeckKit.md index 0452005..858b212 100644 --- a/Sources/DeckKit/DeckKit.docc/DeckKit.md +++ b/Sources/DeckKit/DeckKit.docc/DeckKit.md @@ -8,11 +8,11 @@ DeckKit is a SwiftUI SDK that helps you build deck-based apps. ![DeckKit logo](Logo.png) -DeckKit is a Swift SDK that helps you build deck-based apps in SwiftUI. +DeckKit is a SwiftUI SDK that helps you build deck-based apps. -DeckKit has a ``DeckItem`` protocol that is automatically implemented by any type that implements `Identifiable` and `Equatable`, and extends any such ``Swift/Array`` with more functionality. +DeckKit has a ``DeckView`` component that can render any ``DeckItem`` collection, with support for swipe gestures, edge swipes, shuffling, etc. -DeckKit has a ``DeckView`` that can render an item collection as a physical deck of cards, as well as a ``DeckPageView`` that renders an item collection as a horizontally scrolling page view. +The ``DeckItem`` type is a typealias that is automatically implemented by any type that implements `Identifiable` and `Equatable`, and extends any such ``Swift/Array`` with more functionality. DeckKit can be customized to great extent. You can change colors, fonts, corner radius etc., and use completely custom views. You can also use a ``FavoriteContext`` to manage the favorite state of any `Identifiable` type. diff --git a/scripts/build.sh b/scripts/build.sh index 05a7445..50e5ab5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,22 +1,22 @@ #!/bin/bash -# Build a for all supported platforms. - -# USAGE: bash scripts/build.sh +# Documentation: +# This script builds a for all supported platforms. # Exit immediately if a command exits with a non-zero status set -e -# Create local argument variables. -TARGET=$1 - -# Check if target is provided +# Verify that all required arguments are provided if [ $# -eq 0 ]; then - echo "Error: No target specified" + echo "Error: This script requires exactly one argument" + echo "Usage: $0 " exit 1 fi -# Use the script folder to refer to the platform script. +# Create local argument variables. +TARGET=$1 + +# Use the script folder to refer to other scripts. FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" SCRIPT="$FOLDER/build_platform.sh" diff --git a/scripts/build_platform.sh b/scripts/build_platform.sh index e7f49fd..c7750d3 100755 --- a/scripts/build_platform.sh +++ b/scripts/build_platform.sh @@ -1,8 +1,14 @@ #!/bin/bash -# Build a for a specific platform. +# Documentation: +# This script builds a for a specific . -# USAGE: bash scripts/build_platform.sh +# Verify that all required arguments are provided +if [ $# -ne 2 ]; then + echo "Error: This script requires exactly two arguments" + echo "Usage: $0 " + exit 1 +fi TARGET=$1 PLATFORM=$2 diff --git a/scripts/docc.sh b/scripts/docc.sh index 1fbc122..ef49d2b 100644 --- a/scripts/docc.sh +++ b/scripts/docc.sh @@ -1,8 +1,15 @@ #!/bin/bash -# Build DocC documentation for a to .build/docs. +# Documentation: +# This script build DocC for a . +# The documentation ends up in to .build/docs. -# USAGE: bash scripts/docc.sh +# Verify that all required arguments are provided +if [ $# -eq 0 ]; then + echo "Error: This script requires exactly one argument" + echo "Usage: $0 " + exit 1 +fi TARGET=$1 TARGET_LOWERCASED=$(echo "$1" | tr '[:upper:]' '[:lower:]') @@ -14,6 +21,6 @@ xcodebuild docbuild -scheme $1 -derivedDataPath /tmp/docbuild -destination 'gene $(xcrun --find docc) process-archive \ transform-for-static-hosting /tmp/docbuild/Build/Products/Debug-iphoneos/$1.doccarchive \ --output-path .build/docs \ - --hosting-base-path '$1'; + --hosting-base-path "$TARGET"; echo "" > .build/docs/index.html; diff --git a/scripts/test.sh b/scripts/test.sh index 3fd6015..20f59db 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,40 +1,40 @@ #!/bin/bash -# Test a for all supported platforms. - -# USAGE: bash scripts/test.sh +# Documentation: +# This script tests a for all supported platforms. # Exit immediately if a command exits with a non-zero status set -e -# Create local argument variables. -TARGET=$1 - -# Check if target is provided +# Verify that all required arguments are provided if [ $# -eq 0 ]; then - echo "Error: No target specified" + echo "Error: This script requires exactly one argument" + echo "Usage: $0 " exit 1 fi -# Use the script folder to refer to the platform script. +# Create local argument variables. +TARGET=$1 + +# Use the script folder to refer to other scripts. FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" SCRIPT="$FOLDER/test_platform.sh" # Make the script executable chmod +x $SCRIPT -# A function that builds a specific platform +# A function that tests a specific platform test_platform() { local platform=$1 - echo "Building for $platform..." + echo "Testing for $platform..." if ! bash $SCRIPT $TARGET $platform; then - echo "Failed to build $platform" + echo "Failed to test $platform" return 1 fi - echo "Successfully built $platform" + echo "Successfully tested $platform" } -# Array of platforms to build +# Array of platforms to test platforms=("platform=iOS_Simulator,name=iPhone_16") # Loop through platforms and build diff --git a/scripts/test_platform.sh b/scripts/test_platform.sh index ec183f4..5f241d5 100755 --- a/scripts/test_platform.sh +++ b/scripts/test_platform.sh @@ -1,10 +1,15 @@ #!/bin/bash -# Test the SDK for a specific platform. - +# Documentation: +# This script tests a for a specific platform. # Use _ instead of spaces when passing in the . -# USAGE: bash scripts/build_platform.sh +# Verify that all required arguments are provided +if [ $# -ne 2 ]; then + echo "Error: This script requires exactly two arguments" + echo "Usage: $0 " + exit 1 +fi TARGET=$1 PLATFORM="${2//_/ }" diff --git a/scripts/validate_git.sh b/scripts/validate_git.sh deleted file mode 100755 index d1970cc..0000000 --- a/scripts/validate_git.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Validate the Git repository for an optional . - -# USAGE: bash scripts/validate_git.sh - -# Create local argument variables. -BRANCH=$1 - -# Check if a branch is provided -if [ $# -eq 0 ]; then - echo "Error: No branch specified" - exit 1 -fi - -# Check if the current directory is a Git repository -if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then - echo "Error: Not a Git repository" - exit 1 -fi - -# Check for uncommitted changes -if ! git diff-index --quiet HEAD --; then - echo "Error: Git repository is dirty. There are uncommitted changes." - exit 1 -fi - -# If a branch name is provided, check if we're on that branch -if [ $# -eq 1 ]; then - current_branch=$(git rev-parse --abbrev-ref HEAD) - if [ "$current_branch" != "$1" ]; then - echo "Error: Not on the specified branch. Current branch is $current_branch, expected $1." - exit 1 - fi - echo "Git repository is clean and on the correct branch ($1)." -elif [ $# -gt 1 ]; then - print_usage - exit 1 -fi - -# The Git repository validation succeeded. -exit 0 diff --git a/scripts/validate_project.sh b/scripts/validate_project.sh deleted file mode 100755 index 5574729..0000000 --- a/scripts/validate_project.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Validate the project. - -# USAGE: bash scripts/validate_project.sh - -swiftlint diff --git a/scripts/version_create.sh b/scripts/version_create.sh index 357de71..fcea0b1 100755 --- a/scripts/version_create.sh +++ b/scripts/version_create.sh @@ -1,13 +1,12 @@ #!/bin/bash -# Create a new project version for the provided and . - -# USAGE: bash scripts/version_create.sh and +# Documentation: +# This script creates a new project version for the provided and . # Exit immediately if a command exits with a non-zero status set -e -# Check if both arguments are provided +# Verify that all required arguments are provided if [ $# -ne 2 ]; then echo "Error: This script requires exactly two arguments" echo "Usage: $0 " @@ -20,11 +19,9 @@ GIT_BRANCH="$2" # Use the script folder to refer to the platform script. FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -VALIDATE_GIT="$FOLDER/validate_git.sh" -VALIDATE_PROJECT="$FOLDER/validate_project.sh" -BUILD="$FOLDER/build.sh" -TEST="$FOLDER/test.sh" -VERSION_BUMP="$FOLDER/version_bump.sh" +VALIDATE_GIT="$FOLDER/version_validate_git.sh" +VALIDATE_PROJECT="$FOLDER/version_validate_project.sh" +VERSION_BUMP="$FOLDER/version_number_bump.sh" # A function that run a certain script and checks for errors run_script() { @@ -51,13 +48,7 @@ echo "Validating Git..." run_script "$VALIDATE_GIT" "$GIT_BRANCH" echo "Validating Project..." -run_script "$VALIDATE_PROJECT" - -echo "Building..." -run_script "$BUILD" "$BUILD_TARGET" - -echo "Testing..." -run_script "$TEST" "$BUILD_TARGET" +run_script "$VALIDATE_PROJECT" "$BUILD_TARGET" echo "Bumping version..." run_script "$VERSION_BUMP" diff --git a/scripts/version.sh b/scripts/version_number.sh similarity index 79% rename from scripts/version.sh rename to scripts/version_number.sh index 263547b..50a8ba4 100755 --- a/scripts/version.sh +++ b/scripts/version_number.sh @@ -1,8 +1,10 @@ #!/bin/bash -# Get the latest project version number from git. +# Documentation: +# This script returns the latest semver project version. -# USAGE: bash scripts/version.sh +# Exit immediately if a command exits with a non-zero status +set -e # Check if the current directory is a Git repository if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then diff --git a/scripts/version_bump.sh b/scripts/version_number_bump.sh similarity index 75% rename from scripts/version_bump.sh rename to scripts/version_number_bump.sh index 53e6bd4..40eade9 100755 --- a/scripts/version_bump.sh +++ b/scripts/version_number_bump.sh @@ -1,16 +1,26 @@ #!/bin/bash -# Bump the project version number. +# Documentation: +# This script bumps the project version number. -# USAGE: bash scripts/version_bump.sh +# Exit immediately if a command exits with a non-zero status +set -e -# Use the script folder to refer to the platform script. +# Use the script folder to refer to other scripts. FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -SCRIPT="$FOLDER/version.sh" +SCRIPT="$FOLDER/version_number.sh" # Get the latest version VERSION=$($SCRIPT) +if [ $? -ne 0 ]; then + echo "Failed to get the latest version" + exit 1 +fi + +# Print the current version +echo "The current version is: $VERSION" + # Function to validate semver format, including optional -rc. suffix validate_semver() { if [[ $1 =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then @@ -20,13 +30,6 @@ validate_semver() { fi } -if [ $? -ne 0 ]; then - echo "Failed to get the latest version" - exit 1 -fi - -echo "The current version is: $VERSION" - # Prompt user for new version while true; do read -p "Enter the new version number: " NEW_VERSION @@ -39,6 +42,6 @@ while true; do fi done -git tag $NEW_VERSION -git push --tags git push -u origin HEAD +git tag $NEW_VERSION +git push --tags \ No newline at end of file diff --git a/scripts/version_validate_git.sh b/scripts/version_validate_git.sh new file mode 100755 index 0000000..50e4b81 --- /dev/null +++ b/scripts/version_validate_git.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Documentation: +# This script version validates the Git repository for a . +# The script will fail if there are uncommitted changes, or if the branch is incorrect. + +# Exit immediately if a command exits with a non-zero status +set -e + +# Verify that all required arguments are provided +if [ $# -eq 0 ]; then + echo "Error: This script requires exactly one argument" + echo "Usage: $0 " + exit 1 +fi + +# Create local argument variables. +BRANCH=$1 + +# Check if the current directory is a Git repository +if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "Error: Not a Git repository" + exit 1 +fi + +# Check for uncommitted changes +if ! git diff-index --quiet HEAD --; then + echo "Error: Git repository is dirty. There are uncommitted changes." + exit 1 +fi + +# Verify that we're on the correct branch +current_branch=$(git rev-parse --abbrev-ref HEAD) +if [ "$current_branch" != "$BRANCH" ]; then + echo "Error: Not on the specified branch. Current branch is $current_branch, expected $1." + exit 1 +fi + +# The Git repository validation succeeded. +echo "Git repository successfully validated for branch ($1)." +exit 0 diff --git a/scripts/version_validate_project.sh b/scripts/version_validate_project.sh new file mode 100755 index 0000000..cc6a7c0 --- /dev/null +++ b/scripts/version_validate_project.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Documentation: +# This script validates the project for a . +# The script will fail if swiftlint fails, or if any build and test runner fails. + +# Exit immediately if a command exits with a non-zero status +set -e + +# Verify that all required arguments are provided +if [ $# -eq 0 ]; then + echo "Error: This script requires exactly one argument" + echo "Usage: $0 " + exit 1 +fi + +# Create local argument variables. +TARGET=$1 + +# Use the script folder to refer to other scripts. +FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +BUILD="$FOLDER/build.sh" +TEST="$FOLDER/test.sh" + +# A function that run a certain script and checks for errors +run_script() { + local script="$1" + shift # Remove the first argument (script path) from the argument list + + if [ ! -f "$script" ]; then + echo "Error: Script not found: $script" + exit 1 + fi + + chmod +x "$script" + if ! "$script" "$@"; then + echo "Error: Script $script failed" + exit 1 + fi +} + +echo "Running SwiftLint" +if ! swiftlint; then + echo "Error: SwiftLint failed." + exit 1 +fi + +echo "Building..." +run_script "$BUILD" "$TARGET" + +echo "Testing..." +run_script "$TEST" "$TARGET" + +echo "" +echo "Project successfully validated!" +echo "" \ No newline at end of file diff --git a/version_create.sh b/version_create.sh index 01ce033..c957f5b 100755 --- a/version_create.sh +++ b/version_create.sh @@ -1,4 +1,4 @@ SCRIPT="scripts/version_create.sh" chmod +x $SCRIPT chmod +x version_create.sh -bash $SCRIPT DeckKit main \ No newline at end of file +bash $SCRIPT DeckKit master \ No newline at end of file