Skip to content

Commit 6e87db3

Browse files
committed
feat: Add SentryDistribution
1 parent 0309548 commit 6e87db3

27 files changed

+662
-3
lines changed

.github/actions/prepare-package.swift/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ inputs:
55
description: "Whether the build is a PR"
66
required: true
77
default: "false"
8+
remove-duplicate:
9+
description: "Whether to remove targets that produce duplicate files. These targets cause SPM validation errors."
10+
default: "false"
11+
change-path:
12+
description: "Whether to change the path of the framework"
13+
default: "true"
814
package-file:
915
description: "The package file to prepare"
1016
required: true
@@ -22,7 +28,17 @@ runs:
2228
sed -i '' '/Sentry-Dynamic-WithARM64e/d' $PACKAGE_FILE
2329
sed -i '' '/Sentry-WithoutUIKitOrAppKit-WithARM64e/d' $PACKAGE_FILE
2430
sed -i '' '/^[[:space:]]*\.binaryTarget($/{N;/\n[[:space:]]*),\{0,1\}$/d;}' $PACKAGE_FILE
31+
- name: Remove duplicate target
32+
if: ${{ inputs.remove-duplicate == 'true' }}
33+
shell: bash
34+
env:
35+
PACKAGE_FILE: ${{ inputs.package-file }}
36+
run: |
37+
sed -i '' '/Sentry-Dynamic/d' $PACKAGE_FILE
38+
sed -i '' '/Sentry-WithoutUIKitOrAppKit/d' $PACKAGE_FILE
39+
sed -i '' '/^[[:space:]]*\.binaryTarget($/{N;/\n[[:space:]]*),\{0,1\}$/d;}' $PACKAGE_FILE
2540
- name: Change path of the framework
41+
if: ${{ inputs.change-path == 'true' }}
2642
shell: bash
2743
env:
2844
PACKAGE_FILE: ${{ inputs.package-file }}

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ jobs:
9898
config: DebugV9
9999
- scheme: iOS-ObjectiveC
100100
config: DebugV9
101+
- scheme: DistributionSample
102+
config: Debug
101103

102104
steps:
103105
- uses: actions/checkout@v5
@@ -129,6 +131,26 @@ jobs:
129131
if: ${{ failure() || cancelled() }}
130132
run: ./scripts/ci-diagnostics.sh
131133

134+
build-distribution:
135+
name: Build the distribution framework
136+
runs-on: macos-15
137+
needs: files-changed
138+
steps:
139+
- uses: actions/checkout@v5
140+
141+
- run: ./scripts/ci-select-xcode.sh 16.4
142+
shell: sh
143+
- run: rm -r Sentry.xcodeproj && rm -r Sentry.xcworkspace
144+
- run: set -o pipefail && NSUnbufferedIO=YES xcodebuild build -scheme SentryDistribution -sdk iphoneos -destination 'generic/platform=iphoneos' | tee raw-build-output-spm.log | xcbeautify
145+
shell: sh
146+
- name: Upload SPM Build Logs
147+
uses: actions/upload-artifact@v4
148+
if: ${{ failure() || cancelled() }}
149+
with:
150+
name: raw-build-output-spm
151+
path: |
152+
raw-build-output-spm.log
153+
132154
build-spm:
133155
name: Build with SPM
134156
runs-on: macos-15
@@ -340,6 +362,7 @@ jobs:
340362
files-changed,
341363
ios-swift-release,
342364
build-sample,
365+
build-distribution,
343366
build-spm,
344367
build-v9,
345368
check-debug-without-UIKit,

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,29 @@ jobs:
9292
if: failure()
9393
run: ./scripts/ci-diagnostics.sh
9494

