Skip to content

Commit f54ff1b

Browse files
committed
initial commit
0 parents  commit f54ff1b

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.build
2+
.DS_Store
3+
.vscode
4+
.idea
5+
node_modules

Package.resolved

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// swift-tools-version: 6.0
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "featurevisor-example-swift",
6+
platforms: [
7+
.macOS(.v13)
8+
],
9+
dependencies: [
10+
.package(url: "https://github.com/featurevisor/featurevisor-swift2.git", from: "0.1.0")
11+
],
12+
targets: [
13+
.executableTarget(
14+
name: "featurevisor-example-swift",
15+
dependencies: [
16+
.product(name: "Featurevisor", package: "featurevisor-swift2")
17+
]
18+
)
19+
]
20+
)

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# featurevisor-example-swift
2+
3+
Example application using Featurevisor [Swift SDK](https://github.com/featurevisor/featurevisor-swift2).
4+
5+
Learn more about Featurevisor [here](https://featurevisor.com).
6+
7+
## Installation
8+
9+
```bash
10+
swift package resolve
11+
```
12+
13+
## Usage
14+
15+
```bash
16+
swift run featurevisor-example-swift
17+
```
18+
19+
## Featurevisor project
20+
21+
Uses this Featurevisor project to fetch the datafile from: [https://github.com/featurevisor/featurevisor-example-cloudflare](https://github.com/featurevisor/featurevisor-example-cloudflare)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
import Featurevisor
3+
4+
let datafileURL = URL(string: "https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-tag-all.json")!
5+
6+
let data = try Data(contentsOf: datafileURL)
7+
let datafileContent = try DatafileContent.fromData(data)
8+
9+
let f = createInstance(
10+
InstanceOptions(
11+
datafile: datafileContent,
12+
context: [
13+
"userId": .string("123"),
14+
"deviceId": .string("device-23456"),
15+
"country": .string("nl")
16+
]
17+
)
18+
)
19+
20+
let featureIsEnabled = f.isEnabled("my_feature")
21+
print("Feature is enabled: \(featureIsEnabled)")

0 commit comments

Comments
 (0)