diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 249b71d314f..0081bf13420 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,7 @@ jobs: # sample projects don't use SPM for including Sentry. Only the DistributionSample uses local SPM. # Therefore, we only keep the local DistributionSample reference in the Package.swift as a workaround. - name: Only keep distribution lib and target in Package.swift - run: ./scripts/prepare-package.sh --only-keep-distribution true + run: ./scripts/prepare-package.sh --remove-binary-targets true - run: ./scripts/ci-select-xcode.sh 16.4 - name: Setup Ruby @@ -126,7 +126,7 @@ jobs: # sample projects don't use SPM for including Sentry. Only the DistributionSample uses local SPM. # Therefore, we only keep the local DistributionSample reference in the Package.swift as a workaround. - name: Only keep distribution lib and target in Package.swift - run: ./scripts/prepare-package.sh --only-keep-distribution true + run: ./scripts/prepare-package.sh --remove-binary-targets true - run: ./scripts/ci-select-xcode.sh 16.4 - run: make init-ci-build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50e28ca1148..5c724b8c52f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -207,7 +207,7 @@ jobs: --is-pr "${{ github.event_name == 'pull_request' }}" \ --change-path true - run: ./scripts/ci-select-xcode.sh 16.4 - - run: swift build + - run: swift build --target SentrySwiftUI - name: Run CI Diagnostics if: failure() run: ./scripts/ci-diagnostics.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba663220750..0e2bbe58e69 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -116,7 +116,8 @@ jobs: --package-file Package.swift \ --is-pr "${{ github.event_name == 'pull_request' }}" \ --remove-duplicate true \ - --change-path false + --change-path false \ + --remove-binary-targets true - run: rm -r Sentry.xcodeproj && rm -r Sentry.xcworkspace - run: set -o pipefail && NSUnbufferedIO=YES SKIP_BINARIES=1 xcodebuild test -scheme Sentry-Package -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=18.4,name=iPhone 16 Pro' | tee raw-test-output-distribution.log | xcbeautify --preserve-unbeautified shell: sh diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 491f9a14f51..7b59b751f30 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -55,7 +55,7 @@ jobs: # sample projects don't use SPM for including Sentry. Only the DistributionSample uses local SPM. # Therefore, we only keep the local DistributionSample reference in the Package.swift as a workaround. - name: Only keep distribution lib and target in Package.swift - run: ./scripts/prepare-package.sh --only-keep-distribution true + run: ./scripts/prepare-package.sh --remove-binary-targets true - run: make init-ci-build - run: make xcode-ci diff --git a/.gitignore b/.gitignore index 9e3ff1c66ae..99652eaebc6 100644 --- a/.gitignore +++ b/.gitignore @@ -95,6 +95,7 @@ Samples/visionOS-Swift/visionOS-Swift.xcodeproj Samples/watchOS-Swift/watchOS-Swift.xcodeproj Samples/SentrySampleShared/SentrySampleShared.xcodeproj Samples/DistributionSample/DistributionSample.xcodeproj +Samples/SPM/SPM.xcodeproj TestSamples/SwiftUITestSample/SwiftUITestSample.xcodeproj TestSamples/SwiftUICrashTest/SwiftUICrashTest.xcodeproj diff --git a/Makefile b/Makefile index 302ea0981e5..47da8ef1fdf 100644 --- a/Makefile +++ b/Makefile @@ -184,6 +184,7 @@ xcode: open Sentry.xcworkspace xcode-ci: + xcodegen --spec Samples/SPM/SPM.yml xcodegen --spec Samples/SentrySampleShared/SentrySampleShared.yml xcodegen --spec Samples/SessionReplay-CameraTest/SessionReplay-CameraTest.yml xcodegen --spec Samples/iOS-ObjectiveC/iOS-ObjectiveC.yml diff --git a/Package.swift b/Package.swift index 3c20caa0b01..b926ea670d7 100644 --- a/Package.swift +++ b/Package.swift @@ -74,8 +74,6 @@ var targets: [Target] = [ .testTarget(name: "SentryDistributionTests", dependencies: ["SentryDistribution"], path: "Sources/SentryDistributionTests") ] -let env = getenv("EXPERIMENTAL_SPM_BUILDS") -if let env = env, String(cString: env, encoding: .utf8) == "1" { products.append(.library(name: "SentrySPM", type: .dynamic, targets: ["SentryObjc"])) targets.append(contentsOf: [ // At least one source file is required, therefore we use a dummy class to satisfy the SPM build system @@ -114,7 +112,6 @@ if let env = env, String(cString: env, encoding: .utf8) == "1" { .headerSearchPath("SentryCrash/Reporting/Filters"), .headerSearchPath("SentryCrash/Reporting/Filters/Tools")]) ]) -} let package = Package( name: "Sentry", diff --git a/Samples/SPM/SPM.xcconfig b/Samples/SPM/SPM.xcconfig new file mode 100644 index 00000000000..9eabd99183a --- /dev/null +++ b/Samples/SPM/SPM.xcconfig @@ -0,0 +1,14 @@ +#include "../Shared/Config/_Common.xcconfig" + +PRODUCT_BUNDLE_IDENTIFIER = io.sentry.sample.SPM +INFOPLIST_FILE = SPM/Info.plist +CODE_SIGN_ENTITLEMENTS = SPM/SPM.entitlements + +PROVISIONING_PROFILE_SPECIFIER_Debug = match Development io.sentry.sample.SPM +PROVISIONING_PROFILE_SPECIFIER_Release = match AppStore io.sentry.sample.SPM +PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*] = $(PROVISIONING_PROFILE_SPECIFIER_$(CONFIGURATION)) +PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] = + +CODE_SIGN_STYLE = Manual + +SUPPORTED_PLATFORMS = iphoneos iphonesimulator diff --git a/Samples/SPM/SPM.yml b/Samples/SPM/SPM.yml new file mode 100644 index 00000000000..eb0f21f6ec0 --- /dev/null +++ b/Samples/SPM/SPM.yml @@ -0,0 +1,35 @@ +# yaml-language-server: $schema=../../schema/xcodegen.schema.json + +name: SPM +createIntermediateGroups: true +generateEmptyDirectories: true +configs: + Debug: debug + Release: release +fileGroups: + - SPM.yml +options: + bundleIdPrefix: io.sentry +packages: + Sentry: + path: ../../ +targets: + SPM: + type: application + platform: auto + sources: + - SPM + dependencies: + - package: Sentry + products: + - SentrySwift + configFiles: + Debug: SPM.xcconfig + Release: SPM.xcconfig +schemes: + SPM: + templates: + - SampleAppScheme + build: + targets: + SPM: all diff --git a/Samples/SPM/SPM/Assets.xcassets/AccentColor.colorset/Contents.json b/Samples/SPM/SPM/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000000..0afb3cf0eec --- /dev/null +++ b/Samples/SPM/SPM/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors": [ + { + "idiom": "universal" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Samples/SPM/SPM/Assets.xcassets/AppIcon.appiconset/Contents.json b/Samples/SPM/SPM/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..c70a5bff185 --- /dev/null +++ b/Samples/SPM/SPM/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images": [ + { + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "dark" + } + ], + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "tinted" + } + ], + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Samples/SPM/SPM/Assets.xcassets/Contents.json b/Samples/SPM/SPM/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..74d6a722cf3 --- /dev/null +++ b/Samples/SPM/SPM/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Samples/SPM/SPM/ContentView.swift b/Samples/SPM/SPM/ContentView.swift new file mode 100644 index 00000000000..b000a7e4618 --- /dev/null +++ b/Samples/SPM/SPM/ContentView.swift @@ -0,0 +1,17 @@ +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundStyle(.tint) + Text("Hello, world!") + } + .padding() + } +} + +#Preview { + ContentView() +} diff --git a/Samples/SPM/SPM/Info.plist b/Samples/SPM/SPM/Info.plist new file mode 100644 index 00000000000..b4f367bf79b --- /dev/null +++ b/Samples/SPM/SPM/Info.plist @@ -0,0 +1,56 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + GIT_BRANCH + <branch> + GIT_COMMIT_HASH + <sha> + GIT_STATUS_CLEAN + <status> + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + UIApplicationSupportsIndirectInputEvents + + UILaunchScreen + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Samples/SPM/SPM/SPM.entitlements b/Samples/SPM/SPM/SPM.entitlements new file mode 100644 index 00000000000..ee95ab7e582 --- /dev/null +++ b/Samples/SPM/SPM/SPM.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/Samples/SPM/SPM/SPMTestApp.swift b/Samples/SPM/SPM/SPMTestApp.swift new file mode 100644 index 00000000000..08f6cc0838b --- /dev/null +++ b/Samples/SPM/SPM/SPMTestApp.swift @@ -0,0 +1,21 @@ +import SentrySwift +import SwiftUI + +@main +struct SPMTestApp: App { + init() { + let options = Options() + options.enableAppHangTracking = true + options.dsn = "https://6cc9bae94def43cab8444a99e0031c28@o447951.ingest.sentry.io/5428557" + options.sessionReplay.maskAllImages = false + SentrySDK.start(options: options) + let user = User() + SentrySDK.setUser(user) + } + + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Sentry.xcworkspace/contents.xcworkspacedata b/Sentry.xcworkspace/contents.xcworkspacedata index df84c70c570..a024dfdeb5a 100644 --- a/Sentry.xcworkspace/contents.xcworkspacedata +++ b/Sentry.xcworkspace/contents.xcworkspacedata @@ -13,6 +13,9 @@ + + diff --git a/scripts/prepare-package.sh b/scripts/prepare-package.sh index 3945d453dfa..ee63744a66a 100755 --- a/scripts/prepare-package.sh +++ b/scripts/prepare-package.sh @@ -12,7 +12,7 @@ Options: --remove-duplicate true|false Whether to strip duplicate targets (default: false) --change-path true|false Whether to swap SPM binary URLs for local paths (default: false) - --only-keep-distribution true|false + --remove-binary-targets true|false Whether to keep only SentryDistribution product/target (default: false) -h, --help Show this help message USAGE @@ -29,7 +29,7 @@ PACKAGE_FILE="Package.swift" IS_PR="false" REMOVE_DUPLICATE="false" CHANGE_PATH="false" -ONLY_KEEP_DISTRIBUTION="false" +REMOVE_BINARY_TARGETS="false" while [[ $# -gt 0 ]]; do case "$1" in @@ -53,9 +53,9 @@ while [[ $# -gt 0 ]]; do CHANGE_PATH="$2" shift 2 ;; - --only-keep-distribution) + --remove-binary-targets) [[ $# -lt 2 ]] && { echo "Missing value for $1" >&2; exit 1; } - ONLY_KEEP_DISTRIBUTION="$2" + REMOVE_BINARY_TARGETS="$2" shift 2 ;; -h|--help) @@ -103,7 +103,7 @@ if is_enabled "$CHANGE_PATH"; then sed -i '' 's/platforms: \[\.iOS(\.v11), \.macOS(\.v10_13), \.tvOS(\.v11), \.watchOS(\.v4)\]$/platforms: [.iOS(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4)],/g' "$PACKAGE_FILE" fi -if is_enabled "$ONLY_KEEP_DISTRIBUTION"; then +if is_enabled "$REMOVE_BINARY_TARGETS"; then # Remove all binary targets. sed -i '' '/^[[:space:]]*\.binaryTarget(/,/^[[:space:]]*),\{0,1\}$/d' "$PACKAGE_FILE" @@ -118,6 +118,7 @@ var products: [Product] = [\ sed -i '' '/^var targets: \[Target\] = \[/,/^]/c\ var targets: [Target] = [\ .target(name: "SentryDistribution", path: "Sources/SentryDistribution"),\ + .testTarget(name: "SentryDistributionTests", dependencies: ["SentryDistribution"], path: "Sources/SentryDistributionTests")\ ]\ ' "$PACKAGE_FILE"