Skip to content

Commit 98713e6

Browse files
chore: Swift usage documentation (#3039)
Added documentation on how to use swift in the framework. Co-authored-by: Philipp Hofmann <[email protected]>
1 parent 736495a commit 98713e6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

develop-docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This page contains internal documentation for development.
44

5+
## Coding with Swift
6+
7+
To use Swift in the project take a look at [Swift Usage](Swift-Usage.md) documentation.
8+
59
## Code Signing
610

711
This repository follows the [codesiging.guide](https://codesigning.guide/) in combination with [fastlane match](https://docs.fastlane.tools/actions/match/).

develop-docs/Swift-Usage.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swift Usage
2+
3+
Starting from version 8.0.0, it is now possible to include Swift code in the project. All Swift files should be placed under the `/Sources/Swift` directory.
4+
5+
> In this document, `SentryPrivate` refers to the library written in Swift, while `Sentry` represents the framework written in Objective-C. The term `SentryPrivate` public API refers to the API that will be consumed by `Sentry` and is not intended for direct use by users.
6+
7+
When working with Swift, it's important to keep the following restrictions in mind:
8+
9+
1. All Swift code will be bundled within the `SentryPrivate` library, which `Sentry` depends on.
10+
2. User-facing APIs cannot be written in Swift because their components will be accessed through imports from "SentryPrivate."
11+
3. `SentryPrivate` does not have access to `Sentry` classes to avoid cyclic references. As a result, any code written in Objective-C is not accessible from the Swift layer.
12+
- However, it is possible to create Dependency Injection (DI) APIs in Swift, allowing `Sentry` to inject its objects for use within `SentryPrivate`.
13+
4. `SentryPrivate` public APIs (code consumed by `Sentry`) cannot utilize certain Objective-C incompatible features, including:
14+
- Generics
15+
- Non-@objc protocols and protocol extensions
16+
- Top-level functions and properties
17+
- Global variables
18+
- Structs
19+
- Swift-only enums
20+
- Swift-only optionals
21+
- Swift-only tuples
22+
23+
By keeping these considerations in mind, you can effectively work with Swift code within the project, ensuring compatibility with the `Sentry` framework and adhering to the necessary restrictions imposed by the language differences.

0 commit comments

Comments
 (0)