amplitude / amplitude/Amplitude-Swift

Server Side Swift Support

Aberta
#85 2 comentários 0 reações 0 responsáveis Ver no GitHub
enhancement
Linguagem predominante
Swift
Estrelas
82
Forks
45
Merge médio
8h 54min
PRs com merge (30d)
7

Descrição

## 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.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.