Skip to content

Commit dc91aa5

Browse files
authored
build: restructure dependencies (#9)
reestructure dependencies and provide example on how to set up plugin in a separate file
2 parents 4b60b80 + eb9eca6 commit dc91aa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+426
-1135
lines changed
Lines changed: 84 additions & 86 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import SwiftUI
1+
import UIKit
22
import LaunchDarkly
3-
import Plugin
3+
import LaunchDarklyObservability
44

5-
//let mobileKey = "mob-dbe6f0ac-80ce-4903-bf20-431c2e7aeae1"
65
let mobileKey = "mob-48fd3788-eab7-4b72-b607-e41712049dbd"
76
let config = { () -> LDConfig in
87
var config = LDConfig(
98
mobileKey: mobileKey,
109
autoEnvAttributes: .enabled
1110
)
1211
config.plugins = [
13-
Observability()
12+
Observability(options: .init(sessionBackgroundTimeout: 3))
1413
]
1514
return config
1615
}()
@@ -51,15 +50,3 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
5150
return true
5251
}
5352
}
54-
55-
@main
56-
struct ObservabilityiOSTestAppApp: App {
57-
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
58-
59-
var body: some Scene {
60-
WindowGroup {
61-
// ContentView()
62-
HomeView()
63-
}
64-
}
65-
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
},
8+
{
9+
"appearances" : [
10+
{
11+
"appearance" : "luminosity",
12+
"value" : "dark"
13+
}
14+
],
15+
"idiom" : "universal",
16+
"platform" : "ios",
17+
"size" : "1024x1024"
18+
},
19+
{
20+
"appearances" : [
21+
{
22+
"appearance" : "luminosity",
23+
"value" : "tinted"
24+
}
25+
],
26+
"idiom" : "universal",
27+
"platform" : "ios",
28+
"size" : "1024x1024"
29+
}
30+
],
31+
"info" : {
32+
"author" : "xcode",
33+
"version" : 1
34+
}
35+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// ContentView.swift
3+
// ExampleApp
4+
//
5+
// Created by Mario Canto on 04/09/25.
6+
//
7+
8+
import SwiftUI
9+
10+
struct ContentView: View {
11+
var body: some View {
12+
VStack(spacing: 32) {
13+
Button {
14+
fatalError()
15+
} label: {
16+
Text("Crash")
17+
}
18+
NetworkRequestView()
19+
FeatureFlagView()
20+
}
21+
.padding()
22+
}
23+
}
24+
25+
#Preview {
26+
ContentView()
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import SwiftUI
2+
3+
@main
4+
struct ExampleAppApp: App {
5+
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
6+
7+
var body: some Scene {
8+
WindowGroup {
9+
ContentView()
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import SwiftUI
22
import LaunchDarkly
3-
import LaunchDarklyObservability
43

5-
private let featureFlag = "new-home-experience"
6-
struct HomeView: View {
4+
struct FeatureFlagView: View {
5+
private let featureFlag = "new-home-experience"
76
@State private var isNewExperience = Optional<Bool>.none
87

98
var body: some View {
10-
NavigationStack {
11-
if isNewExperience == true {
12-
HomeNewView()
13-
} else if isNewExperience == false {
14-
HomeOldView()
9+
Group {
10+
if let isNewExperience {
11+
Text("Feature flag is: \(isNewExperience)")
1512
} else {
16-
Text("Default Home View")
13+
Text("Feature flag is nil...")
1714
}
1815
}
16+
.font(.title)
17+
.bold()
1918
.onAppear {
2019
isNewExperience = LDClient.get()?.boolVariation(
2120
forKey: featureFlag,
2221
defaultValue: false
2322
)
2423
}
2524
}
25+
2626
}

0 commit comments

Comments
 (0)