From fbfbc1c099ae24b7611004b148767c3d9566fd30 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Wed, 28 Oct 2020 11:27:16 +0000 Subject: [PATCH 01/14] Supporting initializer with RandomAccessCollection --- Documentation/Usage.md | 9 +++++++++ README.md | 1 + Sources/SwiftUIPager/Pager+Buildable.swift | 2 ++ Sources/SwiftUIPager/Pager.swift | 12 ++++++------ Sources/SwiftUIPager/PagerContent+Buildable.swift | 2 ++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Documentation/Usage.md b/Documentation/Usage.md index 5a71719..fbbdf23 100644 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -51,6 +51,15 @@ whereas a value greater than one will make it look like a box: itemAspectRatio greater than 1 +### Pagination sensitivity + +By default, `Pager` will increase/decrease the current `page` if this shift is greather than 50% of its relative size. If you wish to make this transition easier or, on the contrary, make it harder to happen, use `sensitivity` to modify this relative value. For instance, to make transitions easier: + +```swift +Pager(...) + .sensitivity(.high) +``` + ### Orientation and direction By default, `Pager` will create a horizontal container. Use `vertical` to create a vertical pager: diff --git a/README.md b/README.md index 7f37844..5110ed9 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Create vertical or horizontal pagers, align the cards, change the direction of t - [Initialization](Documentation/Usage.md#initialization) - [UI customization](Documentation/Usage.md#ui-customization) - [Configure your page size](Documentation/Usage.md#configure-your-page-size) + - [Pagination sensitivity](Documentation/Usage.md#pagination-sensitivity) - [Orientation and direction](Documentation/Usage.md#orientation-and-direction) - [Alignment](Documentation/Usage.md#alignment) - [Multiple pagination](Documentation/Usage.md#multiple-pagination) diff --git a/Sources/SwiftUIPager/Pager+Buildable.swift b/Sources/SwiftUIPager/Pager+Buildable.swift index e9d01f8..8816bea 100644 --- a/Sources/SwiftUIPager/Pager+Buildable.swift +++ b/Sources/SwiftUIPager/Pager+Buildable.swift @@ -55,6 +55,8 @@ extension Pager: Buildable, PagerProxy { #if !os(tvOS) /// Sensitivity used to determine whether or not to swipe the page + /// + /// - Parameter value: sensitivity to be applied when paginating public func sensitivity(_ value: PaginationSensitivity) -> Self { mutating(keyPath: \.sensitivity, value: value) } diff --git a/Sources/SwiftUIPager/Pager.swift b/Sources/SwiftUIPager/Pager.swift index 4b2b29c..becba7c 100644 --- a/Sources/SwiftUIPager/Pager.swift +++ b/Sources/SwiftUIPager/Pager.swift @@ -165,12 +165,12 @@ public struct Pager: View where PageView: View, Element: /// Initializes a new `Pager`. /// /// - Parameter page: Binding to the page index - /// - Parameter data: Array of items to populate the content + /// - Parameter data: Collection of items to populate the content /// - Parameter id: KeyPath to identifiable property /// - Parameter content: Factory method to build new pages - public init(page: Binding, data: [Element], id: KeyPath, @ViewBuilder content: @escaping (Element) -> PageView) { + public init(page: Binding, data: Data, id: KeyPath, @ViewBuilder content: @escaping (Element) -> PageView) where Data.Index == Int, Data.Element == Element { self._page = page - self.data = data + self.data = Array(data) self.id = id self.content = content } @@ -228,10 +228,10 @@ extension Pager where ID == Element.ID, Element : Identifiable { /// Initializes a new Pager. /// - /// - Parameter data: Array of items to populate the content + /// - Parameter data: Collection of items to populate the content /// - Parameter content: Factory method to build new pages - public init(page: Binding, data: [Element], @ViewBuilder content: @escaping (Element) -> PageView) { - self.init(page: page, data: data, id: \Element.id, content: content) + public init(page: Binding, data: Data, @ViewBuilder content: @escaping (Element) -> PageView) where Data.Index == Int, Data.Element == Element { + self.init(page: page, data: Array(data), id: \Element.id, content: content) } } diff --git a/Sources/SwiftUIPager/PagerContent+Buildable.swift b/Sources/SwiftUIPager/PagerContent+Buildable.swift index e8c1c9f..601ac54 100644 --- a/Sources/SwiftUIPager/PagerContent+Buildable.swift +++ b/Sources/SwiftUIPager/PagerContent+Buildable.swift @@ -59,6 +59,8 @@ extension Pager.PagerContent: Buildable, PagerProxy { #if !os(tvOS) /// Sensitivity used to determine whether or not to swipe the page + /// + /// - Parameter value: sensitivity to be applied when paginating func sensitivity(_ value: PaginationSensitivity) -> Self { mutating(keyPath: \.sensitivity, value: value) } From f63c7713c7893257d30028c8c94c7aabfd082d88 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Wed, 28 Oct 2020 11:29:56 +0000 Subject: [PATCH 02/14] Explicitly adding release branch --- .github/workflows/bump-version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 08b402e..6e4f3aa 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -24,6 +24,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} TAG_CONTEXT: repo + RELEASE_BRANCHES: master DEFAULT_BUMP: none WITH_V: false PRERELEASE_SUFFIX: beta From b5af6dd52e9b01427238f025e44aa4bc9ad66243 Mon Sep 17 00:00:00 2001 From: Teameh Date: Wed, 28 Oct 2020 14:15:36 +0100 Subject: [PATCH 03/14] Update CGPoint+Angle.swift --- Sources/SwiftUIPager/Helpers/CGPoint+Angle.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/SwiftUIPager/Helpers/CGPoint+Angle.swift b/Sources/SwiftUIPager/Helpers/CGPoint+Angle.swift index 5af5876..67d055b 100644 --- a/Sources/SwiftUIPager/Helpers/CGPoint+Angle.swift +++ b/Sources/SwiftUIPager/Helpers/CGPoint+Angle.swift @@ -36,6 +36,7 @@ extension CGPoint { } +@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *) extension Angle { var isAlongXAxis: Bool { let degrees = ((Int(self.degrees.rounded()) % 360) + 360) % 360 From 3ef8fe64f2ab6a186f0a7c92fbe96a0c98743b8a Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Wed, 28 Oct 2020 14:36:11 +0000 Subject: [PATCH 04/14] Update Bump version and create release acton versions --- .github/workflows/bump-version.yml | 2 +- .github/workflows/create-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 6e4f3aa..db0c39e 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -20,7 +20,7 @@ jobs: token: '${{ secrets.PERSONAL_TOKEN }}' - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.30.0 + uses: anothrNick/github-tag-action@1.33.0 env: GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} TAG_CONTEXT: repo diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 4244f17..c71c3ed 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - name: Create XCFramework - uses: unsignedapps/swift-create-xcframework@v1 + uses: unsignedapps/swift-create-xcframework@v1.3 create_release: name: Create Release and Upload artfifacts From 0aff8ba045a2682ff85bf8751e8660473f17704a Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Wed, 28 Oct 2020 16:56:06 +0000 Subject: [PATCH 05/14] Complete version for xcframework --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index c71c3ed..ffb9f60 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - name: Create XCFramework - uses: unsignedapps/swift-create-xcframework@v1.3 + uses: unsignedapps/swift-create-xcframework@v1.3.0 create_release: name: Create Release and Upload artfifacts From 22c74bb3ad7e13b36b518abe2a872aec21fe8c8e Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Wed, 28 Oct 2020 17:30:03 +0000 Subject: [PATCH 06/14] Use fork for xcframework step --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index ffb9f60..834b6e1 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - name: Create XCFramework - uses: unsignedapps/swift-create-xcframework@v1.3.0 + uses: fermoya/swift-create-xcframework@master create_release: name: Create Release and Upload artfifacts From a3f10c638aa9a2fd9d49a317af6a0fc2552fc646 Mon Sep 17 00:00:00 2001 From: Fernando Date: Wed, 28 Oct 2020 18:44:15 +0000 Subject: [PATCH 07/14] Using fork version 1.5.0 --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 834b6e1..84d9320 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - name: Create XCFramework - uses: fermoya/swift-create-xcframework@master + uses: fermoya/swift-create-xcframework@v1.5.0 create_release: name: Create Release and Upload artfifacts From 0fc02a988e91305e5a0b39f01396415377f480b9 Mon Sep 17 00:00:00 2001 From: Fernando Date: Thu, 29 Oct 2020 08:58:07 +0000 Subject: [PATCH 08/14] Explicit platforms to add maccatalyst --- .github/workflows/create-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 84d9320..f8ea1e8 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -19,6 +19,8 @@ jobs: - name: Create XCFramework uses: fermoya/swift-create-xcframework@v1.5.0 + with: + platforms: ios, macos, maccatalyst, tvos, watchos create_release: name: Create Release and Upload artfifacts From ccd0647c9a39eaf34c4419e95f3a2913471302f7 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Mon, 2 Nov 2020 16:41:54 +0000 Subject: [PATCH 09/14] Extracting scripts and updating ci flows --- .github/workflows/build-platforms.yml | 21 +-------- .github/workflows/bump-version.yml | 1 + .github/workflows/create-release.yml | 19 ++++---- .github/workflows/rebase-legacy-branch.yml | 28 +----------- SwiftUIPager.xcodeproj/project.pbxproj | 2 +- scripts/build_platforms.sh | 20 +++++++++ scripts/build_xcframework.sh | 51 ++++++++++++++++++++++ scripts/rebase.sh | 25 +++++++++++ 8 files changed, 109 insertions(+), 58 deletions(-) create mode 100755 scripts/build_platforms.sh create mode 100755 scripts/build_xcframework.sh create mode 100755 scripts/rebase.sh diff --git a/.github/workflows/build-platforms.yml b/.github/workflows/build-platforms.yml index cec3d0f..50a7929 100644 --- a/.github/workflows/build-platforms.yml +++ b/.github/workflows/build-platforms.yml @@ -16,23 +16,4 @@ jobs: - uses: actions/checkout@v2 - name: Run script - run: | - gem install xcpretty - - SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS ) - PLATFORMS=( "platform=macOS,variant=Mac Catalyst" "platform=macOS" "generic/platform=iOS" "generic/platform=watchOS" "generic/platform=tvOS" ) - DIR=$(xcodebuild -project SwiftUIPager.xcodeproj -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*") - - for i in ${!SCHEMES[@]}; do - xcodebuild clean build -scheme ${SCHEMES[$i]} \ - -project SwiftUIPager.xcodeproj \ - -destination "${PLATFORMS[$i]}" | xcpretty - - COUNT=$(find $DIR -maxdepth 1 -type d | wc -l) - if [ $COUNT -eq 2 ]; then - echo "$(tput setaf 2)Build succeded for target ${SCHEMES[$i]}$(tput sgr0)" - else - echo "$(tput setaf 1)Build failed for target ${SCHEMES[$i]}$(tput sgr0)" - exit 1 - fi - done + run: ./scripts/build_platforms.sh diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index db0c39e..371e7a4 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -28,3 +28,4 @@ jobs: DEFAULT_BUMP: none WITH_V: false PRERELEASE_SUFFIX: beta + VERBOSE: false diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index f8ea1e8..e570248 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -18,9 +18,14 @@ jobs: - uses: actions/checkout@v2 - name: Create XCFramework - uses: fermoya/swift-create-xcframework@v1.5.0 + id: xcframework + run: ./scripts/build_xcframework.sh + + - name: Upload artifact + uses: actions/upload-artifact@v2 with: - platforms: ios, macos, maccatalyst, tvos, watchos + name: SwiftUIPager.xcframework.zip + path: ${{ steps.xcframework.outputs.path }} create_release: name: Create Release and Upload artfifacts @@ -34,11 +39,7 @@ jobs: run: | name=VERSION::${GITHUB_REF/refs\/tags\//} echo "Tag: $name" - if [[ "$name" == *"beta"* ]]; then - prerelease=true - else - prerelease=false - fi + if [[ "$name" == *"beta"* ]]; then prerelease=true; else prerelease=false; fi echo ::set-output name=prerelease::$prerelease - name: Create Release @@ -57,10 +58,8 @@ jobs: - name: Download artifact uses: actions/download-artifact@v2 with: - name: SwiftUIPager.zip + name: SwiftUIPager.xcframework.zip path: ./ - - - run: mv SwiftUIPager.zip SwiftUIPager.xcframework.zip - name: Upload Release Asset id: upload-release-asset diff --git a/.github/workflows/rebase-legacy-branch.yml b/.github/workflows/rebase-legacy-branch.yml index b4fe0f5..a29dbad 100644 --- a/.github/workflows/rebase-legacy-branch.yml +++ b/.github/workflows/rebase-legacy-branch.yml @@ -3,7 +3,6 @@ name: Rebase branch legacy-projects on: - # Trigger the workflow on push pull request or manually push: branches: [ develop ] @@ -22,29 +21,4 @@ jobs: USER_EMAIL: fmdr.ct@gmail.com OUTDATED_BRANCH: legacy-projects BASE_BRANCH: develop - run: | - FOLDER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) - - git clone https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git - cd $FOLDER - git checkout $OUTDATED_BRANCH - - echo Adding origin as $GITHUB_REPOSITORY - git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git - git config --global user.email "$USER_EMAIL" - git config --global user.name "$USER_NAME" - - git fetch origin $BASE_BRANCH - - echo git pull --rebase origin $OUTDATED_BRANCH - git pull --rebase origin $OUTDATED_BRANCH - - echo Rebasing $BASE_BRANCH onto $OUTDATED_BRANCH - echo git rebase origin/$BASE_BRANCH - git rebase origin/$BASE_BRANCH - - echo git push --force-with-lease origin $OUTDATED_BRANCH - git push --force-with-lease origin $OUTDATED_BRANCH - - cd .. - rm -rf $FOLDER + run: ./scripts/rebase.sh diff --git a/SwiftUIPager.xcodeproj/project.pbxproj b/SwiftUIPager.xcodeproj/project.pbxproj index 88423d1..e135f61 100644 --- a/SwiftUIPager.xcodeproj/project.pbxproj +++ b/SwiftUIPager.xcodeproj/project.pbxproj @@ -548,7 +548,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "rm -rd \"SwiftUIPager.xcframework\"\nxcodebuild archive -scheme SwiftUIPager_macOS \\\n -destination \"platform=macOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_iOS \\\n -destination \"generic/platform=iOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_iOS \\\n -destination \"generic/platform=iOS Simulator\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS-simulator.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_Catalyst \\\n -destination \"platform=macOS,variant=Mac Catalyst\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macCatalyst.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_watchOS \\\n -destination \"generic/platform=watchOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager//SwiftUIPager.watchOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_watchOS \\\n -destination \"generic/platform=watchOS Simulator\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager//SwiftUIPager.watchOS-simulator.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_tvOS \\\n -destination \"generic/platform=tvOS\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild archive -scheme SwiftUIPager_tvOS \\\n -destination \"generic/platform=tvOS Simulator\" \\\n -archivePath \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS-simulator.xcarchive\" \\\n SKIP_INSTALL=NO \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES\n\nxcodebuild -create-xcframework \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.iOS-simulator.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.macCatalyst.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.watchOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.watchOS-simulator.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -framework \"$TEMP_DIR/SwiftUIPager/SwiftUIPager.tvOS-simulator.xcarchive/Products/Library/Frameworks/SwiftUIPager.framework\" \\\n -output \"SwiftUIPager.xcframework\"\n"; + shellScript = "./scripts/build_xcframework.sh\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/scripts/build_platforms.sh b/scripts/build_platforms.sh new file mode 100755 index 0000000..a632413 --- /dev/null +++ b/scripts/build_platforms.sh @@ -0,0 +1,20 @@ +gem install xcpretty + +SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS ) +PLATFORMS=( "platform=macOS,variant=Mac Catalyst" "platform=macOS" "generic/platform=iOS" "generic/platform=watchOS" "generic/platform=tvOS" ) +DIR=$(xcodebuild -project SwiftUIPager.xcodeproj -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*") +rm -rd $DIR + +for i in ${!SCHEMES[@]}; do + xcodebuild clean build -scheme ${SCHEMES[$i]} \ + -project SwiftUIPager.xcodeproj \ + -destination "${PLATFORMS[$i]}" | xcpretty + + COUNT=$(find $DIR -maxdepth 1 -type d | wc -l) + if [ $COUNT -eq 2 ]; then + echo "$(tput setaf 2)Build succeded for target ${SCHEMES[$i]}$(tput sgr0)" + else + echo "$(tput setaf 1)Build failed for target ${SCHEMES[$i]}$(tput sgr0)" + exit 1 + fi +done \ No newline at end of file diff --git a/scripts/build_xcframework.sh b/scripts/build_xcframework.sh new file mode 100755 index 0000000..a781d05 --- /dev/null +++ b/scripts/build_xcframework.sh @@ -0,0 +1,51 @@ +gem install xcpretty + +LIB_NAME="SwiftUIPager" +PROJ_PATH="$LIB_NAME.xcodeproj" +BUILD_PATH=".build" +FRAMEWORKS_PATH="$BUILD_PATH/frameworks" +XCFRAMEWORK_PATH="$BUILD_PATH/$LIB_NAME.xcframework" +XCFRAMEWORK_ZIP_PATH="$XCFRAMEWORK_PATH.zip" +rm $XCFRAMEWORK_ZIP_PATH + +SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS ) +PLATFORMS=( + "platform=macOS,variant=Mac Catalyst" + "platform=macOS" + "generic/platform=iOS;generic/platform=iOS Simulator" + "generic/platform=watchOS;generic/platform=watchOS Simulator" + "generic/platform=tvOS;generic/platform=tvOS Simulator" +) +ARCHIVES=( + "$LIB_NAME.macCatalyst.xcarchive" + "$LIB_NAME.macos.xcarchive" + "$LIB_NAME.iOS.xcarchive;SwiftUIPager.iOS-simulator.xcarchive" + "$LIB_NAME.watchOS.xcarchive;SwiftUIPager.watchOS-simulator.xcarchive" + "$LIB_NAME.tvOS.xcarchive;SwiftUIPager.tvOS-simulator.xcarchive" +) + +COMMAND="xcodebuild -create-xcframework " +xcodebuild clean -project $PROJ_PATH +for i in ${!SCHEMES[@]}; do + IFS=";" read -r -a PLATFORM <<< "${PLATFORMS[i]}" + IFS=";" read -r -a ARCHIVE <<< "${ARCHIVES[i]}" + + for j in ${!PLATFORM[@]}; do + ARCHIVE_PATH="$FRAMEWORKS_PATH/${ARCHIVE[$j]}" + xcodebuild archive -scheme ${SCHEMES[$i]} \ + -project $PROJ_PATH \ + -destination "${PLATFORM[$j]}" \ + -archivePath $ARCHIVE_PATH \ + SKIP_INSTALL=NO \ + BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty + + COMMAND="$COMMAND -framework $ARCHIVE_PATH/Products/Library/Frameworks/$LIB_NAME.framework" + done + +done +COMMAND="$COMMAND -output $XCFRAMEWORK_PATH" +$COMMAND | xcpretty +rm -rd $FRAMEWORKS_PATH +zip -r $XCFRAMEWORK_ZIP_PATH $XCFRAMEWORK_PATH +rm -rd $XCFRAMEWORK_PATH +echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH \ No newline at end of file diff --git a/scripts/rebase.sh b/scripts/rebase.sh new file mode 100755 index 0000000..a934e98 --- /dev/null +++ b/scripts/rebase.sh @@ -0,0 +1,25 @@ +FOLDER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) + +git clone https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git +cd $FOLDER +git checkout $OUTDATED_BRANCH + +echo Adding origin as $GITHUB_REPOSITORY +git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git +git config --global user.email "$USER_EMAIL" +git config --global user.name "$USER_NAME" + +git fetch origin $BASE_BRANCH + +echo git pull --rebase origin $OUTDATED_BRANCH +git pull --rebase origin $OUTDATED_BRANCH + +echo Rebasing $BASE_BRANCH onto $OUTDATED_BRANCH +echo git rebase origin/$BASE_BRANCH +git rebase origin/$BASE_BRANCH + +echo git push --force-with-lease origin $OUTDATED_BRANCH +git push --force-with-lease origin $OUTDATED_BRANCH + +cd .. +rm -rf $FOLDER \ No newline at end of file From a5db243e7ccdea1cb02f814dffac18f25155a643 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Mon, 2 Nov 2020 17:46:47 +0000 Subject: [PATCH 10/14] Fixing flows after extraction --- .github/workflows/rebase-legacy-branch.yml | 4 +++- SwiftUIPager.xcodeproj/project.pbxproj | 2 +- SwiftUIPager/{ => SupportFiles}/Info-macOS.plist | 0 scripts/build_xcframework.sh | 11 +++++++---- 4 files changed, 11 insertions(+), 6 deletions(-) rename SwiftUIPager/{ => SupportFiles}/Info-macOS.plist (100%) diff --git a/.github/workflows/rebase-legacy-branch.yml b/.github/workflows/rebase-legacy-branch.yml index a29dbad..f3b412e 100644 --- a/.github/workflows/rebase-legacy-branch.yml +++ b/.github/workflows/rebase-legacy-branch.yml @@ -12,7 +12,9 @@ jobs: rebase: name: Checkout legacy-projects and rebase runs-on: ubuntu-latest - steps: + steps: + - uses: actions/checkout@v2 + - name: Automatic Rebase env: GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} diff --git a/SwiftUIPager.xcodeproj/project.pbxproj b/SwiftUIPager.xcodeproj/project.pbxproj index e135f61..cb0200f 100644 --- a/SwiftUIPager.xcodeproj/project.pbxproj +++ b/SwiftUIPager.xcodeproj/project.pbxproj @@ -128,7 +128,7 @@ /* Begin PBXFileReference section */ 172F4D6023DF830600FD2F15 /* SwiftUIPager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftUIPager.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 172F4D6123DF830600FD2F15 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-macOS.plist"; path = "/Users/fernando.moyaderivas/Documents/Playgrounds/SwiftUIPager/SwiftUIPager/Info-macOS.plist"; sourceTree = ""; }; + 172F4D6123DF830600FD2F15 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = ""; }; 172F4D7823DF8A6400FD2F15 /* SwiftUIPager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftUIPager.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 172F4D7B23DF8A6400FD2F15 /* Info-watchOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-watchOS.plist"; sourceTree = ""; }; 6B0F33DD24B4A4DE006031BE /* OnDeactivateModifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnDeactivateModifier.swift; sourceTree = ""; }; diff --git a/SwiftUIPager/Info-macOS.plist b/SwiftUIPager/SupportFiles/Info-macOS.plist similarity index 100% rename from SwiftUIPager/Info-macOS.plist rename to SwiftUIPager/SupportFiles/Info-macOS.plist diff --git a/scripts/build_xcframework.sh b/scripts/build_xcframework.sh index a781d05..58a21c8 100755 --- a/scripts/build_xcframework.sh +++ b/scripts/build_xcframework.sh @@ -4,8 +4,10 @@ LIB_NAME="SwiftUIPager" PROJ_PATH="$LIB_NAME.xcodeproj" BUILD_PATH=".build" FRAMEWORKS_PATH="$BUILD_PATH/frameworks" -XCFRAMEWORK_PATH="$BUILD_PATH/$LIB_NAME.xcframework" -XCFRAMEWORK_ZIP_PATH="$XCFRAMEWORK_PATH.zip" +XCFRAMEWORK_NAME="$LIB_NAME.xcframework" +XCFRAMEWORK_ZIP="$XCFRAMEWORK_NAME.zip" +XCFRAMEWORK_PATH="$BUILD_PATH/$XCFRAMEWORK_NAME" +XCFRAMEWORK_ZIP_PATH="$BUILD_PATH/$XCFRAMEWORK_ZIP" rm $XCFRAMEWORK_ZIP_PATH SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS ) @@ -46,6 +48,7 @@ done COMMAND="$COMMAND -output $XCFRAMEWORK_PATH" $COMMAND | xcpretty rm -rd $FRAMEWORKS_PATH -zip -r $XCFRAMEWORK_ZIP_PATH $XCFRAMEWORK_PATH -rm -rd $XCFRAMEWORK_PATH +cd $BUILD_PATH +zip -r -X $XCFRAMEWORK_ZIP $XCFRAMEWORK_NAME +rm -rd $XCFRAMEWORK_NAME echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH \ No newline at end of file From c296d6ffb1e616630f0b86cad60f75c48793bfb2 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Mon, 2 Nov 2020 18:09:50 +0000 Subject: [PATCH 11/14] Adding change of directory --- scripts/build_xcframework.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build_xcframework.sh b/scripts/build_xcframework.sh index 58a21c8..940c10a 100755 --- a/scripts/build_xcframework.sh +++ b/scripts/build_xcframework.sh @@ -51,4 +51,5 @@ rm -rd $FRAMEWORKS_PATH cd $BUILD_PATH zip -r -X $XCFRAMEWORK_ZIP $XCFRAMEWORK_NAME rm -rd $XCFRAMEWORK_NAME -echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH \ No newline at end of file +echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH +cd .. \ No newline at end of file From edc6c5ab008baf4f40010e0b25c84743b6ffefd7 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Mon, 2 Nov 2020 18:33:50 +0000 Subject: [PATCH 12/14] Fixed macos build --- SwiftUIPager.xcodeproj/project.pbxproj | 4 ++-- scripts/build_xcframework.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SwiftUIPager.xcodeproj/project.pbxproj b/SwiftUIPager.xcodeproj/project.pbxproj index cb0200f..ccd01d6 100644 --- a/SwiftUIPager.xcodeproj/project.pbxproj +++ b/SwiftUIPager.xcodeproj/project.pbxproj @@ -691,7 +691,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/Info-macOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/SupportFiles/Info-macOS.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -723,7 +723,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/Info-macOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/SwiftUIPager/SupportFiles/Info-macOS.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/scripts/build_xcframework.sh b/scripts/build_xcframework.sh index 940c10a..416b18c 100755 --- a/scripts/build_xcframework.sh +++ b/scripts/build_xcframework.sh @@ -21,9 +21,9 @@ PLATFORMS=( ARCHIVES=( "$LIB_NAME.macCatalyst.xcarchive" "$LIB_NAME.macos.xcarchive" - "$LIB_NAME.iOS.xcarchive;SwiftUIPager.iOS-simulator.xcarchive" - "$LIB_NAME.watchOS.xcarchive;SwiftUIPager.watchOS-simulator.xcarchive" - "$LIB_NAME.tvOS.xcarchive;SwiftUIPager.tvOS-simulator.xcarchive" + "$LIB_NAME.iOS.xcarchive;$LIB_NAME.iOS-simulator.xcarchive" + "$LIB_NAME.watchOS.xcarchive;$LIB_NAME.watchOS-simulator.xcarchive" + "$LIB_NAME.tvOS.xcarchive;$LIB_NAME.tvOS-simulator.xcarchive" ) COMMAND="xcodebuild -create-xcframework " @@ -51,5 +51,5 @@ rm -rd $FRAMEWORKS_PATH cd $BUILD_PATH zip -r -X $XCFRAMEWORK_ZIP $XCFRAMEWORK_NAME rm -rd $XCFRAMEWORK_NAME -echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH -cd .. \ No newline at end of file +cd .. +echo ::set-output name=path::$XCFRAMEWORK_ZIP_PATH \ No newline at end of file From a8fcbadf63fb8045dab5682c00f6a38abc713d87 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Mon, 2 Nov 2020 18:58:01 +0000 Subject: [PATCH 13/14] Fixing build platforms sript --- scripts/build_platforms.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/scripts/build_platforms.sh b/scripts/build_platforms.sh index a632413..0391c9a 100755 --- a/scripts/build_platforms.sh +++ b/scripts/build_platforms.sh @@ -2,19 +2,10 @@ gem install xcpretty SCHEMES=( SwiftUIPager_Catalyst SwiftUIPager_macOS SwiftUIPager_iOS SwiftUIPager_watchOS SwiftUIPager_tvOS ) PLATFORMS=( "platform=macOS,variant=Mac Catalyst" "platform=macOS" "generic/platform=iOS" "generic/platform=watchOS" "generic/platform=tvOS" ) -DIR=$(xcodebuild -project SwiftUIPager.xcodeproj -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*") -rm -rd $DIR +rm -rd $DIR for i in ${!SCHEMES[@]}; do xcodebuild clean build -scheme ${SCHEMES[$i]} \ -project SwiftUIPager.xcodeproj \ - -destination "${PLATFORMS[$i]}" | xcpretty - - COUNT=$(find $DIR -maxdepth 1 -type d | wc -l) - if [ $COUNT -eq 2 ]; then - echo "$(tput setaf 2)Build succeded for target ${SCHEMES[$i]}$(tput sgr0)" - else - echo "$(tput setaf 1)Build failed for target ${SCHEMES[$i]}$(tput sgr0)" - exit 1 - fi + -destination "${PLATFORMS[$i]}" || exit 1 done \ No newline at end of file From f5e1c5a557ebe15344469ff2a70f8f7bbf813f58 Mon Sep 17 00:00:00 2001 From: Fernando Moya de Rivas Date: Mon, 2 Nov 2020 19:15:21 +0000 Subject: [PATCH 14/14] Fixed rebase script --- scripts/rebase.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/rebase.sh b/scripts/rebase.sh index a934e98..7237fc6 100755 --- a/scripts/rebase.sh +++ b/scripts/rebase.sh @@ -1,4 +1,8 @@ FOLDER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) +TEMP_DIR=".tmp" + +mkdir $TEMP_DIR +cd $TEMP_DIR git clone https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git cd $FOLDER @@ -21,5 +25,5 @@ git rebase origin/$BASE_BRANCH echo git push --force-with-lease origin $OUTDATED_BRANCH git push --force-with-lease origin $OUTDATED_BRANCH -cd .. -rm -rf $FOLDER \ No newline at end of file +cd ../.. +rm -rf $TEMP_DIR \ No newline at end of file