amplitude / amplitude/Amplitude-Swift

Server Side Swift Support

Offen
#85 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Swift
Sterne
82
Forks
45
Ø Merge
8 Std. 54 Min.
Gemergte PRs (30 T.)
7

Beschreibung

## Summary

Although the repository specially called out Apple platforms (This is Amplitude's latest version of the iOS SDK, covering iOS/tvOS/macOS/watchOS.), Swift as a language is growing beyond those specific usages. With a few modifications, this library can be adapted to run on other Swift native environments (like Linux and Windows).

## Motivations

I had a [PR](https://github.com/amplitude/Amplitude-Swift/pull/42) that started this work, but recent changes has made it difficult to stay on top keeping it merge-ready. When library developers aren't trained to think about multiple platform support, it's easy to make decisions that directly make that support hard to achieve.

Here are some of the areas identified that would need to be addressed to make this library compatible with non-apple platforms:

### Isolate **OSLog** usage by checking for `#if canImport(os.log)`
* Preferably use a cross-platform solution like [swift-log](https://github.com/apple/swift-log)

### Add conditional imports for `FoundationNetworking` where required. (`#if canImport(FoundationNetworking)`)

* On non-apple platforms, networking classes like `URL`, `URLRequest`, `URLSession` are part of the `FoundationNetworking` package.

### Setup a CSQLite map for linux systems

```
.systemLibrary(
name: "CSQLite",
pkgConfig: "sqlite3",
providers: [
.apt(["sqlite3", "libsqlite3-dev"])
]
),
.target(
name: "AmplitudeSwift",
dependencies: [
.target(name: "CSQLite", condition: .when(platforms: [.linux]))
],
path: "Sources/Amplitude",
exclude: ["../../Examples/", "../../Tests/"]
),
```

### Beware of `DispatchQueue.main`

This may not exist or function differently on other platforms. In a server-side environment, using this queue often does nothing.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.