diff --git a/.github/workflows/carthage.yml b/.github/workflows/carthage.yml index b50473b..979a77c 100644 --- a/.github/workflows/carthage.yml +++ b/.github/workflows/carthage.yml @@ -24,14 +24,26 @@ on: jobs: build: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Build - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.carthage/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -56,7 +68,7 @@ jobs: ./scripts/carthage.sh update --log-path "$LOGSDIR/Build.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: BuildLog diff --git a/.github/workflows/cocoapods.yml b/.github/workflows/cocoapods.yml index 3fcbac0..0369879 100644 --- a/.github/workflows/cocoapods.yml +++ b/.github/workflows/cocoapods.yml @@ -26,16 +26,26 @@ jobs: strategy: matrix: linttype: [Dynamic, Static] + os: [macOS-13] + xcode: ['15.0'] + name: Lint - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.cocoapods/Logs/${{ matrix.linttype }} LINT_TYPE: ${{ matrix.linttype }} steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Cocoapods uses: maxim-lobanov/setup-cocoapods@v1 @@ -55,7 +65,7 @@ jobs: fi - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: ${{ matrix.linttype }}Logs diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index f51bac2..d9bb0ee 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -16,14 +16,26 @@ on: jobs: build: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Build Documentation - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.documentation/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -31,10 +43,10 @@ jobs: - name: Build Documentation run: | - xcodebuild docbuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -destination "generic/platform=iOS" SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build.log" + xcodebuild docbuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -destination "generic/platform=iOS" SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: Logs diff --git a/.github/workflows/publish-cocoapods.yml b/.github/workflows/publish-cocoapods.yml index 0014b0a..f0a0610 100644 --- a/.github/workflows/publish-cocoapods.yml +++ b/.github/workflows/publish-cocoapods.yml @@ -8,15 +8,27 @@ on: jobs: publish: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Publish CocoaPods - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.cocoapods/Logs COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup CocoaPods uses: maxim-lobanov/setup-cocoapods@v1 @@ -32,7 +44,7 @@ jobs: pod trunk push CBORCoding.podspec --verbose 2>&1 | tee "$LOGSDIR/CocoaPods.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: Logs diff --git a/.github/workflows/swift-package.yml b/.github/workflows/swift-package.yml index 8af012d..20133e6 100644 --- a/.github/workflows/swift-package.yml +++ b/.github/workflows/swift-package.yml @@ -24,7 +24,8 @@ jobs: build: strategy: matrix: - os: [macOS-11, ubuntu-latest] + os: [macOS-13, ubuntu-latest] + xcode: ['15.0'] name: Build runs-on: ${{ matrix.os }} @@ -32,8 +33,16 @@ jobs: LOGSDIR: /tmp/.cborcoding.swiftpm/Logs/Build steps: + - name: Select Xcode Version + if: ${{ runner.os == 'macOS' }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -45,7 +54,7 @@ jobs: swift build --verbose | tee -a "$LOGSDIR/Build.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: BuildLogs-${{ runner.os }} @@ -54,7 +63,8 @@ jobs: test: strategy: matrix: - os: [macOS-11, ubuntu-latest] + os: [macOS-13, ubuntu-latest] + xcode: ['15.0'] name: Test runs-on: ${{ matrix.os }} @@ -63,8 +73,16 @@ jobs: LOGSDIR: /tmp/.cborcoding.swiftpm/Logs/Test steps: + - name: Select Xcode Version + if: ${{ runner.os == 'macOS' }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -88,7 +106,7 @@ jobs: verbose: true - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: TestLogs-${{ runner.os }} diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml index 48950d6..ee5cfd9 100644 --- a/.github/workflows/swiftlint.yml +++ b/.github/workflows/swiftlint.yml @@ -16,12 +16,24 @@ on: jobs: build: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Run SwiftLint - runs-on: macOS-11 + runs-on: ${{ matrix.os }} steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Run SwiftLint run: | diff --git a/.github/workflows/upload-assets.yml b/.github/workflows/upload-assets.yml index 8338df3..74bb582 100644 --- a/.github/workflows/upload-assets.yml +++ b/.github/workflows/upload-assets.yml @@ -8,14 +8,26 @@ on: jobs: xcframework: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Upload XCFramework Assets - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: TMPDIR: /tmp/.cborcoding.assets-xcframework.build steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -57,7 +69,7 @@ jobs: asset_content_type: application/gzip - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: XCFrameworkLogs @@ -66,14 +78,26 @@ jobs: documentation: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Upload Documentation Assets - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: TMPDIR: /tmp/.cborcoding.assets-documentation.build steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -82,7 +106,7 @@ jobs: - name: Build run: | - xcodebuild docbuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -destination "generic/platform=iOS" -derivedDataPath "${TMPDIR}/.docbuild" 2>&1 | tee "${TMPDIR}/Logs/Build.log" + xcodebuild docbuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -destination "generic/platform=iOS" -derivedDataPath "${TMPDIR}/.docbuild" 2>&1 | tee "${TMPDIR}/Logs/Build.log" DOCC_ARCHIVE="$(find "${TMPDIR}/.docbuild" -type d -name "CBORCoding.doccarchive")" mv "${DOCC_ARCHIVE%/}" "${TMPDIR}/Output/CBORCoding.doccarchive" @@ -118,7 +142,7 @@ jobs: asset_content_type: application/gzip - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: DocumentationLogs diff --git a/.github/workflows/xcframework.yml b/.github/workflows/xcframework.yml index 89789d9..66803c1 100644 --- a/.github/workflows/xcframework.yml +++ b/.github/workflows/xcframework.yml @@ -25,14 +25,26 @@ on: jobs: build: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Build - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: TMPDIR: /tmp/.cborcoding.xcframework.build steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -44,7 +56,7 @@ jobs: ./scripts/xcframework.sh --build-dir "${TMPDIR}" -- RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: BuildLogs diff --git a/.github/workflows/xcodebuild.yml b/.github/workflows/xcodebuild.yml index 81b8e77..a2f3299 100644 --- a/.github/workflows/xcodebuild.yml +++ b/.github/workflows/xcodebuild.yml @@ -25,14 +25,26 @@ on: jobs: ios: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: iOS - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.xcodebuild/iOS/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -40,11 +52,11 @@ jobs: - name: Build iOS run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -destination "generic/platform=iOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-ios.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -destination "generic/platform=iOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-ios.log" - name: Build iOS Simulator run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -destination "generic/platform=iOS Simulator" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-iossimulator.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -destination "generic/platform=iOS Simulator" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-iossimulator.log" - name: Test run: | @@ -53,24 +65,36 @@ jobs: IOS_SIM="iPhone 12 Pro" # Fallback Simulator fi - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -testPlan "CBORCodingTests" -destination "platform=iOS Simulator,name=$IOS_SIM" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-ios.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -testPlan "CBORCodingTests" -destination "platform=iOS Simulator,name=$IOS_SIM" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-ios.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: iOSBuildLogs path: ${{ env.LOGSDIR }}/*.log maccatalyst: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: Mac Catalyst - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.xcodebuild/macCatalyst/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -78,28 +102,40 @@ jobs: - name: Build run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -destination "generic/platform=macOS,variant=Mac Catalyst" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-maccatalyst.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -destination "generic/platform=macOS,variant=Mac Catalyst" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-maccatalyst.log" - name: Test run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding" -testPlan "CBORCodingTests" -destination "platform=macOS,variant=Mac Catalyst" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-maccatalyst.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding" -testPlan "CBORCodingTests" -destination "platform=macOS,variant=Mac Catalyst" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-maccatalyst.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: MacCatalystBuildLogs path: ${{ env.LOGSDIR }}/*.log macos: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: macOS - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.xcodebuild/macOS/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -107,28 +143,40 @@ jobs: - name: Build run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding macOS" -destination "generic/platform=macOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-macos.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding macOS" -destination "generic/platform=macOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-macos.log" - name: Test run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding macOS" -testPlan "CBORCoding macOS Tests" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-macos.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding macOS" -testPlan "CBORCoding macOS Tests" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-macos.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: macOSBuildLogs path: ${{ env.LOGSDIR }}/*.log tvos: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: tvOS - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.xcodebuild/tvOS/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -136,11 +184,11 @@ jobs: - name: Build tvOS run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding tvOS" -destination "generic/platform=tvOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-tvos.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding tvOS" -destination "generic/platform=tvOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-tvos.log" - name: Build tvOS Simulator run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding tvOS" -destination "generic/platform=tvOS Simulator" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-tvossimulator.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding tvOS" -destination "generic/platform=tvOS Simulator" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-tvossimulator.log" - name: Test run: | @@ -149,24 +197,36 @@ jobs: TVOS_SIM="Apple TV" # Fallback Simulator fi - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding tvOS" -testPlan "CBORCoding tvOS Tests" -destination "platform=tvOS Simulator,name=$TVOS_SIM" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-tvos.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding tvOS" -testPlan "CBORCoding tvOS Tests" -destination "platform=tvOS Simulator,name=$TVOS_SIM" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-tvos.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: tvOSBuildLogs path: ${{ env.LOGSDIR }}/*.log watchos: + strategy: + matrix: + os: [macOS-13] + xcode: ['15.0'] + name: watchOS - runs-on: macOS-11 + runs-on: ${{ matrix.os }} env: LOGSDIR: /tmp/.cborcoding.xcodebuild/watchOS/Logs steps: + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup Environment run: | @@ -174,11 +234,11 @@ jobs: - name: Build watchOS run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding watchOS" -destination "generic/platform=watchOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-watchos.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding watchOS" -destination "generic/platform=watchOS" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-watchos.log" - name: Build watchOS Simulator run: | - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding watchOS" -destination "generic/platform=watchOS Simulator" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-watchossimulator.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding watchOS" -destination "generic/platform=watchOS Simulator" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES 2>&1 | tee "$LOGSDIR/build-watchossimulator.log" - name: Test run: | @@ -187,10 +247,10 @@ jobs: WATCHOS_SIM="Apple Watch Series 6 - 44mm" # Fallback Simulator fi - xcodebuild -project "CBORCoding.xcodeproj" -scheme "CBORCoding watchOS" -testPlan "CBORCoding watchOS Tests" -destination "platform=watchOS Simulator,name=$WATCHOS_SIM" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-watchos.log" + xcodebuild -workspace "CBORCoding.xcworkspace" -scheme "CBORCoding watchOS" -testPlan "CBORCoding watchOS Tests" -destination "platform=watchOS Simulator,name=$WATCHOS_SIM" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-watchos.log" - name: Upload Logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: always() with: name: watchOSBuildLogs diff --git a/.gitignore b/.gitignore index 02c326a..eba166d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ CBORCoding.xcodeproj/project.xcworkspace/xcuserdata CBORCoding.xcodeproj/xcuserdata +CBORCoding.xcworkspace/xcuserdata .build .swiftpm diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cdabaea --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Half"] + path = Half + url = https://github.com/SomeRandomiOSDev/Half diff --git a/.swiftlint.yml b/.swiftlint.yml index 71d4f91..a1f520f 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -7,7 +7,6 @@ disabled_rules: - function_body_length opt_in_rules: - - anyobject_protocol - array_init - attributes - closure_end_indentation @@ -23,7 +22,6 @@ opt_in_rules: - first_where - force_unwrapping - function_default_parameter_at_end - - inert_defer - no_extension_access_modifier - overridden_super_call - prohibited_super_call @@ -66,6 +64,7 @@ excluded: - Carthage - Tests/LinuxMain.swift - Tests/CBORCodingTests/XCTestManifests.swift + - Half identifier_name: excluded: diff --git a/CBORCoding.podspec b/CBORCoding.podspec index 47a3b45..7d3be4b 100644 --- a/CBORCoding.podspec +++ b/CBORCoding.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "CBORCoding" - s.version = "1.3.2" + s.version = "1.4.0" s.summary = "A CBOR Encoder and Decoder" s.description = <<-DESC A lightweight framework containing a coder pair for encoding and decoding `Codable` conforming types to and from CBOR document format for iOS, macOS, tvOS, and watchOS. @@ -12,25 +12,16 @@ Pod::Spec.new do |s| s.author = { "Joe Newton" => "somerandomiosdev@gmail.com" } s.source = { :git => "https://github.com/SomeRandomiOSDev/CBORCoding.git", :tag => s.version.to_s } - s.ios.deployment_target = '9.0' - s.macos.deployment_target = '10.10' - s.tvos.deployment_target = '9.0' - s.watchos.deployment_target = '2.0' + s.ios.deployment_target = '12.0' + s.macos.deployment_target = '10.13' + s.tvos.deployment_target = '12.0' + s.watchos.deployment_target = '4.0' s.source = { :git => "https://github.com/SomeRandomiOSDev/CBORCoding.git", :tag => s.version.to_s } s.source_files = 'Sources/**/*.swift' - s.swift_versions = ['4.2', '5.0'] + s.swift_versions = ['5.0'] s.cocoapods_version = '>= 1.7.3' - s.dependency 'Half', '~> 1.3' - - s.test_spec 'Tests' do |ts| - ts.ios.deployment_target = '9.0' - ts.macos.deployment_target = '10.10' - ts.tvos.deployment_target = '9.0' - ts.watchos.deployment_target = '2.0' - - ts.source_files = 'Tests/CBORCodingTests/*Tests.swift' - end + s.dependency 'Half', '~> 1.4' end diff --git a/CBORCoding.xcodeproj/project.pbxproj b/CBORCoding.xcodeproj/project.pbxproj index 9b49918..59f4037 100644 --- a/CBORCoding.xcodeproj/project.pbxproj +++ b/CBORCoding.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -32,6 +32,14 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 8EBD20582B03BA9900036789 /* Half.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD20572B03BA9900036789 /* Half.framework */; }; + 8EBD20592B03BA9900036789 /* Half.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD20572B03BA9900036789 /* Half.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8EBD205C2B03BAA400036789 /* Half.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD205B2B03BAA400036789 /* Half.framework */; }; + 8EBD205D2B03BAA400036789 /* Half.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD205B2B03BAA400036789 /* Half.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8EBD20602B03BAA900036789 /* Half.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD205F2B03BAA900036789 /* Half.framework */; }; + 8EBD20612B03BAA900036789 /* Half.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD205F2B03BAA900036789 /* Half.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8EBD20642B03BAAC00036789 /* Half.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD20632B03BAAC00036789 /* Half.framework */; }; + 8EBD20652B03BAAC00036789 /* Half.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8EBD20632B03BAAC00036789 /* Half.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; DD02B7E727476A13007F5569 /* CBORDecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD02B7E227476A13007F5569 /* CBORDecoderTests.swift */; }; DD02B7E827476A13007F5569 /* CBORDecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD02B7E227476A13007F5569 /* CBORDecoderTests.swift */; }; DD02B7E927476A13007F5569 /* CBORDecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD02B7E227476A13007F5569 /* CBORDecoderTests.swift */; }; @@ -80,10 +88,6 @@ DD02B81E27476A4F007F5569 /* CBORDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD02B81427476A4F007F5569 /* CBORDecoder.swift */; }; DD02B81F27476A4F007F5569 /* CBORDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD02B81427476A4F007F5569 /* CBORDecoder.swift */; }; DD02B82027476A4F007F5569 /* CBORDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD02B81427476A4F007F5569 /* CBORDecoder.swift */; }; - DD02B82327476BBA007F5569 /* Half in Frameworks */ = {isa = PBXBuildFile; productRef = DD02B82227476BBA007F5569 /* Half */; }; - DD02B82627476BC2007F5569 /* Half in Frameworks */ = {isa = PBXBuildFile; productRef = DD02B82527476BC2007F5569 /* Half */; }; - DD02B82827476BC5007F5569 /* Half in Frameworks */ = {isa = PBXBuildFile; productRef = DD02B82727476BC5007F5569 /* Half */; }; - DD02B82A27476BC9007F5569 /* Half in Frameworks */ = {isa = PBXBuildFile; productRef = DD02B82927476BC9007F5569 /* Half */; }; DD02B82B27477390007F5569 /* CBORCoding.docc in Sources */ = {isa = PBXBuildFile; fileRef = DD3BB7202731ADDA00DB55F8 /* CBORCoding.docc */; }; DD02B82C27477390007F5569 /* CBORCoding.docc in Sources */ = {isa = PBXBuildFile; fileRef = DD3BB7202731ADDA00DB55F8 /* CBORCoding.docc */; }; DD02B82D27477391007F5569 /* CBORCoding.docc in Sources */ = {isa = PBXBuildFile; fileRef = DD3BB7202731ADDA00DB55F8 /* CBORCoding.docc */; }; @@ -153,9 +157,59 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 8EBD205A2B03BA9900036789 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 8EBD20592B03BA9900036789 /* Half.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 8EBD205E2B03BAA400036789 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 8EBD205D2B03BAA400036789 /* Half.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 8EBD20622B03BAA900036789 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 8EBD20612B03BAA900036789 /* Half.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 8EBD20662B03BAAC00036789 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 8EBD20652B03BAAC00036789 /* Half.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ + 8EBD20572B03BA9900036789 /* Half.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Half.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8EBD205B2B03BAA400036789 /* Half.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Half.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8EBD205F2B03BAA900036789 /* Half.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Half.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8EBD20632B03BAAC00036789 /* Half.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Half.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DD02B7E0274768C9007F5569 /* ATTRIBUTIONS */ = {isa = PBXFileReference; lastKnownFileType = text; path = ATTRIBUTIONS; sourceTree = ""; }; - DD02B7E127476932007F5569 /* Package@swift-4.2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Package@swift-4.2.swift"; sourceTree = ""; }; DD02B7E227476A13007F5569 /* CBORDecoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CBORDecoderTests.swift; sourceTree = ""; }; DD02B7E327476A13007F5569 /* ContainersTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainersTests.swift; sourceTree = ""; }; DD02B7E427476A13007F5569 /* CBOREncoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CBOREncoderTests.swift; sourceTree = ""; }; @@ -168,7 +222,6 @@ DD02B81227476A4E007F5569 /* CBOREncoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CBOREncoder.swift; sourceTree = ""; }; DD02B81327476A4E007F5569 /* CBORParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CBORParser.swift; sourceTree = ""; }; DD02B81427476A4F007F5569 /* CBORDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CBORDecoder.swift; sourceTree = ""; }; - DD02B8CD2755137B007F5569 /* Package@swift-5.0.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Package@swift-5.0.swift"; sourceTree = ""; }; DD17A9F9257744BC00D30599 /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = scripts; sourceTree = ""; }; DD3BB7202731ADDA00DB55F8 /* CBORCoding.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; name = CBORCoding.docc; path = Sources/CBORCoding/CBORCoding.docc; sourceTree = ""; }; DD438A452742CFD900F0A1F6 /* .remarkrc */ = {isa = PBXFileReference; explicitFileType = text.json; path = .remarkrc; sourceTree = ""; }; @@ -207,7 +260,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DD02B82327476BBA007F5569 /* Half in Frameworks */, + 8EBD20582B03BA9900036789 /* Half.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -223,7 +276,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DD02B82627476BC2007F5569 /* Half in Frameworks */, + 8EBD205C2B03BAA400036789 /* Half.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -239,7 +292,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DD02B82827476BC5007F5569 /* Half in Frameworks */, + 8EBD20602B03BAA900036789 /* Half.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -255,7 +308,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DD02B82A27476BC9007F5569 /* Half in Frameworks */, + 8EBD20642B03BAAC00036789 /* Half.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -293,6 +346,10 @@ DD02B82427476BC2007F5569 /* Frameworks */ = { isa = PBXGroup; children = ( + 8EBD20632B03BAAC00036789 /* Half.framework */, + 8EBD205F2B03BAA900036789 /* Half.framework */, + 8EBD205B2B03BAA400036789 /* Half.framework */, + 8EBD20572B03BA9900036789 /* Half.framework */, ); name = Frameworks; sourceTree = ""; @@ -381,8 +438,6 @@ DD17A9F9257744BC00D30599 /* scripts */, DD86D5E023D22DB90046E63E /* CBORCoding.podspec */, DD86D5DF23D22DB90046E63E /* Package.swift */, - DD02B8CD2755137B007F5569 /* Package@swift-5.0.swift */, - DD02B7E127476932007F5569 /* Package@swift-4.2.swift */, DDB1DE5C2405EEE300C20FED /* codecov.yml */, DD438A452742CFD900F0A1F6 /* .remarkrc */, DD86D5E323D22DC30046E63E /* .swiftlint.yml */, @@ -470,6 +525,7 @@ DD86D53923D11B3E0046E63E /* Sources */, DD86D53A23D11B3E0046E63E /* Frameworks */, DD86D53B23D11B3E0046E63E /* Resources */, + 8EBD205A2B03BA9900036789 /* Embed Frameworks */, ); buildRules = ( ); @@ -478,7 +534,6 @@ ); name = CBORCoding; packageProductDependencies = ( - DD02B82227476BBA007F5569 /* Half */, ); productName = CBORCoding; productReference = DD86D53D23D11B3E0046E63E /* CBORCoding.framework */; @@ -510,6 +565,7 @@ DD86D56C23D11C860046E63E /* Sources */, DD86D56D23D11C860046E63E /* Frameworks */, DD86D56E23D11C860046E63E /* Resources */, + 8EBD205E2B03BAA400036789 /* Embed Frameworks */, ); buildRules = ( ); @@ -518,7 +574,6 @@ ); name = "CBORCoding macOS"; packageProductDependencies = ( - DD02B82527476BC2007F5569 /* Half */, ); productName = "CBORCoding macOS"; productReference = DD86D57023D11C860046E63E /* CBORCoding.framework */; @@ -550,6 +605,7 @@ DD86D58823D11CA00046E63E /* Sources */, DD86D58923D11CA00046E63E /* Frameworks */, DD86D58A23D11CA00046E63E /* Resources */, + 8EBD20622B03BAA900036789 /* Embed Frameworks */, ); buildRules = ( ); @@ -558,7 +614,6 @@ ); name = "CBORCoding tvOS"; packageProductDependencies = ( - DD02B82727476BC5007F5569 /* Half */, ); productName = "CBORCoding tvOS"; productReference = DD86D58C23D11CA00046E63E /* CBORCoding.framework */; @@ -590,6 +645,7 @@ DD86D5C023D11D140046E63E /* Sources */, DD86D5C123D11D140046E63E /* Frameworks */, DD86D5C223D11D140046E63E /* Resources */, + 8EBD20662B03BAAC00036789 /* Embed Frameworks */, ); buildRules = ( ); @@ -598,7 +654,6 @@ ); name = "CBORCoding watchOS"; packageProductDependencies = ( - DD02B82927476BC9007F5569 /* Half */, ); productName = "CBORCoding watchOS"; productReference = DD86D5C423D11D140046E63E /* CBORCoding.framework */; @@ -610,8 +665,9 @@ DD86D53423D11B3E0046E63E /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 1310; - LastUpgradeCheck = 1310; + LastUpgradeCheck = 1500; ORGANIZATIONNAME = SomeRandomiOSDev; TargetAttributes = { DD2FBC27258BE8BB00DB3211 = { @@ -666,7 +722,6 @@ ); mainGroup = DD86D53323D11B3E0046E63E; packageReferences = ( - DD02B82127476BBA007F5569 /* XCRemoteSwiftPackageReference "Half" */, ); productRefGroup = DD86D53E23D11B3E0046E63E /* Products */; projectDirPath = ""; @@ -766,6 +821,7 @@ }; DD86D56823D11C550046E63E /* Run SwiftLint */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -780,7 +836,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if (echo \"$SKIP_SWIFTLINT\" | grep -iq \"^YES$\"); then\n echo \"SKIP_SWIFTLINT=YES | Skipping SwiftLint\"\nelse\n if which swiftlint >/dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n"; + shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\n\nif (echo \"$SKIP_SWIFTLINT\" | grep -iq \"^YES$\"); then\n echo \"SKIP_SWIFTLINT=YES | Skipping SwiftLint\"\nelse\n if which swiftlint >/dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -1041,6 +1097,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -1055,8 +1112,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MACOSX_DEPLOYMENT_TARGET = 10.10; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -1064,10 +1121,10 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TVOS_DEPLOYMENT_TARGET = 9.0; + TVOS_DEPLOYMENT_TARGET = 12.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - WATCHOS_DEPLOYMENT_TARGET = 2.0; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Debug; }; @@ -1075,6 +1132,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -1110,6 +1168,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1118,19 +1177,19 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MACOSX_DEPLOYMENT_TARGET = 10.10; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; - TVOS_DEPLOYMENT_TARGET = 9.0; + TVOS_DEPLOYMENT_TARGET = 12.0; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - WATCHOS_DEPLOYMENT_TARGET = 2.0; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Release; }; @@ -1144,6 +1203,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1151,6 +1211,8 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1171,6 +1233,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1178,6 +1241,8 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1232,6 +1297,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + ENABLE_USER_SCRIPT_SANDBOXING = NO; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -1240,6 +1306,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + ENABLE_USER_SCRIPT_SANDBOXING = NO; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -1251,10 +1318,12 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1262,6 +1331,8 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1279,10 +1350,12 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1290,6 +1363,8 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1307,6 +1382,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; INFOPLIST_FILE = "Plists/CBORCodingTests-Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1329,6 +1405,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; INFOPLIST_FILE = "Plists/CBORCodingTests-Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1352,6 +1429,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1359,6 +1437,8 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1380,6 +1460,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1387,6 +1468,8 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1451,6 +1534,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1458,6 +1542,8 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1480,6 +1566,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; INFOPLIST_FILE = "Plists/CBORCoding-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1487,6 +1574,8 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14"; PRODUCT_BUNDLE_IDENTIFIER = com.somerandomiosdev.cborcoding; PRODUCT_NAME = CBORCoding; RUN_DOCUMENTATION_COMPILER = YES; @@ -1600,40 +1689,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - -/* Begin XCRemoteSwiftPackageReference section */ - DD02B82127476BBA007F5569 /* XCRemoteSwiftPackageReference "Half" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/SomeRandomiOSDev/Half"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.3.1; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - DD02B82227476BBA007F5569 /* Half */ = { - isa = XCSwiftPackageProductDependency; - package = DD02B82127476BBA007F5569 /* XCRemoteSwiftPackageReference "Half" */; - productName = Half; - }; - DD02B82527476BC2007F5569 /* Half */ = { - isa = XCSwiftPackageProductDependency; - package = DD02B82127476BBA007F5569 /* XCRemoteSwiftPackageReference "Half" */; - productName = Half; - }; - DD02B82727476BC5007F5569 /* Half */ = { - isa = XCSwiftPackageProductDependency; - package = DD02B82127476BBA007F5569 /* XCRemoteSwiftPackageReference "Half" */; - productName = Half; - }; - DD02B82927476BC9007F5569 /* Half */ = { - isa = XCSwiftPackageProductDependency; - package = DD02B82127476BBA007F5569 /* XCRemoteSwiftPackageReference "Half" */; - productName = Half; - }; -/* End XCSwiftPackageProductDependency section */ }; rootObject = DD86D53423D11B3E0046E63E /* Project object */; } diff --git a/CBORCoding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CBORCoding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 88442a7..0000000 --- a/CBORCoding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,16 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "Half", - "repositoryURL": "https://github.com/SomeRandomiOSDev/Half", - "state": { - "branch": null, - "revision": "8c80711c6ff57caa51e73e3b97a841c414af06cf", - "version": "1.3.1" - } - } - ] - }, - "version": 1 -} diff --git a/CBORCoding.xcodeproj/xcshareddata/xcschemes/CBORCoding macOS Tests.xcscheme b/CBORCoding.xcodeproj/xcshareddata/xcschemes/CBORCoding macOS Tests.xcscheme index 53fd81d..16d2324 100644 --- a/CBORCoding.xcodeproj/xcshareddata/xcschemes/CBORCoding macOS Tests.xcscheme +++ b/CBORCoding.xcodeproj/xcshareddata/xcschemes/CBORCoding macOS Tests.xcscheme @@ -1,6 +1,6 @@ + + + + + + diff --git a/Half b/Half new file mode 160000 index 0000000..bb32fc7 --- /dev/null +++ b/Half @@ -0,0 +1 @@ +Subproject commit bb32fc7a5d5cfcee01e5442b1381450b1fcd4803 diff --git a/Package.resolved b/Package.resolved index 88442a7..b9d4306 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/SomeRandomiOSDev/Half", "state": { "branch": null, - "revision": "8c80711c6ff57caa51e73e3b97a841c414af06cf", - "version": "1.3.1" + "revision": "bb32fc7a5d5cfcee01e5442b1381450b1fcd4803", + "version": "1.4.1" } } ] diff --git a/Package.swift b/Package.swift index b77b5ec..f961d75 100644 --- a/Package.swift +++ b/Package.swift @@ -1,14 +1,14 @@ -// swift-tools-version:5.5 +// swift-tools-version:5.0 import PackageDescription let package = Package( name: "CBORCoding", platforms: [ - .iOS("9.0"), - .macOS("10.10"), - .tvOS("9.0"), - .watchOS("2.0") + .iOS("12.0"), + .macOS("10.13"), + .tvOS("12.0"), + .watchOS("4.0") ], products: [ @@ -16,13 +16,11 @@ let package = Package( ], dependencies: [ - .package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.3.1") + .package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.4.1") ], targets: [ .target(name: "CBORCoding", dependencies: ["Half"]), .testTarget(name: "CBORCodingTests", dependencies: ["CBORCoding", "Half"]) - ], - - swiftLanguageVersions: [.version("4.2"), .version("5")] + ] ) diff --git a/Package@swift-4.2.swift b/Package@swift-4.2.swift deleted file mode 100644 index 8eab283..0000000 --- a/Package@swift-4.2.swift +++ /dev/null @@ -1,21 +0,0 @@ -// swift-tools-version:4.2 -import PackageDescription - -let package = Package( - name: "CBORCoding", - - products: [ - .library(name: "CBORCoding", targets: ["CBORCoding"]) - ], - - dependencies: [ - .package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.3.1") - ], - - targets: [ - .target(name: "CBORCoding", dependencies: ["Half"]), - .testTarget(name: "CBORCodingTests", dependencies: ["CBORCoding", "Half"]) - ], - - swiftLanguageVersions: [.v4_2] -) diff --git a/Package@swift-5.0.swift b/Package@swift-5.0.swift deleted file mode 100644 index 72713d3..0000000 --- a/Package@swift-5.0.swift +++ /dev/null @@ -1,28 +0,0 @@ -// swift-tools-version:5.0 -import PackageDescription - -let package = Package( - name: "CBORCoding", - - platforms: [ - .iOS("9.0"), - .macOS("10.10"), - .tvOS("9.0"), - .watchOS("2.0") - ], - - products: [ - .library(name: "CBORCoding", targets: ["CBORCoding"]) - ], - - dependencies: [ - .package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.3.1") - ], - - targets: [ - .target(name: "CBORCoding", dependencies: ["Half"]), - .testTarget(name: "CBORCodingTests", dependencies: ["CBORCoding", "Half"]) - ], - - swiftLanguageVersions: [.version("4.2"), .version("5")] -) diff --git a/README.md b/README.md index 080cde7..3f70f3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # CBORCoding -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d30d31c29f17449481b97a04610ff5b9)](https://app.codacy.com/app/SomeRandomiOSDev/CBORCoding?utm_source=github.com&utm_medium=referral&utm_content=SomeRandomiOSDev/CBORCoding&utm_campaign=Badge_Grade_Dashboard) [![License MIT](https://img.shields.io/cocoapods/l/CBORCoding.svg)](https://cocoapods.org/pods/CBORCoding) [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CBORCoding.svg)](https://cocoapods.org/pods/CBORCoding) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) diff --git a/Sources/CBORCoding/CBOR.swift b/Sources/CBORCoding/CBOR.swift index 8a19f37..04e4a11 100644 --- a/Sources/CBORCoding/CBOR.swift +++ b/Sources/CBORCoding/CBOR.swift @@ -321,7 +321,8 @@ public enum CBOR { /// The string composed by joining together all of the data chunks and interpreting /// it as a UTF8 encoded string. - @inline(__always) public var stringValue: String? { + @inline(__always) + public var stringValue: String? { return stringValue(as: .utf8) } diff --git a/Sources/CBORCoding/CBORDecoder.swift b/Sources/CBORCoding/CBORDecoder.swift index 9343c31..5609fb8 100644 --- a/Sources/CBORCoding/CBORDecoder.swift +++ b/Sources/CBORCoding/CBORDecoder.swift @@ -6,7 +6,7 @@ // import Foundation -import Half +@_implementationOnly import Half #if canImport(Combine) import Combine @@ -245,7 +245,7 @@ internal class __CBORDecoder: Decoder, SingleValueDecodingContainer { try expectNonNull(type) guard let array = storage.topContainer as? [Any], array.count == 3, - let tag = array[0] as? CBOR.Tag, (tag == .decimalFraction || tag == .bigfloat) else { + let tag = array[0] as? CBOR.Tag, tag == .decimalFraction || tag == .bigfloat else { throw DecodingError._typeMismatch(at: codingPath, expectation: type, reality: storage.topContainer) } guard tag == .decimalFraction else { @@ -262,7 +262,7 @@ internal class __CBORDecoder: Decoder, SingleValueDecodingContainer { try expectNonNull(type) guard let array = storage.topContainer as? [Any], array.count == 3, - let tag = array[0] as? CBOR.Tag, (tag == .decimalFraction || tag == .bigfloat) else { + let tag = array[0] as? CBOR.Tag, tag == .decimalFraction || tag == .bigfloat else { throw DecodingError._typeMismatch(at: codingPath, expectation: type, reality: storage.topContainer) } guard tag == .bigfloat else { diff --git a/Sources/CBORCoding/CBOREncoder.swift b/Sources/CBORCoding/CBOREncoder.swift index d89c08a..6ed43c0 100644 --- a/Sources/CBORCoding/CBOREncoder.swift +++ b/Sources/CBORCoding/CBOREncoder.swift @@ -6,7 +6,7 @@ // import Foundation -import Half +@_implementationOnly import Half #if canImport(Combine) import Combine @@ -600,10 +600,6 @@ internal class __CBOREncoder: CBOREncoderProtocol, SingleValueEncodingContainer var rawValue: UInt - init(rawValue: UInt) { - self.rawValue = rawValue - } - // MARK: Constants static let indefinite = ContainerLength(rawValue: 0x01) diff --git a/Sources/CBORCoding/CBORParser.swift b/Sources/CBORCoding/CBORParser.swift index 0566522..019b967 100644 --- a/Sources/CBORCoding/CBORParser.swift +++ b/Sources/CBORCoding/CBORParser.swift @@ -6,7 +6,7 @@ // import Foundation -import Half +@_implementationOnly import Half // MARK: - CBORParser Definition @@ -639,6 +639,12 @@ internal class CBORParser { } else { result = (.nan, 3) } + } else if half.isInfinite { + if half.sign == .minus { + result = (-.infinity, 3) + } else { + result = (.infinity, 3) + } } else if let value = T(exactly: half) { result = (value, 3) } else { @@ -659,6 +665,12 @@ internal class CBORParser { } else { result = (.nan, 5) } + } else if float.isInfinite { + if float.sign == .minus { + result = (-.infinity, 5) + } else { + result = (.infinity, 5) + } } else if let value = T(exactly: float) { result = (value, 5) } else { @@ -679,6 +691,12 @@ internal class CBORParser { } else { result = (.nan, 9) } + } else if double.isInfinite { + if double.sign == .minus { + result = (-.infinity, 9) + } else { + result = (.infinity, 9) + } } else if let value = T(exactly: double) { result = (value, 9) } else { @@ -726,7 +744,7 @@ internal class CBORParser { if data.count >= 5 { let upper = UInt32(data[data.index(data.startIndex, offsetBy: 1)]) << 24 | UInt32(data[data.index(data.startIndex, offsetBy: 2)]) << 16 - let lower = UInt32(data[data.index(data.startIndex, offsetBy: 3)]) << 8 | + let lower = UInt32(data[data.index(data.startIndex, offsetBy: 3)]) << 8 | UInt32(data[data.index(data.startIndex, offsetBy: 4)]) result = (T(exactly: upper | lower), 5) @@ -747,7 +765,7 @@ internal class CBORParser { do { let lower1 = UInt64(data[data.index(data.startIndex, offsetBy: 5)]) << 24 | UInt64(data[data.index(data.startIndex, offsetBy: 6)]) << 16 - let lower2 = UInt64(data[data.index(data.startIndex, offsetBy: 7)]) << 8 | + let lower2 = UInt64(data[data.index(data.startIndex, offsetBy: 7)]) << 8 | UInt64(data[data.index(data.startIndex, offsetBy: 8)]) lower = lower1 | lower2 diff --git a/Tests/CBORCodingTests/CBORDecoderTests.swift b/Tests/CBORCodingTests/CBORDecoderTests.swift index 0976f41..25a7634 100644 --- a/Tests/CBORCodingTests/CBORDecoderTests.swift +++ b/Tests/CBORCodingTests/CBORDecoderTests.swift @@ -5,7 +5,7 @@ // Copyright © 2021 SomeRandomiOSDev. All rights reserved. // -// swiftlint:disable nesting function_body_length force_cast identifier_name opening_brace comma implicitly_unwrapped_optional number_separator force_unwrapping +// swiftlint:disable nesting function_body_length force_cast identifier_name opening_brace comma implicitly_unwrapped_optional number_separator force_unwrapping closure_spacing @testable import CBORCoding import Half @@ -1248,3 +1248,5 @@ class CBORDecoderTests: XCTestCase { return Calendar.current.date(from: components)! } } + +// swiftlint:enable nesting function_body_length force_cast identifier_name opening_brace comma implicitly_unwrapped_optional number_separator force_unwrapping closure_spacing diff --git a/Tests/CBORCodingTests/CBOREncoderTests.swift b/Tests/CBORCodingTests/CBOREncoderTests.swift index b85a428..4a1e094 100644 --- a/Tests/CBORCodingTests/CBOREncoderTests.swift +++ b/Tests/CBORCodingTests/CBOREncoderTests.swift @@ -1434,3 +1434,5 @@ class CBOREncoderTests: XCTestCase { return Calendar.current.date(from: components)! } } + +// swiftlint:enable comma nesting function_body_length identifier_name force_try force_cast number_separator force_unwrapping diff --git a/Tests/CBORCodingTests/CBORParserTests.swift b/Tests/CBORCodingTests/CBORParserTests.swift index d77d272..d2391d8 100644 --- a/Tests/CBORCodingTests/CBORParserTests.swift +++ b/Tests/CBORCodingTests/CBORParserTests.swift @@ -1282,3 +1282,5 @@ class CBORParserTests: XCTestCase { return Calendar.current.date(from: components)! } } + +// swiftlint:enable function_body_length force_cast comma force_try implicitly_unwrapped_optional number_separator force_unwrapping diff --git a/Tests/CBORCodingTests/CBORTests.swift b/Tests/CBORCodingTests/CBORTests.swift index 2df6092..aff06d5 100644 --- a/Tests/CBORCodingTests/CBORTests.swift +++ b/Tests/CBORCodingTests/CBORTests.swift @@ -560,3 +560,5 @@ class CBORTests: XCTestCase { return data } } + +// swiftlint:enable comma nesting force_try implicitly_unwrapped_optional diff --git a/Tests/CBORCodingTests/ContainersTests.swift b/Tests/CBORCodingTests/ContainersTests.swift index 453b684..692379f 100644 --- a/Tests/CBORCodingTests/ContainersTests.swift +++ b/Tests/CBORCodingTests/ContainersTests.swift @@ -164,3 +164,5 @@ class ContainersTests: XCTestCase { XCTAssertNil(pair) } } + +// swiftlint:enable identifier_name force_unwrapping diff --git a/scripts/findworkspace.sh b/scripts/findworkspace.sh new file mode 100755 index 0000000..2fed6c4 --- /dev/null +++ b/scripts/findworkspace.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# +# xcframework.sh +# Usage example: ./findworkspace.sh --workspace-name + +# Set Script Variables + +SCRIPT="$("$(dirname "$0")/resolvepath.sh" "$0")" +SCRIPTS_DIR="$(dirname "$SCRIPT")" +ROOT_DIR="$(dirname "$SCRIPTS_DIR")" + +EXIT_CODE=0 + +# Help + +function printhelp() { + local HELP="Locates the Xcode workspace for the current working directory.\n\n" + HELP+="findworkspace.sh [--help | -h] [--workspace-name ]\n" + HELP+="\n" + HELP+="--help, -h) Print this help message and exit.\n" + HELP+="\n" + HELP+="--workspace-name) The name of the workspace to locate. If not provided,\n" + HELP+=" the working directory is searched for a Xcode workspace.\n" + + IFS='%' + echo -e "$HELP" 1>&2 + unset IFS + + exit $EXIT_CODE +} + +# Parse Arguments + +while [[ $# -gt 0 ]]; do + case "$1" in + --workspace-name) + WORKSPACE_NAME="$2" + shift # --workspace-name + shift # + ;; + + --help | -h) + printhelp + ;; + + *) + echo -e "Unknown argument: $1\n" 1>&2 + EXIT_CODE=1 + printhelp + ;; + esac +done + +# + +if [ -z ${WORKSPACE_NAME+x} ]; then + WORKSPACES=($(ls "$ROOT_DIR" | grep \.xcworkspace$)) + + if [ "${#WORKSPACES[@]}" == "0" ]; then + echo -e "No Xcode workspaces found in root directory. Try specifying a workspace name:\n" 1>&2 + exit 1 + elif [ "${#WORKSPACES[@]}" == "1" ]; then + WORKSPACE_NAME="${WORKSPACES[0]}" + WORKSPACE_NAME="${WORKSPACE_NAME%.*}" + else + echo -e "More than 1 Xcode workspaces found in root directory. Specify which workspace to use:\n" 1>&2 + exit 1 + fi +else + if [ "${WORKSPACE_NAME##*.}" == "xcworkspace" ]; then + if [ -e "$ROOT_DIR/$WORKSPACE_NAME" ]; then + WORKSPACE_NAME="${WORKSPACE_NAME%.*}" + else + ERROR_MESSAGE="Unable to locate specified Xcode workspace: $ROOT_DIR/$WORKSPACE_NAME\n" + fi + elif [ ! -e "$ROOT_DIR/$WORKSPACE_NAME.xcworkspace" ]; then + ERROR_MESSAGE="Unable to locate specified Xcode workspace: $ROOT_DIR/$WORKSPACE_NAME.xcworkspace\n" + fi + + if [ "${#ERROR_MESSAGE[@]}" != "0" ]; then + echo -e "$ERROR_MESSAGE" 1>&2 + exit 1 + fi +fi + +# + +echo "$WORKSPACE_NAME" +exit 0 diff --git a/scripts/workflowtests.sh b/scripts/workflowtests.sh index 3a6ed0a..20d5b31 100755 --- a/scripts/workflowtests.sh +++ b/scripts/workflowtests.sh @@ -13,567 +13,57 @@ CURRENT_DIR="$(pwd -P)" EXIT_CODE=0 EXIT_MESSAGE="" -# Help +# Import Helper Functions -function printhelp() { - local HELP="Run tests for the Github Action workflows.\n" - HELP+="\n" - HELP+="workflowtests.sh [--help | -h] [--verbose] [--project-name ]\n" - HELP+=" [--no-clean | --no-clean-on-fail] [--is-running-in-temp-env]\n" - HELP+="\n" - HELP+="--help, -h) Print this help message and exit.\n" - HELP+="\n" - HELP+="--help, -h) Enable verbose logging.\n" - HELP+="\n" - HELP+="--project-name) The name of the project to run tests against. If not\n" - HELP+=" provided it will attempt to be resolved by searching\n" - HELP+=" the working directory for an Xcode project and using\n" - HELP+=" its name.\n" - HELP+="\n" - HELP+="--no-clean) When not running in a temporary environment, do not\n" - HELP+=" clean up the temporary project created to run these\n" - HELP+=" tests upon completion.\n" - HELP+="\n" - HELP+="--no-clean-on-fail) Same as --no-clean with the exception that if the\n" - HELP+=" succeed clean up will continue as normal. This is\n" - HELP+=" mutually exclusive with --no-clean with --no-clean\n" - HELP+=" taking precedence.\n" - HELP+="\n" - HELP+="--is-running-in-temp-env) Setting this flag tells this script that the\n" - HELP+=" environment (directory) in which it is running is a\n" - HELP+=" temporary environment and it need not worry about\n" - HELP+=" dirtying up the directory or creating/deleting files\n" - HELP+=" and folders. USE CAUTION WITH THIS OPTION.\n" - HELP+="\n" - HELP+=" When this flag is NOT set, a copy of the containing\n" - HELP+=" working folder is created in a temporary location and\n" - HELP+=" removed (unless --no-clean is set) after the tests\n" - HELP+=" have finished running." - - IFS='%' - echo -e "$HELP" 1>&2 - unset IFS - - exit $EXIT_CODE -} +source "$SCRIPTS_DIR/workflowtests/helper_functions.sh" # Parse Arguments -while [[ $# -gt 0 ]]; do - case "$1" in - --project-name) - PROJECT_NAME="$2" - shift # --project-name - shift # - ;; - - --is-running-in-temp-env) - IS_RUNNING_IN_TEMP_ENV=1 - shift # --is-running-in-temp-env - ;; - - --no-clean) - NO_CLEAN=1 - shift # --no-clean - ;; - - --no-clean-on-fail) - NO_CLEAN_ON_FAIL=1 - shift # --no-clean-on-fail - ;; - - --verbose) - VERBOSE=1 - shift # --verbose - ;; - - --help | -h) - printhelp - ;; - - *) - "$SCRIPTS_DIR/printformat.sh" "foreground:red" "Unknown argument: $1\n" 1>&2 - EXIT_CODE=1 - printhelp - ;; - esac -done - -if [ -z ${IS_RUNNING_IN_TEMP_ENV+x} ]; then - IS_RUNNING_IN_TEMP_ENV=0 -fi - -if [ -z ${NO_CLEAN+x} ]; then - NO_CLEAN=0 -fi - -if [ -z ${NO_CLEAN_ON_FAIL+x} ]; then - NO_CLEAN_ON_FAIL=0 -fi - -# Function Definitions - -function cleanup() { - if [ "$IS_RUNNING_IN_TEMP_ENV" == "0" ]; then - if [[ "$NO_CLEAN" == "1" ]] || [[ "$NO_CLEAN_ON_FAIL" == "1" && "$EXIT_CODE" != "0" ]]; then - echo "Test Project: $OUTPUT_DIR" - else - cd "$CURRENT_DIR" - rm -rf "$TEMP_DIR" - fi - fi - - # - - local CARTHAGE_CACHE="$HOME/Library/Caches/org.carthage.CarthageKit" - if [ -e "$CARTHAGE_CACHE" ]; then - if [ -e "$CARTHAGE_CACHE/dependencies/$PROJECT_NAME" ]; then - rm -rf "$CARTHAGE_CACHE/dependencies/$PROJECT_NAME" - fi - - for DIR in $(find "$CARTHAGE_CACHE/DerivedData" -mindepth 1 -maxdepth 1 -type d); do - if [ -e "$DIR/$PROJECT_NAME" ]; then - rm -rf "$DIR/$PROJECT_NAME" - fi - done - fi - - # - - if [ "${#EXIT_MESSAGE}" != 0 ]; then - if [ "$EXIT_MESSAGE" == "**printhelp**" ]; then - printhelp - else - echo -e "$EXIT_MESSAGE" 1>&2 - fi - fi - - exit $EXIT_CODE -} - -function checkresult() { - if [ "$1" != "0" ]; then - if [ "${#2}" != "0" ]; then - EXIT_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:red" "$2")" - else - EXIT_MESSAGE="**printhelp**" - fi - - EXIT_CODE=$1 - cleanup - fi -} - -function printstep() { - "$SCRIPTS_DIR/printformat.sh" "foreground:green" "$1" -} - -function setuptemp() { - TEMP_DIR="$(mktemp -d)" - - local TEMP_NAME="$(basename "$(mktemp -u "$TEMP_DIR/${PROJECT_NAME}WorkflowTests_XXXXXXXX")")" - local OUTPUT_DIR="$TEMP_DIR/$TEMP_NAME" - - cp -R "$ROOT_DIR" "$OUTPUT_DIR" - if [ "$?" != "0" ]; then exit $?; fi - - if [ -e "$OUTPUT_DIR/.build" ]; then - rm -rf "$OUTPUT_DIR/.build" - fi - if [ -e "$OUTPUT_DIR/.swiftpm" ]; then - rm -rf "$OUTPUT_DIR/.swiftpm" - fi - if [ -e "$OUTPUT_DIR/.xcodebuild" ]; then - rm -rf "$OUTPUT_DIR/.xcodebuild" - fi - - echo "$OUTPUT_DIR" -} - -function createlogfile() { - if [ ! -d "$OUTPUT_DIR/Logs" ]; then - mkdir -p "$OUTPUT_DIR/Logs" - fi - - local LOG="$OUTPUT_DIR/Logs/$1.log" - touch "$LOG" - - echo "$LOG" -} - -function errormessage() { - local ERROR_MESSAGE="$1" - - if [[ "$NO_CLEAN" == "1" ]] || [[ "$NO_CLEAN_ON_FAIL" == "1" ]]; then - ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "${1%.}. See log for more details: $("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "$2")")" - elif [ "$VERBOSE" != "1" ]; then - ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "${1%.}. Use the '--no-clean' or '--no-clean-on-fail' flag to inspect the logs.")" - fi - - echo "$ERROR_MESSAGE" -} - -function interrupt() { - EXIT_CODE=$SIGINT - EXIT_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Tests run was interrupted..")" - - cleanup -} +source "$SCRIPTS_DIR/workflowtests/parse_arguments.sh" # Setup trap interrupt SIGINT # Cleanup if the user aborts (Ctrl + C) -# - -ARGUMENTS=() -if [ "${#PROJECT_NAME}" != 0 ]; then - ARGUMENTS=(--project-name "$PROJECT_NAME") -fi - -PROJECT_NAME="$("$SCRIPTS_DIR/findproject.sh" "${ARGUMENTS[@]}")" -checkresult $? - -# - -VERBOSE_FLAGS=() -if [ "$VERBOSE" == "1" ]; then - VERBOSE_FLAGS=(--verbose) -fi - -# - -if [ "$IS_RUNNING_IN_TEMP_ENV" == "1" ]; then - OUTPUT_DIR="$ROOT_DIR" -else - OUTPUT_DIR="$(setuptemp)" - echo -e "Testing from Temporary Directory: $("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "$OUTPUT_DIR")" -fi - # Check For Dependencies -cd "$OUTPUT_DIR" -printstep "Checking for Test Dependencies..." - -### Carthage - -if which carthage >/dev/null; then - CARTHAGE_VERSION="$(carthage version)" - echo "Carthage: $CARTHAGE_VERSION" - - "$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0" - - if [ $? -lt 0 ]; then - "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Carthage version of at least 0.37.0 is recommended for running these unit tests" - fi -else - checkresult -1 "Carthage is not installed and is required for running unit tests: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://github.com/Carthage/Carthage#installing-carthage")" -fi - -### CocoaPods - -if which pod >/dev/null; then - PODS_VERSION="$(pod --version)" - "$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3" - - if [ $? -ge 0 ]; then - echo "CocoaPods: $PODS_VERSION" - else - checkresult -1 "These unit tests require version 1.7.3 or later of CocoaPods: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods")" - fi -else - checkresult -1 "CocoaPods is not installed and is required for running unit tests: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#installation")" -fi - -### SwiftLint - -if which swiftlint >/dev/null; then - echo "SwiftLint: $(swiftlint --version)" -else - checkresult -1 "SwiftLint is not installed and is required for running unit tests: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://github.com/realm/SwiftLint#installation")" -fi +source "$SCRIPTS_DIR/workflowtests/check_dependencies.sh" # Run Tests printstep "Running Tests...\n" -### Carthage Workflow - -printstep "Testing 'carthage.yml' Workflow..." - -git add . >/dev/null 2>&1 -git commit -m "Commit" --no-gpg-sign >/dev/null 2>&1 -git tag | xargs git tag -d >/dev/null 2>&1 -git tag --no-sign 1.0 >/dev/null 2>&1 -checkresult $? "'Create Cartfile' step of 'carthage.yml' workflow failed." - -echo "git \"file://$OUTPUT_DIR\"" > ./Cartfile - -./scripts/carthage.sh update "${VERBOSE_FLAGS[@]}" -checkresult $? "'Build' step of 'carthage.yml' workflow failed." - -printstep "'carthage.yml' Workflow Tests Passed\n" - -### CocoaPods Workflow - -printstep "Testing 'cocoapods.yml' Workflow..." - -pod lib lint "${VERBOSE_FLAGS[@]}" -checkresult $? "'Lint (Dynamic)' step of 'cocoapods.yml' workflow failed." - -pod lib lint --use-libraries "${VERBOSE_FLAGS[@]}" -checkresult $? "'Lint (Static)' step of 'cocoapods.yml' workflow failed." - -printstep "'cocoapods.yml' Workflow Tests Passed\n" - -### Documentation Workflow - -printstep "Testing 'documentation.yml' Workflow..." - -ERROR_MESSAGE="'Build Documentation' step of 'documentation.yml' workflow failed." - -if [ "$VERBOSE" == "1" ]; then - xcodebuild docbuild -project "$PROJECT_NAME.xcodeproj" -scheme "$PROJECT_NAME" -destination "generic/platform=iOS" -derivedDataPath "$OUTPUT_DIR/.xcodebuild" SKIP_SWIFTLINT=YES -else - LOG="$(createlogfile "build-documentation")" - ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" - - # - - xcodebuild docbuild -project "$PROJECT_NAME.xcodeproj" -scheme "$PROJECT_NAME" -destination "generic/platform=iOS" -derivedDataPath "$OUTPUT_DIR/.xcodebuild" SKIP_SWIFTLINT=YES > "$LOG" 2>&1 -fi +# Carthage +source "$SCRIPTS_DIR/workflowtests/carthage_tests.sh" -checkresult $? "$ERROR_MESSAGE" +# Cocoapods +source "$SCRIPTS_DIR/workflowtests/cocoapods_tests.sh" -printstep "'documentation.yml' Workflow Tests Passed\n" +# Documentation +source "$SCRIPTS_DIR/workflowtests/documentation_tests.sh" -### Swift Package Workflow +# Swift Package +source "$SCRIPTS_DIR/workflowtests/swift_package_tests.sh" -printstep "Testing 'swift-package.yml' Workflow..." +# SwiftLint +source "$SCRIPTS_DIR/workflowtests/swiftlint_tests.sh" -if [ "$VERBOSE" == "1" ]; then - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" - swift build "${VERBOSE_FLAGS[@]}" - checkresult $? "'Build' step of 'swift-package.yml' workflow failed." +# XCFramework +source "$SCRIPTS_DIR/workflowtests/xcframework_tests.sh" - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" - swift test --enable-code-coverage "${VERBOSE_FLAGS[@]}" - checkresult $? "'Test' step of 'swift-package.yml' workflow failed." -else - LOG="$(createlogfile "build-swiftpackage")" - - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" - swift build > "$LOG" 2>&1 - checkresult $? "$(errormessage "'Build' step of 'swift-package.yml' workflow failed." "$LOG")" - - # - - LOG="$(createlogfile "test-swiftpackage")" - - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" - swift test --enable-code-coverage > "$LOG" 2>&1 - checkresult $? "$(errormessage "'Test' step of 'swift-package.yml' workflow failed." "$LOG")" -fi - -xcrun llvm-cov export --format=lcov --instr-profile=".build/debug/codecov/default.profdata" ".build/debug/${PROJECT_NAME}PackageTests.xctest/Contents/MacOS/${PROJECT_NAME}PackageTests" > "./codecov.lcov" -checkresult $? "'Generate Code Coverage File' step of 'swift-package.yml' workflow failed." - -printstep "'swift-package.yml' Workflow Tests Passed\n" - -### SwiftLint Workflow - -printstep "Testing 'swiftlint.yml' Workflow..." - -swiftlint -checkresult $? "'Run SwiftLint' step of 'swiftlint.yml' workflow failed." - -printstep "'swiftlint.yml' Workflow Tests Passed\n" - -### XCFramework Workflow - -printstep "Testing 'xcframework.yml' Workflow..." - -./scripts/xcframework.sh --project-name "$PROJECT_NAME" --output "$OUTPUT_DIR" "${VERBOSE_FLAGS[@]}" -- RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES -checkresult $? "'Build' step of 'xcframework.yml' workflow failed." - -printstep "'xcframework.yml' Workflow Tests Passed\n" - -### Upload Assets Workflow - -printstep "Testing 'upload-assets.yml' Workflow..." - -echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating zip archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.xcframework")" -zip -rX "$PROJECT_NAME.xcframework.zip" "$PROJECT_NAME.xcframework" >/dev/null 2>&1 -checkresult $? "'Create XCFramework Zip' step of 'upload-assets.yml' workflow failed." - -echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating tar archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.xcframework")" -tar -zcvf "$PROJECT_NAME.xcframework.tar.gz" "$PROJECT_NAME.xcframework" >/dev/null 2>&1 -checkresult $? "'Create XCFramework Tar' step of 'upload-assets.yml' workflow failed." - -# - -DOCC_ARCHIVE="$(find "$OUTPUT_DIR/.xcodebuild" -type d -name "$PROJECT_NAME.doccarchive")" - -if [ "${DOCC_ARCHIVE[@]]}" == "0" ]; then - checkresult 1 "'Build Documentation' step of 'upload-assets.yml' workflow failed." -else - mv "${DOCC_ARCHIVE%/}" "$OUTPUT_DIR/$PROJECT_NAME.doccarchive" - checkresult $? "'Build Documentation' step of 'upload-assets.yml' workflow failed." -fi - -# - -echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating zip archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.doccarchive")" -zip -rX "$PROJECT_NAME.doccarchive.zip" "$PROJECT_NAME.doccarchive" >/dev/null 2>&1 -checkresult $? "'Create Documentation Zip' step of 'upload-assets.yml' workflow failed." - -echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating tar archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.doccarchive")" -tar -zcvf "$PROJECT_NAME.doccarchive.tar.gz" "$PROJECT_NAME.doccarchive" >/dev/null 2>&1 -checkresult $? "'Create Documentation Tar' step of 'upload-assets.yml' workflow failed." - -printstep "'upload-assets.yml' Workflow Tests Passed\n" - -### Xcodebuild Workflow +# Upload Assets +source "$SCRIPTS_DIR/workflowtests/upload_assets_tests.sh" +# Xcodebuild printstep "Testing 'xcodebuild.yml' Workflow..." -# - -for PLATFORM in "iOS" "iOS Simulator" "Mac Catalyst" "macOS" "tvOS" "tvOS Simulator" "watchOS" "watchOS Simulator"; do - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") in $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.xcodeproj")" - - SCHEME="${PROJECT_NAME}" - DESTINATION="$PLATFORM" - - case "$PLATFORM" in - "Mac Catalyst") DESTINATION="macOS,variant=Mac Catalyst" ;; - "macOS") SCHEME="${PROJECT_NAME} macOS" ;; - - "tvOS") SCHEME="${PROJECT_NAME} tvOS" ;; - "tvOS Simulator") SCHEME="${PROJECT_NAME} tvOS" ;; - - "watchOS") SCHEME="${PROJECT_NAME} watchOS" ;; - "watchOS Simulator") SCHEME="${PROJECT_NAME} watchOS" ;; - esac - - # - - ERROR_MESSAGE="'Build $PLATFORM' step of 'xcodebuild.yml' workflow failed." - - if [ "$VERBOSE" == "1" ]; then - xcodebuild -project "$PROJECT_NAME.xcodeproj" -scheme "$SCHEME" -destination "generic/platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES - else - LOG="$(createlogfile "$(echo "$PLATFORM" | tr -d ' ' | tr '[:upper:]' '[:lower:]')-build")" - ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" - - # - - xcodebuild -project "$PROJECT_NAME.xcodeproj" -scheme "$SCHEME" -destination "generic/platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES > "$LOG" 2>&1 - fi - - checkresult $? "$ERROR_MESSAGE" -done - -echo "" - -# - -IOS_SIM="$(xcrun simctl list devices available | grep "iPhone [0-9]" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" -TVOS_SIM="$(xcrun simctl list devices available | grep "Apple TV" | sort -V | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" -WATCHOS_SIM="$(xcrun simctl list devices available | grep "Apple Watch" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" - -# - -for PLATFORM in "iOS" "Mac Catalyst" "macOS" "tvOS" "watchOS"; do - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") in $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.xcodeproj")" - - SCHEME="${PROJECT_NAME}" - TESTPLAN="${PROJECT_NAME}Tests" - DESTINATION="$PLATFORM" - - case "$PLATFORM" in - "iOS") DESTINATION="iOS Simulator,name=$IOS_SIM" ;; - "Mac Catalyst") DESTINATION="macOS,variant=Mac Catalyst" ;; - - "macOS") - SCHEME="$PROJECT_NAME macOS" - TESTPLAN="$PROJECT_NAME macOS Tests" - ;; - - "tvOS") - SCHEME="$PROJECT_NAME tvOS" - TESTPLAN="$PROJECT_NAME tvOS Tests" - DESTINATION="tvOS Simulator,name=$TVOS_SIM" - ;; - - "watchOS") - SCHEME="$PROJECT_NAME watchOS" - TESTPLAN="$PROJECT_NAME watchOS Tests" - DESTINATION="watchOS Simulator,name=$WATCHOS_SIM" - ;; - esac - - # - - ERROR_MESSAGE="'Test $PLATFORM' step of 'xcodebuild.yml' workflow failed." - - if [ "$VERBOSE" == "1" ]; then - xcodebuild -project "$PROJECT_NAME.xcodeproj" -scheme "$SCHEME" -testPlan "$TESTPLAN" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test - else - LOG="$(createlogfile "$(echo "$PLATFORM" | tr -d ' ' | tr '[:upper:]' '[:lower:]')-test")" - ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" - - xcodebuild -project "$PROJECT_NAME.xcodeproj" -scheme "$SCHEME" -testPlan "$TESTPLAN" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test > "$LOG" 2>&1 - fi - - checkresult $? "$ERROR_MESSAGE" -done +#source "$SCRIPTS_DIR/workflowtests/xcodebuild_build_tests.sh" +source "$SCRIPTS_DIR/workflowtests/xcodebuild_test_tests.sh" printstep "'xcodebuild.yml' Workflow Tests Passed\n" -### Test Schemes - -printstep "Test running unit tests with test schemes..." - -for PLATFORM in "iOS" "Mac Catalyst" "macOS" "tvOS" "watchOS"; do - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") in $("$SCRIPTS_DIR/printformat.sh" "bold" "$PROJECT_NAME.xcodeproj")" - - SCHEME="${PROJECT_NAME}Tests" - DESTINATION="$PLATFORM" - - case "$PLATFORM" in - "iOS") DESTINATION="iOS Simulator,name=$IOS_SIM" ;; - "Mac Catalyst") DESTINATION="macOS,variant=Mac Catalyst" ;; - "macOS") SCHEME="$PROJECT_NAME macOS Tests" ;; - - "tvOS") - SCHEME="$PROJECT_NAME tvOS Tests" - DESTINATION="tvOS Simulator,name=$TVOS_SIM" - ;; - - "watchOS") - SCHEME="$PROJECT_NAME watchOS Tests" - DESTINATION="watchOS Simulator,name=$WATCHOS_SIM" - ;; - esac - - # - - ERROR_MESSAGE="Test $PLATFORM (Test Scheme) failed." - - if [ "$VERBOSE" == "1" ]; then - xcodebuild -project "$PROJECT_NAME.xcodeproj" -scheme "$SCHEME" -testPlan "$SCHEME" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test - else - LOG="$(createlogfile "$(echo "$PLATFORM" | tr -d ' ' | tr '[:upper:]' '[:lower:]')-test")" - ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" - - xcodebuild -project "$PROJECT_NAME.xcodeproj" -scheme "$SCHEME" -testPlan "$SCHEME" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test > "$LOG" 2>&1 - fi - - checkresult $? "$ERROR_MESSAGE" -done - -printstep "Test Scheme Unit Tests Passed\n" +# Test Schemes +source "$SCRIPTS_DIR/workflowtests/test_scheme_tests.sh" ### Success diff --git a/scripts/workflowtests/carthage_tests.sh b/scripts/workflowtests/carthage_tests.sh new file mode 100755 index 0000000..4a361ae --- /dev/null +++ b/scripts/workflowtests/carthage_tests.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# workflowtests/carthage_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'carthage.yml' Workflow..." + +git add . >/dev/null 2>&1 +git commit -m "Commit" --no-gpg-sign >/dev/null 2>&1 +git tag | xargs git tag -d >/dev/null 2>&1 +git tag --no-sign 1.0 >/dev/null 2>&1 +checkresult $? "'Create Cartfile' step of 'carthage.yml' workflow failed." + +echo "git \"file://$OUTPUT_DIR\"" > ./Cartfile + +./scripts/carthage.sh update "${VERBOSE_FLAGS[@]}" +checkresult $? "'Build' step of 'carthage.yml' workflow failed." + +printstep "'carthage.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/check_dependencies.sh b/scripts/workflowtests/check_dependencies.sh new file mode 100755 index 0000000..82afb00 --- /dev/null +++ b/scripts/workflowtests/check_dependencies.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# +# workflowtests/check_dependencies.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +cd "$OUTPUT_DIR" +printstep "Checking for Test Dependencies..." + +### Carthage + +if which carthage >/dev/null; then + CARTHAGE_VERSION="$(carthage version)" + echo "Carthage: $CARTHAGE_VERSION" + + "$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0" + + if [ $? -lt 0 ]; then + "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Carthage version of at least 0.37.0 is recommended for running these unit tests" + fi +else + checkresult -1 "Carthage is not installed and is required for running unit tests: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://github.com/Carthage/Carthage#installing-carthage")" +fi + +### CocoaPods + +if which pod >/dev/null; then + PODS_VERSION="$(pod --version)" + "$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3" + + if [ $? -ge 0 ]; then + echo "CocoaPods: $PODS_VERSION" + else + checkresult -1 "These unit tests require version 1.7.3 or later of CocoaPods: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods")" + fi +else + checkresult -1 "CocoaPods is not installed and is required for running unit tests: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#installation")" +fi + +### SwiftLint + +if which swiftlint >/dev/null; then + echo "SwiftLint: $(swiftlint --version)" +else + checkresult -1 "SwiftLint is not installed and is required for running unit tests: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://github.com/realm/SwiftLint#installation")" +fi diff --git a/scripts/workflowtests/cocoapods_tests.sh b/scripts/workflowtests/cocoapods_tests.sh new file mode 100755 index 0000000..7aa9826 --- /dev/null +++ b/scripts/workflowtests/cocoapods_tests.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# workflowtests/cocoapods_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'cocoapods.yml' Workflow..." + +pod lib lint "${VERBOSE_FLAGS[@]}" +checkresult $? "'Lint (Dynamic)' step of 'cocoapods.yml' workflow failed." + +pod lib lint --use-libraries "${VERBOSE_FLAGS[@]}" +checkresult $? "'Lint (Static)' step of 'cocoapods.yml' workflow failed." + +printstep "'cocoapods.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/documentation_tests.sh b/scripts/workflowtests/documentation_tests.sh new file mode 100755 index 0000000..8351e64 --- /dev/null +++ b/scripts/workflowtests/documentation_tests.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# workflowtests/documentation_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'documentation.yml' Workflow..." + +ERROR_MESSAGE="'Build Documentation' step of 'documentation.yml' workflow failed." + +if [ "$VERBOSE" == "1" ]; then + xcodebuild docbuild "${XCODEBUILD_ARGS[@]}" -scheme "$PRODUCT_NAME" -destination "generic/platform=iOS" -derivedDataPath "$OUTPUT_DIR/.xcodebuild" SKIP_SWIFTLINT=YES +else + LOG="$(createlogfile "build-documentation")" + ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" + + # + + xcodebuild docbuild "${XCODEBUILD_ARGS[@]}" -scheme "$PRODUCT_NAME" -destination "generic/platform=iOS" -derivedDataPath "$OUTPUT_DIR/.xcodebuild" SKIP_SWIFTLINT=YES > "$LOG" 2>&1 +fi + +checkresult $? "$ERROR_MESSAGE" + +printstep "'documentation.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/helper_functions.sh b/scripts/workflowtests/helper_functions.sh new file mode 100755 index 0000000..26c50ca --- /dev/null +++ b/scripts/workflowtests/helper_functions.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash +# +# workflowtests/helper_functions.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +function printhelp() { + local HELP="Run tests for the Github Action workflows.\n" + HELP+="\n" + HELP+="workflowtests.sh [--help | -h] [--verbose] [--project-name ]\n" + HELP+=" [--no-clean | --no-clean-on-fail] [--is-running-in-temp-env]\n" + HELP+="\n" + HELP+="--help, -h) Print this help message and exit.\n" + HELP+="\n" + HELP+="--help, -h) Enable verbose logging.\n" + HELP+="\n" + HELP+="--project-name) The name of the project to run tests against. If not\n" + HELP+=" provided it will attempt to be resolved by searching\n" + HELP+=" the working directory for an Xcode project and using\n" + HELP+=" its name.\n" + HELP+="\n" + HELP+="--workspace-name) The name of the workspace to run tests against. If not\n" + HELP+=" provided it will attempt to be resolved by searching\n" + HELP+=" the working directory for a Xcode workspace and using\n" + HELP+=" its name.\n" + HELP+="\n" + HELP+="--no-clean) When not running in a temporary environment, do not\n" + HELP+=" clean up the temporary project created to run these\n" + HELP+=" tests upon completion.\n" + HELP+="\n" + HELP+="--no-clean-on-fail) Same as --no-clean with the exception that if the\n" + HELP+=" succeed clean up will continue as normal. This is\n" + HELP+=" mutually exclusive with --no-clean with --no-clean\n" + HELP+=" taking precedence.\n" + HELP+="\n" + HELP+="--is-running-in-temp-env) Setting this flag tells this script that the\n" + HELP+=" environment (directory) in which it is running is a\n" + HELP+=" temporary environment and it need not worry about\n" + HELP+=" dirtying up the directory or creating/deleting files\n" + HELP+=" and folders. USE CAUTION WITH THIS OPTION.\n" + HELP+="\n" + HELP+=" When this flag is NOT set, a copy of the containing\n" + HELP+=" working folder is created in a temporary location and\n" + HELP+=" removed (unless --no-clean is set) after the tests\n" + HELP+=" have finished running." + + IFS='%' + echo -e "$HELP" 1>&2 + unset IFS + + exit $EXIT_CODE +} + +function cleanup() { + if [ "$IS_RUNNING_IN_TEMP_ENV" == "0" ]; then + if [[ "$NO_CLEAN" == "1" ]] || [[ "$NO_CLEAN_ON_FAIL" == "1" && "$EXIT_CODE" != "0" ]]; then + echo "Test Project: $OUTPUT_DIR" + else + cd "$CURRENT_DIR" + rm -rf "$TEMP_DIR" + fi + fi + + # + + local CARTHAGE_CACHE="$HOME/Library/Caches/org.carthage.CarthageKit" + if [ -e "$CARTHAGE_CACHE" ]; then + if [ -e "$CARTHAGE_CACHE/dependencies/$PROJECT_NAME" ]; then + rm -rf "$CARTHAGE_CACHE/dependencies/$PROJECT_NAME" + fi + + for DIR in $(find "$CARTHAGE_CACHE/DerivedData" -mindepth 1 -maxdepth 1 -type d); do + if [ -e "$DIR/$PROJECT_NAME" ]; then + rm -rf "$DIR/$PROJECT_NAME" + fi + done + fi + + # + + if [ "${#EXIT_MESSAGE}" != 0 ]; then + if [ "$EXIT_MESSAGE" == "**printhelp**" ]; then + printhelp + else + echo -e "$EXIT_MESSAGE" 1>&2 + fi + fi + + exit $EXIT_CODE +} + +function checkresult() { + if [ "$1" != "0" ]; then + if [ "${#2}" != "0" ]; then + EXIT_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:red" "$2")" + else + EXIT_MESSAGE="**printhelp**" + fi + + EXIT_CODE=$1 + cleanup + fi +} + +function printstep() { + "$SCRIPTS_DIR/printformat.sh" "foreground:green" "$1" +} + +function setuptemp() { + TEMP_DIR="$(mktemp -d)" + + local TEMP_NAME="$(basename "$(mktemp -u "$TEMP_DIR/${PROJECT_NAME}WorkflowTests_XXXXXXXX")")" + local OUTPUT_DIR="$TEMP_DIR/$TEMP_NAME" + + cp -R "$ROOT_DIR" "$OUTPUT_DIR" + if [ "$?" != "0" ]; then exit $?; fi + + if [ -e "$OUTPUT_DIR/.build" ]; then + rm -rf "$OUTPUT_DIR/.build" + fi + if [ -e "$OUTPUT_DIR/.swiftpm" ]; then + rm -rf "$OUTPUT_DIR/.swiftpm" + fi + if [ -e "$OUTPUT_DIR/.xcodebuild" ]; then + rm -rf "$OUTPUT_DIR/.xcodebuild" + fi + + echo "$OUTPUT_DIR" +} + +function createlogfile() { + if [ ! -d "$OUTPUT_DIR/Logs" ]; then + mkdir -p "$OUTPUT_DIR/Logs" + fi + + local LOG="$OUTPUT_DIR/Logs/$1.log" + touch "$LOG" + + echo "$LOG" +} + +function errormessage() { + local ERROR_MESSAGE="$1" + + if [[ "$NO_CLEAN" == "1" ]] || [[ "$NO_CLEAN_ON_FAIL" == "1" ]]; then + ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "${1%.}. See log for more details: $("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "$2")")" + elif [ "$VERBOSE" != "1" ]; then + ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "${1%.}. Use the '--no-clean' or '--no-clean-on-fail' flag to inspect the logs.")" + fi + + echo "$ERROR_MESSAGE" +} + +function interrupt() { + EXIT_CODE=$SIGINT + EXIT_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Tests run was interrupted..")" + + cleanup +} diff --git a/scripts/workflowtests/parse_arguments.sh b/scripts/workflowtests/parse_arguments.sh new file mode 100755 index 0000000..e29c5a6 --- /dev/null +++ b/scripts/workflowtests/parse_arguments.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash +# +# workflowtests/parse_arguments.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +while [[ $# -gt 0 ]]; do + case "$1" in + --project-name) + PROJECT_NAME="$2" + shift # --project-name + shift # + ;; + + --workspace-name) + WORKSPACE_NAME="$2" + shift # --workspace-name + shift # + ;; + + --is-running-in-temp-env) + IS_RUNNING_IN_TEMP_ENV=1 + shift # --is-running-in-temp-env + ;; + + --no-clean) + NO_CLEAN=1 + shift # --no-clean + ;; + + --no-clean-on-fail) + NO_CLEAN_ON_FAIL=1 + shift # --no-clean-on-fail + ;; + + --verbose) + VERBOSE=1 + shift # --verbose + ;; + + --help | -h) + printhelp + ;; + + *) + "$SCRIPTS_DIR/printformat.sh" "foreground:red" "Unknown argument: $1\n" 1>&2 + EXIT_CODE=1 + printhelp + ;; + esac +done + +# + +if [ -z ${IS_RUNNING_IN_TEMP_ENV+x} ]; then + IS_RUNNING_IN_TEMP_ENV=0 +fi + +if [ -z ${NO_CLEAN+x} ]; then + NO_CLEAN=0 +fi + +if [ -z ${NO_CLEAN_ON_FAIL+x} ]; then + NO_CLEAN_ON_FAIL=0 +fi + +# + +if [ "${#WORKSPACE_NAME}" != 0 ]; then + USE_WORKSPACE=1 + WORKSPACE_NAME="$("$SCRIPTS_DIR/findworkspace.sh" --workspace-name "$WORKSPACE_NAME")" + + checkresult $? +elif [ "${#PROJECT_NAME}" != 0 ]; then + USE_WORKSPACE=0 + PROJECT_NAME="$("$SCRIPTS_DIR/findproject.sh" --project-name "$PROJECT_NAME")" + + checkresult $? +else + WORKSPACE_NAME="$("$SCRIPTS_DIR/findworkspace.sh")" 2> /dev/null + RESULT=$? + + if [[ "$RESULT" == 0 ]] && [[ "${#WORKSPACE_NAME}" != 0 ]]; then + USE_WORKSPACE=1 + else + PROJECT_NAME="$("$SCRIPTS_DIR/findproject.sh")" 2> /dev/null + RESULT=$? + + if [[ "$RESULT" == 0 ]] && [[ "${#PROJECT_NAME}" != 0 ]]; then + USE_WORKSPACE=0 + else + checkresult 1 "Unable to find specific Xcode project or workspace in the root directory. Try specifying a project or workspace name:\n" + fi + fi +fi + +if [ "$USE_WORKSPACE" == "1" ]; then + PRODUCT_NAME="$WORKSPACE_NAME" + FULL_PRODUCT_NAME="$WORKSPACE_NAME.xcworkspace" + XCODEBUILD_ARGS=(-workspace "$FULL_PRODUCT_NAME") + FORWARDING_ARGS=(--workspace-name "$WORKSPACE_NAME") +else + PRODUCT_NAME="$PROJECT_NAME" + FULL_PRODUCT_NAME="$PROJECT_NAME.xcodeproj" + XCODEBUILD_ARGS=(-project "$FULL_PRODUCT_NAME") + FORWARDING_ARGS=(--project-name "$PRODUCT_NAME") +fi + +# + +VERBOSE_FLAGS=() +if [ "$VERBOSE" == "1" ]; then + VERBOSE_FLAGS=(--verbose) +fi + +# + +if [ "$IS_RUNNING_IN_TEMP_ENV" == "1" ]; then + OUTPUT_DIR="$ROOT_DIR" +else + OUTPUT_DIR="$(setuptemp)" + echo -e "Testing from Temporary Directory: $("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "$OUTPUT_DIR")" +fi diff --git a/scripts/workflowtests/swift_package_tests.sh b/scripts/workflowtests/swift_package_tests.sh new file mode 100755 index 0000000..afe802f --- /dev/null +++ b/scripts/workflowtests/swift_package_tests.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# workflowtests/swift_package_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'swift-package.yml' Workflow..." + +if [ "$VERBOSE" == "1" ]; then + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" + swift build "${VERBOSE_FLAGS[@]}" + checkresult $? "'Build' step of 'swift-package.yml' workflow failed." + + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" + swift test --enable-code-coverage "${VERBOSE_FLAGS[@]}" + checkresult $? "'Test' step of 'swift-package.yml' workflow failed." +else + LOG="$(createlogfile "build-swiftpackage")" + + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" + swift build > "$LOG" 2>&1 + checkresult $? "$(errormessage "'Build' step of 'swift-package.yml' workflow failed." "$LOG")" + + # + + LOG="$(createlogfile "test-swiftpackage")" + + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing Swift Package from $("$SCRIPTS_DIR/printformat.sh" "bold" "Package.swift")" + swift test --enable-code-coverage > "$LOG" 2>&1 + checkresult $? "$(errormessage "'Test' step of 'swift-package.yml' workflow failed." "$LOG")" +fi + +xcrun llvm-cov export --format=lcov --instr-profile=".build/debug/codecov/default.profdata" ".build/debug/${PRODUCT_NAME}PackageTests.xctest/Contents/MacOS/${PRODUCT_NAME}PackageTests" > "./codecov.lcov" +checkresult $? "'Generate Code Coverage File' step of 'swift-package.yml' workflow failed." + +printstep "'swift-package.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/swiftlint_tests.sh b/scripts/workflowtests/swiftlint_tests.sh new file mode 100755 index 0000000..cc5d1bb --- /dev/null +++ b/scripts/workflowtests/swiftlint_tests.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# workflowtests/swiftlint_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'swiftlint.yml' Workflow..." + +swiftlint +checkresult $? "'Run SwiftLint' step of 'swiftlint.yml' workflow failed." + +printstep "'swiftlint.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/test_scheme_tests.sh b/scripts/workflowtests/test_scheme_tests.sh new file mode 100755 index 0000000..73fe431 --- /dev/null +++ b/scripts/workflowtests/test_scheme_tests.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# +# workflowtests/test_scheme_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Test running unit tests with test schemes..." + +# + +IOS_SIM="$(xcrun simctl list devices available | grep "iPhone [0-9]" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" +TVOS_SIM="$(xcrun simctl list devices available | grep "Apple TV" | sort -V | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" +WATCHOS_SIM="$(xcrun simctl list devices available | grep "Apple Watch" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" + +# + +for PLATFORM in "iOS" "Mac Catalyst" "macOS" "tvOS" "watchOS"; do + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") in $("$SCRIPTS_DIR/printformat.sh" "bold" "$FULL_PRODUCT_NAME")" + + SCHEME="${WORKSPACE_NAME}" + DESTINATION="$PLATFORM" + + case "$PLATFORM" in + "iOS") + SCHEME="${SCHEME}Tests" + DESTINATION="iOS Simulator,name=$IOS_SIM" + ;; + + "Mac Catalyst") + SCHEME="${SCHEME}Tests" + DESTINATION="macOS,variant=Mac Catalyst" + ;; + + "macOS") + SCHEME="$SCHEME macOS Tests" + ;; + + "tvOS") + SCHEME="$SCHEME tvOS Tests" + DESTINATION="tvOS Simulator,name=$TVOS_SIM" + ;; + + "watchOS") + SCHEME="$SCHEME watchOS Tests" + DESTINATION="watchOS Simulator,name=$WATCHOS_SIM" + ;; + esac + + # + + ERROR_MESSAGE="Test $PLATFORM (Test Scheme) failed." + + if [ "$VERBOSE" == "1" ]; then + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -testPlan "$SCHEME" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test + else + LOG="$(createlogfile "$(echo "$PLATFORM" | tr -d ' ' | tr '[:upper:]' '[:lower:]')-test")" + ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" + + # + + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -testPlan "$SCHEME" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test > "$LOG" 2>&1 + fi + + checkresult $? "$ERROR_MESSAGE" +done + +printstep "Test Scheme Unit Tests Passed\n" diff --git a/scripts/workflowtests/upload_assets_tests.sh b/scripts/workflowtests/upload_assets_tests.sh new file mode 100755 index 0000000..7e6af6b --- /dev/null +++ b/scripts/workflowtests/upload_assets_tests.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# workflowtests/upload_assets_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'upload-assets.yml' Workflow..." + +echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating zip archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PRODUCT_NAME.xcframework")" +zip -rX "$PRODUCT_NAME.xcframework.zip" "$PRODUCT_NAME.xcframework" >/dev/null 2>&1 +checkresult $? "'Create XCFramework Zip' step of 'upload-assets.yml' workflow failed." + +echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating tar archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PRODUCT_NAME.xcframework")" +tar -zcvf "$PRODUCT_NAME.xcframework.tar.gz" "$PRODUCT_NAME.xcframework" >/dev/null 2>&1 +checkresult $? "'Create XCFramework Tar' step of 'upload-assets.yml' workflow failed." + +# + +DOCC_ARCHIVE="$(find "$OUTPUT_DIR/.xcodebuild" -type d -name "$PRODUCT_NAME.doccarchive")" + +if [ "${DOCC_ARCHIVE[@]]}" == "0" ]; then + checkresult 1 "'Build Documentation' step of 'upload-assets.yml' workflow failed." +else + mv "${DOCC_ARCHIVE%/}" "$OUTPUT_DIR/$PRODUCT_NAME.doccarchive" + checkresult $? "'Build Documentation' step of 'upload-assets.yml' workflow failed." +fi + +# + +echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating zip archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PRODUCT_NAME.doccarchive")" +zip -rX "$PRODUCT_NAME.doccarchive.zip" "$PRODUCT_NAME.doccarchive" >/dev/null 2>&1 +checkresult $? "'Create Documentation Zip' step of 'upload-assets.yml' workflow failed." + +echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Creating tar archive for $("$SCRIPTS_DIR/printformat.sh" "bold" "$PRODUCT_NAME.doccarchive")" +tar -zcvf "$PRODUCT_NAME.doccarchive.tar.gz" "$PRODUCT_NAME.doccarchive" >/dev/null 2>&1 +checkresult $? "'Create Documentation Tar' step of 'upload-assets.yml' workflow failed." + +printstep "'upload-assets.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/xcframework_tests.sh b/scripts/workflowtests/xcframework_tests.sh new file mode 100755 index 0000000..e44933c --- /dev/null +++ b/scripts/workflowtests/xcframework_tests.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# workflowtests/xcframework_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +printstep "Testing 'xcframework.yml' Workflow..." + +./scripts/xcframework.sh "${FORWARDING_ARGS[@]}" --output "$OUTPUT_DIR" "${VERBOSE_FLAGS[@]}" -- RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES +checkresult $? "'Build' step of 'xcframework.yml' workflow failed." + +printstep "'xcframework.yml' Workflow Tests Passed\n" diff --git a/scripts/workflowtests/xcodebuild_build_tests.sh b/scripts/workflowtests/xcodebuild_build_tests.sh new file mode 100755 index 0000000..193ab31 --- /dev/null +++ b/scripts/workflowtests/xcodebuild_build_tests.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# workflowtests/xcodebuild_build_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +for PLATFORM in "iOS" "iOS Simulator" "Mac Catalyst" "macOS" "tvOS" "tvOS Simulator" "watchOS" "watchOS Simulator"; do + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") in $("$SCRIPTS_DIR/printformat.sh" "bold" "$FULL_PRODUCT_NAME")" + + SCHEME="$PRODUCT_NAME" + DESTINATION="$PLATFORM" + + case "$PLATFORM" in + "Mac Catalyst") DESTINATION="macOS,variant=Mac Catalyst" ;; + "macOS") SCHEME="${SCHEME} macOS" ;; + + "tvOS") SCHEME="${SCHEME} tvOS" ;; + "tvOS Simulator") SCHEME="${SCHEME} tvOS" ;; + + "watchOS") SCHEME="${SCHEME} watchOS" ;; + "watchOS Simulator") SCHEME="${SCHEME} watchOS" ;; + esac + + # + + ERROR_MESSAGE="'Build $PLATFORM' step of 'xcodebuild.yml' workflow failed." + + if [ "$VERBOSE" == "1" ]; then + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -destination "generic/platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES + else + LOG="$(createlogfile "$(echo "$PLATFORM" | tr -d ' ' | tr '[:upper:]' '[:lower:]')-build")" + ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" + + # + + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -destination "generic/platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES > "$LOG" 2>&1 + fi + + checkresult $? "$ERROR_MESSAGE" +done + +echo "" diff --git a/scripts/workflowtests/xcodebuild_test_tests.sh b/scripts/workflowtests/xcodebuild_test_tests.sh new file mode 100755 index 0000000..eb31b62 --- /dev/null +++ b/scripts/workflowtests/xcodebuild_test_tests.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# workflowtests/xcodebuild_test_tests.sh + +# THE INTENT OF THIS FILE IS TO BE IMPORTED DIRECTLY BY THE 'WORKFLOWTESTS.SH' +# FILE. THIS SHOULD RAN DIRECTLY OR IMPORTED BY ANY OTHER BASH SCRIPT. + +IOS_SIM="$(xcrun simctl list devices available | grep "iPhone [0-9]" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" +TVOS_SIM="$(xcrun simctl list devices available | grep "Apple TV" | sort -V | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" +WATCHOS_SIM="$(xcrun simctl list devices available | grep "Apple Watch" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" + +# + +for PLATFORM in "iOS" "Mac Catalyst" "macOS" "tvOS" "watchOS"; do + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Testing $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") in $("$SCRIPTS_DIR/printformat.sh" "bold" "$FULL_PRODUCT_NAME")" + + SCHEME="${PRODUCT_NAME}" + TESTPLAN="${SCHEME}Tests" + DESTINATION="$PLATFORM" + + case "$PLATFORM" in + "iOS") DESTINATION="iOS Simulator,name=$IOS_SIM" ;; + "Mac Catalyst") DESTINATION="macOS,variant=Mac Catalyst" ;; + + "macOS") + TESTPLAN="$SCHEME macOS Tests" + SCHEME="$SCHEME macOS" + ;; + + "tvOS") + TESTPLAN="$SCHEME tvOS Tests" + SCHEME="$SCHEME tvOS" + DESTINATION="tvOS Simulator,name=$TVOS_SIM" + ;; + + "watchOS") + TESTPLAN="$SCHEME watchOS Tests" + SCHEME="$SCHEME watchOS" + DESTINATION="watchOS Simulator,name=$WATCHOS_SIM" + ;; + esac + + # + + ERROR_MESSAGE="'Test $PLATFORM' step of 'xcodebuild.yml' workflow failed." + + if [ "$VERBOSE" == "1" ]; then + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -testPlan "$TESTPLAN" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test + else + LOG="$(createlogfile "$(echo "$PLATFORM" | tr -d ' ' | tr '[:upper:]' '[:lower:]')-test")" + ERROR_MESSAGE="$(errormessage "$ERROR_MESSAGE" "$LOG")" + + # + + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -testPlan "$TESTPLAN" -destination "platform=$DESTINATION" -configuration Debug RUN_DOCUMENTATION_COMPILER=NO SKIP_SWIFTLINT=YES ONLY_ACTIVE_ARCH=YES test > "$LOG" 2>&1 + fi + + checkresult $? "$ERROR_MESSAGE" +done diff --git a/scripts/xcframework.sh b/scripts/xcframework.sh index dbe5625..5fd8b06 100755 --- a/scripts/xcframework.sh +++ b/scripts/xcframework.sh @@ -45,6 +45,10 @@ function printhelp() { HELP+=" provided it will attempt to be resolved by searching the\n" HELP+=" working directory for an Xcode project and using its name.\n" HELP+="\n" + HELP+="--workspace-name) The name of the workspace to run tests against. If not\n" + HELP+=" provided it will attempt to be resolved by searching the\n" + HELP+=" working directory for an Xcode workspace and using its name.\n" + HELP+="\n" HELP+="--exclude-dsyms) Do not include the generated dSYMs nor BCSymbolMaps in the\n" HELP+=" final XCFramework.\n" HELP+="\n" @@ -73,6 +77,61 @@ function printhelp() { exit $EXIT_CODE } +# Function Declarations + +function cleanup() { + cd "$CURRENT_DIR" + if [[ "$VERBOSE" != "1" && "$BUILD_DIR_IS_TEMP" == "1" && ("$NO_CLEAN" == "1" || ("$NO_CLEAN_ON_FAIL" == "1" && "$EXIT_CODE" != "0")) ]]; then + if [ "$EXIT_CODE" == "0" ]; then + "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Build Directory: $BUILD_DIR" + fi + elif [ "$BUILD_DIR_IS_TEMP" == "1" ]; then + rm -rf "$BUILD_DIR" + fi + + # + + if [ "${#EXIT_MESSAGE}" != 0 ]; then + echo -e "$EXIT_MESSAGE" 1>&2 + fi + + exit $EXIT_CODE +} + +function checkresult() { + if [ "$1" != "0" ]; then + if [ "${#2}" != "0" ]; then + EXIT_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:red" "$2")" + fi + + EXIT_CODE=$1 + cleanup + fi +} + +function createlogfile() { + if [ ! -d "$BUILD_DIR/Logs" ]; then + mkdir -p "$BUILD_DIR/Logs" + fi + + local LOG="$BUILD_DIR/Logs/$1.log" + touch "$LOG" + + echo "$LOG" +} + +function errormessage() { + local ERROR_MESSAGE="" + + if [[ "$NO_CLEAN" == "1" ]] || [[ "$NO_CLEAN_ON_FAIL" == "1" ]]; then + ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "Build Failed. See xcodebuild log for more details: $("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "$1")")" + elif [ "$VERBOSE" != "1" ]; then + ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "Build Failed. Use the '--no-clean' or '--no-clean-on-fail' flag to inspect the logs.")" + fi + + echo "$ERROR_MESSAGE" +} + # Parse Arguments while [[ $# -gt 0 ]]; do @@ -99,6 +158,12 @@ while [[ $# -gt 0 ]]; do shift # ;; + --workspace-name) + WORKSPACE_NAME="$2" + shift # --workspace-name + shift # + ;; + --exclude-dsyms) EXCLUDE_DSYMS=1 shift # --exclude-dsyms @@ -145,12 +210,44 @@ done # -ARGUMENTS=() -if [ "${#PROJECT_NAME}" != 0 ]; then - ARGUMENTS=(--project-name "$PROJECT_NAME") +if [ "${#WORKSPACE_NAME}" != 0 ]; then + USE_WORKSPACE=1 + WORKSPACE_NAME="$("$SCRIPTS_DIR/findworkspace.sh" --workspace-name "$WORKSPACE_NAME")" + + checkresult $? +elif [ "${#PROJECT_NAME}" != 0 ]; then + USE_WORKSPACE=0 + PROJECT_NAME="$("$SCRIPTS_DIR/findproject.sh" --project-name "$PROJECT_NAME")" + + checkresult $? +else + WORKSPACE_NAME="$("$SCRIPTS_DIR/findworkspace.sh")" 2> /dev/null + RESULT=$? + + if [[ "$RESULT" == 0 ]] && [[ "${#WORKSPACE_NAME}" != 0 ]]; then + USE_WORKSPACE=1 + else + PROJECT_NAME="$("$SCRIPTS_DIR/findproject.sh")" 2> /dev/null + RESULT=$? + + if [[ "$RESULT" == 0 ]] && [[ "${#PROJECT_NAME}" != 0 ]]; then + USE_WORKSPACE=0 + else + checkresult 1 "Unable to find specific Xcode project or workspace in the root directory. Try specifying a project or workspace name:\n" + fi + fi +fi + +if [ "$USE_WORKSPACE" == "1" ]; then + PRODUCT_NAME="$WORKSPACE_NAME" + FULL_PRODUCT_NAME="$WORKSPACE_NAME.xcworkspace" + XCODEBUILD_ARGS=(-workspace "$FULL_PRODUCT_NAME") +else + PRODUCT_NAME="$PROJECT_NAME" + FULL_PRODUCT_NAME="$PROJECT_NAME.xcodeproj" + XCODEBUILD_ARGS=(-project "$FULL_PRODUCT_NAME") fi -PROJECT_NAME="$("$SCRIPTS_DIR/findproject.sh" "${ARGUMENTS[@]}")" EXIT_CODE=$? if [ "$EXIT_CODE" != "0" ]; then @@ -160,21 +257,23 @@ fi # if [ -z ${OUTPUT+x} ]; then - OUTPUT="$SCRIPTS_DIR/build/$PROJECT_NAME.xcframework" + OUTPUT="$SCRIPTS_DIR/build/$PRODUCT_NAME.xcframework" elif [ "${OUTPUT##*.}" != "xcframework" ]; then if [ "${OUTPUT: -1}" == "/" ]; then - OUTPUT="${OUTPUT}${PROJECT_NAME}.xcframework" + OUTPUT="${OUTPUT}${PRODUCT_NAME}.xcframework" else - OUTPUT="${OUTPUT}/${PROJECT_NAME}.xcframework" + OUTPUT="${OUTPUT}/${PRODUCT_NAME}.xcframework" fi fi +mkdir -p "$(dirname "${OUTPUT}")" + if [ -z ${CONFIGURATION+x} ]; then CONFIGURATION="Release" fi if [ -z ${BUILD_DIR+x} ]; then - BUILD_DIR="$(mktemp -d -t ".$(echo "$PROJECT_NAME" | tr '[:upper:]' '[:lower:]').xcframework.build")" + BUILD_DIR="$(mktemp -d -t ".$(echo "$PRODUCT_NAME" | tr '[:upper:]' '[:lower:]').xcframework.build")" BUILD_DIR_IS_TEMP=1 else mkdir -p "$BUILD_DIR" @@ -186,61 +285,6 @@ else fi fi -# Function Declarations - -function cleanup() { - cd "$CURRENT_DIR" - if [[ "$VERBOSE" != "1" && "$BUILD_DIR_IS_TEMP" == "1" && ("$NO_CLEAN" == "1" || ("$NO_CLEAN_ON_FAIL" == "1" && "$EXIT_CODE" != "0")) ]]; then - if [ "$EXIT_CODE" == "0" ]; then - "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Build Directory: $BUILD_DIR" - fi - elif [ "$BUILD_DIR_IS_TEMP" == "1" ]; then - rm -rf "$BUILD_DIR" - fi - - # - - if [ "${#EXIT_MESSAGE}" != 0 ]; then - echo -e "$EXIT_MESSAGE" 1>&2 - fi - - exit $EXIT_CODE -} - -function checkresult() { - if [ "$1" != "0" ]; then - if [ "${#2}" != "0" ]; then - EXIT_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:red" "$2")" - fi - - EXIT_CODE=$1 - cleanup - fi -} - -function createlogfile() { - if [ ! -d "$BUILD_DIR/Logs" ]; then - mkdir -p "$BUILD_DIR/Logs" - fi - - local LOG="$BUILD_DIR/Logs/$1.log" - touch "$LOG" - - echo "$LOG" -} - -function errormessage() { - local ERROR_MESSAGE="" - - if [[ "$NO_CLEAN" == "1" ]] || [[ "$NO_CLEAN_ON_FAIL" == "1" ]]; then - ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "Build Failed. See xcodebuild log for more details: $("$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "$1")")" - elif [ "$VERBOSE" != "1" ]; then - ERROR_MESSAGE="$("$SCRIPTS_DIR/printformat.sh" "foreground:default" "Build Failed. Use the '--no-clean' or '--no-clean-on-fail' flag to inspect the logs.")" - fi - - echo "$ERROR_MESSAGE" -} - # Build Platforms cd "$ROOT_DIR" @@ -248,20 +292,20 @@ cd "$ROOT_DIR" # for PLATFORM in "iOS" "iOS Simulator" "Mac Catalyst" "macOS" "tvOS" "tvOS Simulator" "watchOS" "watchOS Simulator"; do - echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") architecture(s) of $("$SCRIPTS_DIR/printformat.sh" "bold" "${PROJECT_NAME}.xcodeproj")" + echo -e "$("$SCRIPTS_DIR/printformat.sh" "foreground:blue" "***") Building $("$SCRIPTS_DIR/printformat.sh" "foreground:green" "$PLATFORM") architecture(s) of $("$SCRIPTS_DIR/printformat.sh" "bold" "$FULL_PRODUCT_NAME")" - SCHEME="${PROJECT_NAME}" + SCHEME="${PRODUCT_NAME}" ARCHIVE="" ARCHS="" case "$PLATFORM" in "iOS") - ARCHS="armv7 armv7s arm64 arm64e" + ARCHS="arm64 arm64e" ARCHIVE="iphoneos" ;; "iOS Simulator") - ARCHS="i386 x86_64 arm64" + ARCHS="x86_64 arm64" ARCHIVE="iphonesimulator" ;; @@ -272,32 +316,32 @@ for PLATFORM in "iOS" "iOS Simulator" "Mac Catalyst" "macOS" "tvOS" "tvOS Simula ;; "macOS") - SCHEME="${PROJECT_NAME} macOS" + SCHEME="${SCHEME} macOS" ARCHS="x86_64 arm64 arm64e" ARCHIVE="macos" ;; "tvOS") - SCHEME="${PROJECT_NAME} tvOS" + SCHEME="${SCHEME} tvOS" ARCHS="arm64 arm64e" ARCHIVE="appletvos" ;; "tvOS Simulator") - SCHEME="${PROJECT_NAME} tvOS" + SCHEME="${SCHEME} tvOS" ARCHS="x86_64 arm64" ARCHIVE="appletvsimulator" ;; "watchOS") - SCHEME="${PROJECT_NAME} watchOS" - ARCHS="arm64_32 armv7k" + SCHEME="${SCHEME} watchOS" + ARCHS="arm64 arm64e arm64_32 armv7k" ARCHIVE="watchos" ;; "watchOS Simulator") - SCHEME="${PROJECT_NAME} watchOS" - ARCHS="i386 x86_64 arm64" + SCHEME="${SCHEME} watchOS" + ARCHS="x86_64 arm64" ARCHIVE="watchsimulator" ;; esac @@ -307,14 +351,14 @@ for PLATFORM in "iOS" "iOS Simulator" "Mac Catalyst" "macOS" "tvOS" "tvOS Simula # if [ "$VERBOSE" == "1" ]; then - xcodebuild -project "${PROJECT_NAME}.xcodeproj" -scheme "$SCHEME" -destination "generic/platform=$PLATFORM" -archivePath "${BUILD_DIR}/$ARCHIVE.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="$ARCHS" "${BUILD_ARGS[@]}" archive + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -destination "generic/platform=$PLATFORM" -archivePath "${BUILD_DIR}/$ARCHIVE.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="$ARCHS" "${BUILD_ARGS[@]}" archive else LOG="$(createlogfile "$ARCHIVE-build")" ERROR_MESSAGE="$(errormessage "$LOG")" # - xcodebuild -project "${PROJECT_NAME}.xcodeproj" -scheme "$SCHEME" -destination "generic/platform=$PLATFORM" -archivePath "${BUILD_DIR}/$ARCHIVE.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="$ARCHS" "${BUILD_ARGS[@]}" archive > "$LOG" 2>&1 + xcodebuild "${XCODEBUILD_ARGS[@]}" -scheme "$SCHEME" -destination "generic/platform=$PLATFORM" -archivePath "${BUILD_DIR}/$ARCHIVE.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="$ARCHS" "${BUILD_ARGS[@]}" archive > "$LOG" 2>&1 fi checkresult $? "$ERROR_MESSAGE" @@ -326,19 +370,19 @@ if [[ -d "${OUTPUT}" ]]; then rm -rf "${OUTPUT}" fi -ARGUMENTS=(-create-xcframework -output "${OUTPUT}") +ARGUMENTS=(-create-xcframework -output "$(readlink -f "$(dirname "${OUTPUT}")")/$(basename "${OUTPUT}")") for ARCHIVE in ${BUILD_DIR}/*.xcarchive; do - ARGUMENTS=(${ARGUMENTS[@]} -framework "${ARCHIVE}/Products/Library/Frameworks/${PROJECT_NAME}.framework") + ARGUMENTS=(${ARGUMENTS[@]} -framework "$(readlink -f "${ARCHIVE}/Products/Library/Frameworks/${PRODUCT_NAME}.framework")") if [ "$EXCLUDE_DSYMS" != "1" ]; then - if [[ -d "${ARCHIVE}/dSYMs/${PROJECT_NAME}.framework.dSYM" ]]; then - ARGUMENTS=(${ARGUMENTS[@]} -debug-symbols "${ARCHIVE}/dSYMs/${PROJECT_NAME}.framework.dSYM") + if [[ -d "${ARCHIVE}/dSYMs/${PRODUCT_NAME}.framework.dSYM" ]]; then + ARGUMENTS=(${ARGUMENTS[@]} -debug-symbols "$(readlink -f "${ARCHIVE}/dSYMs/${PRODUCT_NAME}.framework.dSYM")") fi if [[ -d "${ARCHIVE}/BCSymbolMaps" ]]; then for SYMBOLMAP in ${ARCHIVE}/BCSymbolMaps/*.bcsymbolmap; do - ARGUMENTS=(${ARGUMENTS[@]} -debug-symbols "${SYMBOLMAP}") + ARGUMENTS=(${ARGUMENTS[@]} -debug-symbols "$(readlink -f "${SYMBOLMAP}")") done fi fi