95+
distribution-tests:
96+
name: Distribution Tests
97+
runs-on: macos-15
98+
needs: files-changed
99+
steps:
100+
- uses: actions/checkout@v5
101+
- name: Prepare Package.swift
102+
uses: ./.github/actions/prepare-package.swift
103+
with:
104+
is-pr: ${{ github.event_name == 'pull_request' }}
105+
change-path: false
106+
remove-duplicate: true
107+
- run: rm -r Sentry.xcodeproj && rm -r Sentry.xcworkspace
108+
- 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
109+
shell: sh
110+
- name: Upload Distribution Test Logs
111+
uses: actions/upload-artifact@v4
112+
if: ${{ failure() || cancelled() }}
113+
with:
114+
name: raw-test-output-distribution
115+
path: |
116+
raw-test-output-distribution.log
117+
95118
# This matrix runs only the unit tests requiring the test server.
96119
# We do this to speed up the other unit test jobs and to avoid running the
97120
# test server with potential side effects in GH actions for all unit tests.
@@ -453,6 +476,7 @@ jobs:
453476
[
454477
files-changed,
455478
build-test-server,
479+
distribution-tests,
456480
unit-tests,
457481
unit-tests-with-test-server,
458482
]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Add SentryDistribution as Swift Package Manager target (#6149)
8+
39
## 8.56.2
410

511
### Fixes

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,4 @@ xcode-ci:
189189
xcodegen --spec Samples/watchOS-Swift/watchOS-Swift.yml
190190
xcodegen --spec TestSamples/SwiftUITestSample/SwiftUITestSample.yml
191191
xcodegen --spec TestSamples/SwiftUICrashTest/SwiftUICrashTest.yml
192+
xcodegen --spec Samples/DistributionSample/DistributionSample.yml

Package.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ var products: [Product] = [
1515
.library(name: "Sentry-Dynamic-WithARM64e", targets: ["Sentry-Dynamic-WithARM64e"]),
1616
.library(name: "Sentry-WithoutUIKitOrAppKit", targets: ["Sentry-WithoutUIKitOrAppKit", "SentryCppHelper"]),
1717
.library(name: "Sentry-WithoutUIKitOrAppKit-WithARM64e", targets: ["Sentry-WithoutUIKitOrAppKit-WithARM64e", "SentryCppHelper"]),
18-
.library(name: "SentrySwiftUI", targets: ["Sentry", "SentrySwiftUI", "SentryCppHelper"])
18+
.library(name: "SentrySwiftUI", targets: ["Sentry", "SentrySwiftUI", "SentryCppHelper"]),
19+
.library(name: "SentryDistribution", targets: ["SentryDistribution"])
1920
]
2021

2122
var targets: [Target] = [
@@ -66,7 +67,9 @@ var targets: [Target] = [
6667
linkerSettings: [
6768
.linkedLibrary("c++")
6869
]
69-
)
70+
),
71+
.target(name: "SentryDistribution", path: "Sources/SentryDistribution"),
72+
.testTarget(name: "SentryDistributionTests", dependencies: ["SentryDistribution"], path: "Sources/SentryDistributionTests")
7073
]
7174

7275
let env = getenv("EXPERIMENTAL_SPM_BUILDS")
@@ -101,7 +104,7 @@ if let env = env, String(cString: env, encoding: .utf8) == "1" {
101104
name: "SentryObjc",
102105
dependencies: ["SentrySwift"],
103106
path: "Sources",
104-
exclude: ["Sentry/SentryDummyPublicEmptyClass.m", "Sentry/SentryDummyPrivateEmptyClass.m", "Swift", "SentrySwiftUI", "Resources", "Configuration", "SentryCppHelper"],
107+
exclude: ["Sentry/SentryDummyPublicEmptyClass.m", "Sentry/SentryDummyPrivateEmptyClass.m", "Swift", "SentrySwiftUI", "Resources", "Configuration", "SentryCppHelper", "SentryDistribution", "SentryDistributionTests"],
105108
cSettings: [
106109
.headerSearchPath("Sentry/include/HybridPublic"),
107110
.headerSearchPath("Sentry"),
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.sample.DistributionSample
2+
INFOPLIST_FILE = DistributionSample/Info.plist
3+
SUPPORTED_PLATFORMS = iphoneos iphonesimulator
4+
IPHONEOS_DEPLOYMENT_TARGET = 15.0
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: DistributionSample
2+
createIntermediateGroups: true
3+
generateEmptyDirectories: true
4+
configs:
5+
Debug: debug
6+
Release: release
7+
options:
8+
bundleIdPrefix: io.sentry.sample.
9+
packages:
10+
Sentry:
11+
path: ../../
12+
targets:
13+
DistributionSample:
14+
type: application
15+
platform: auto
16+
sources:
17+
- DistributionSample
18+
dependencies:
19+
- package: Sentry
20+
products:
21+
- SentryDistribution
22+
configFiles:
23+
Debug: DistributionSample.xcconfig
24+
Release: DistributionSample.xcconfig
25+
schemes:
26+
DistributionSample:
27+
templates:
28+
- SampleAppScheme
29+
build:
30+
targets:
31+
DistributionSample: all
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SwiftUI
2+
3+
@main
4+
struct DemoAppApp: App {
5+
var body: some Scene {
6+
WindowGroup {
7+
ContentView()
8+
}
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
3+
enum Constants {
4+
static let accessToken = ""
5+
static let organization = ""
6+
static let project = ""
7+
}

0 commit comments

Comments
 (0)