Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for dynamic library #1726

Merged
merged 5 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ jobs:
working-directory: Samples/macOS-SPM-CommandLine
shell: sh

validate-spm-dynamic:
name: Validate Swift Package Manager Dynamic
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- name: Set SPM revision to current git commit
run: >-
if [[ "${{ github.event.pull_request.head.sha }}" != "" ]]; then
sed -i '' 's/.branch("master")/.revision("${{ github.event.pull_request.head.sha }}")/g' Samples/SPM-Dynamic/Package.swift
else
sed -i '' 's/.branch("master")/.revision("${{ github.sha }}")/g' Samples/SPM-Dynamic/Package.swift
fi
shell: bash
- run: swift build
working-directory: Samples/SPM-Dynamic
shell: sh

swift-build:
name: Build with Swift
runs-on: macos-11
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- feat: Add more info to touch event breadcrumbs (#1724)
- feat: Add support for dynamic library (#1726)
Comment on lines +5 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to fix that for you 😁 after merging this PR.

### Features

- Read free_memory when the event is captured, not only at SDK startup (#1962)
Expand Down
6 changes: 2 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ let package = Package(
name: "Sentry",
platforms: [.iOS(.v9), .macOS(.v10_10), .tvOS(.v9), .watchOS(.v2)],
products: [
.library(
name: "Sentry",
targets: ["Sentry"]
)
.library(name: "Sentry", targets: ["Sentry"]),
.library(name: "Sentry-Dynamic", type: .dynamic, targets: ["Sentry"]),
],
targets: [
.target(
Expand Down
7 changes: 7 additions & 0 deletions Samples/SPM-Dynamic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
23 changes: 23 additions & 0 deletions Samples/SPM-Dynamic/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SPM-Dynamic",
products: [
.library(name: "SPM-Dynamic", type: .dynamic, targets: ["SPM-Dynamic"]),
],
dependencies: [
// branch is replaced in CI to the current sha
.package(name: "Sentry", url: "https://github.com/getsentry/sentry-cocoa", .branch("master") )
],
targets: [
.target(
name: "SPM-Dynamic",
dependencies: ["Sentry"],
swiftSettings: [
.unsafeFlags(["-warnings-as-errors"])
])
]
)
27 changes: 27 additions & 0 deletions Samples/SPM-Dynamic/Sources/SPM-Dynamic/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation
import Sentry

SentrySDK.start { options in
options.dsn = "https://[email protected]/5428557"
options.debug = true
}

/**
Some func to build a stacktrace.
*/
private func captureMessage() {
let eventId = SentrySDK.capture(message: "Yeah captured a message")

// Some Delay to wait for sending the message
let group = DispatchGroup()
group.enter()
let queue = DispatchQueue(label: "delay", qos: .background, attributes: [])
queue.asyncAfter(deadline: .now() + 2) {
group.leave()
}
group.wait()

print("\(String(describing: eventId))")
}

captureMessage()