diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 6535620ea..04080cd42 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -2,32 +2,56 @@ on: pull_request: paths: - 'ios/**' + push: + branches: + - 'main' + - 'ios-release' + paths: + - 'ios/**' + tags: + - 'ios-*' jobs: - ios_lint_and_tests: + # ios_lint_and_tests: + # runs-on: macos-latest + # permissions: + # contents: read + # pull-requests: read + # steps: + # - name: Checkout Repository + # uses: actions/checkout@v4 + + # - name: Run SwiftLint + # uses: cirruslabs/swiftlint-action@fdc2695c66b8807e7b1571d08097a99cf1fde41b + # with: + # version: latest + # directory: ios + + # - name: Clean Derived Data + # run: | + # rm -rf ~/Library/Developer/Xcode/DerivedData + + # - name: Run Unit Tests + # run: | + # xcodebuild test \ + # -project ios/MeasureSDK.xcodeproj \ + # -scheme MeasureSDK \ + # -sdk iphonesimulator \ + # -destination 'platform=iOS Simulator,name=iPhone 15 Pro' \ + # ONLY_ACTIVE_ARCH=YES + + publish-ios: runs-on: macos-latest + # needs: [ ios_lint_and_tests ] + # if: startsWith(github.ref, 'refs/tags/ios-') + if: github.ref == 'refs/heads/ios-release' permissions: contents: read - pull-requests: read + packages: write + timeout-minutes: 30 steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Run SwiftLint - uses: cirruslabs/swiftlint-action@fdc2695c66b8807e7b1571d08097a99cf1fde41b - with: - version: latest - directory: ios - - - name: Clean Derived Data - run: | - rm -rf ~/Library/Developer/Xcode/DerivedData - - - name: Run Unit Tests + - name: Lint CocoaPods run: | - xcodebuild test \ - -project ios/MeasureSDK.xcodeproj \ - -scheme MeasureSDK \ - -sdk iphonesimulator \ - -destination 'platform=iOS Simulator,name=iPhone 15 Pro' \ - ONLY_ACTIVE_ARCH=YES \ No newline at end of file + cd .. + pwd + pod spec lint MeasureSDK.podspec \ No newline at end of file diff --git a/.gitignore b/.gitignore index 60061e8eb..6d8671d63 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,8 @@ node_modules # vscode multi-root workspace *.code-workspace + +# ios +.build/ +.swiftpm/ +Package.resolved \ No newline at end of file diff --git a/MeasureSDK.podspec b/MeasureSDK.podspec new file mode 100644 index 000000000..83b44ec59 --- /dev/null +++ b/MeasureSDK.podspec @@ -0,0 +1,18 @@ +Pod::Spec.new do |spec| + spec.name = "MeasureSDK" + spec.version = "0.0.1" + spec.summary = "Open source tool to monitor mobile apps" + spec.homepage = "https://github.com/measure-sh/measure.git" + spec.license = { :type => "MIT", :file => "LICENSE" } + spec.author = "measure.sh" + spec.platform = :ios, "12.0" + spec.swift_version = "5.10" + spec.static_framework = true + spec.source = { :git => "https://github.com/measure-sh/measure.git", + :branch => "ios-release" } + spec.source_files = "ios/Sources/MeasureSDK/Swift/**/*.{swift}", "ios/Sources/MeasureSDK/Objc/**/*.{h,m}" + spec.public_header_files = "ios/Sources/MeasureSDK/Objc/include/**/*.h" + spec.resources = ["ios/Sources/MeasureSDK/Swift/XCDataModel/MeasureModel.xcdatamodeld", "ios/Sources/MeasureSDK/Swift/Resources/PrivacyInfo.xcprivacy"] + spec.frameworks = "Foundation", "UIKit", "CoreData" + spec.dependency "PLCrashReporter" +end diff --git a/ios/Package.swift b/Package.swift similarity index 65% rename from ios/Package.swift rename to Package.swift index 137bb77bf..1567fbd9f 100644 --- a/ios/Package.swift +++ b/Package.swift @@ -16,27 +16,26 @@ let package = Package( .package(url: "https://github.com/microsoft/plcrashreporter.git", from: "1.11.2") ], targets: [ - .target( - name: "MeasureSDKObjc", - dependencies: [], - path: "Sources/MeasureSDK/Objc", - publicHeadersPath: "include" - ), .target( name: "MeasureSDK", dependencies: [ - "MeasureSDKObjc", .product(name: "CrashReporter", package: "plcrashreporter") ], - path: "Sources/MeasureSDK/Swift" + path: "ios/Sources/MeasureSDK/Swift", + resources: [ + .process("XCDataModel/MeasureModel.xcdatamodeld"), + .copy("Resources/PrivacyInfo.xcprivacy") + ] ), .testTarget( name: "MeasureSDKTests", - dependencies: ["MeasureSDK"] + dependencies: ["MeasureSDK"], + path: "ios/Tests/MeasureSDKTests" ), .testTarget( name: "MeasureUITests", - dependencies: ["MeasureSDK"] + dependencies: ["MeasureSDK"], + path: "ios/Tests/MeasureUITests" ), ] ) diff --git a/ios/MeasureSDK.podspec b/ios/MeasureSDK.podspec deleted file mode 100644 index 01c108cbf..000000000 --- a/ios/MeasureSDK.podspec +++ /dev/null @@ -1,18 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = "MeasureSDK" - spec.version = "1.0.0" - spec.summary = "spec.summary" - spec.description = "spec.description" - spec.homepage = "https://github.com/measure-sh/measure" - spec.license = { :type => "MIT", :file => "LICENSE" } - spec.author = { "Adwin Ross" => "adwin@measure.sh" } - spec.platform = :ios, "12.0" - spec.source = { :path => "." } - spec.source_files = "Sources/MeasureSDK/**/*.{h,m,swift}" - spec.resources = ["Sources/MeasureSDK/**/*.xcdatamodeld"] - spec.frameworks = "Foundation", "UIKit", "CoreData" - spec.swift_version = "5.0" - spec.static_framework = true - spec.dependency "PLCrashReporter" - end - \ No newline at end of file diff --git a/ios/PublicApi/MeasureSDK.swiftinterface b/ios/PublicApi/MeasureSDK.swiftinterface index 53248ccdf..2e6e47a0a 100644 --- a/ios/PublicApi/MeasureSDK.swiftinterface +++ b/ios/PublicApi/MeasureSDK.swiftinterface @@ -1,6 +1,6 @@ // swift-interface-format-version: 1.0 // swift-compiler-version: Apple Swift version 6.0.3 effective-5.10 (swiftlang-6.0.3.1.10 clang-1600.0.30.1) -// swift-module-flags: -target x86_64-apple-ios12-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -enable-experimental-feature OpaqueTypeErasure -enable-bare-slash-regex -module-name MeasureSDK +// swift-module-flags: -target arm64-apple-ios12 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -enable-experimental-feature OpaqueTypeErasure -enable-bare-slash-regex -module-name MeasureSDK // swift-module-flags-ignorable: -no-verify-emitted-module-interface import CoreData import CoreTelephony diff --git a/ios/Scripts/bump_sdk_version.sh b/ios/Scripts/bump_sdk_version.sh new file mode 100644 index 000000000..92d4a893f --- /dev/null +++ b/ios/Scripts/bump_sdk_version.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -e # Exit immediately if a command exits with a non-zero status + +# Get the release type from the first argument (major, minor, patch) +RELEASE_TYPE=$1 + +# File paths +FRAMEWORK_INFO_FILE="../Sources/MeasureSDK/Swift/FrameworkInfo.swift" +PODSPEC_FILE="../MeasureSDK.podspec" + +# Function to get the current version from FrameworkInfo.swift +get_current_version() { + grep -oE '[0-9]+\.[0-9]+\.[0-9]+' "$FRAMEWORK_INFO_FILE" | head -1 +} + +# Function to bump version +bump_version() { + local version=$1 + local type=$2 + IFS='.' read -r major minor patch <<< "$version" + + case "$type" in + major) + major=$((major + 1)) + minor=0 + patch=0 + ;; + minor) + minor=$((minor + 1)) + patch=0 + ;; + patch) + patch=$((patch + 1)) + ;; + *) + echo "Invalid release type: $type" + exit 1 + ;; + esac + + echo "$major.$minor.$patch" +} + +# Get current version +CURRENT_VERSION=$(get_current_version) +echo "Current version: $CURRENT_VERSION" + +# Get new version +NEW_VERSION=$(bump_version "$CURRENT_VERSION" "$RELEASE_TYPE") +echo "New version: $NEW_VERSION" + +# Update version in FrameworkInfo.swift +sed -i '' "s/static let version = \".*\"/static let version = \"$NEW_VERSION\"/" "$FRAMEWORK_INFO_FILE" + +# Update version in podspec (Fix: Use a temp file method) +awk -v new_version="$NEW_VERSION" '/spec.version *= *"[0-9]+\.[0-9]+\.[0-9]+"/ { sub(/[0-9]+\.[0-9]+\.[0-9]+/, new_version); }1' "$PODSPEC_FILE" > temp_podspec && mv temp_podspec "$PODSPEC_FILE" + +# Verify updates +grep "static let version" "$FRAMEWORK_INFO_FILE" +grep "spec.version" "$PODSPEC_FILE" + +# Commit and push changes +# git add "$FRAMEWORK_INFO_FILE" "$PODSPEC_FILE" +# git commit -m "Release version $NEW_VERSION" +# git tag "v$NEW_VERSION" +# git push origin main --tags + +echo "✅ Release $NEW_VERSION created successfully!"