Skip to content

Commit 17394b6

Browse files
committed
add Demo
1 parent f88bd97 commit 17394b6

File tree

7 files changed

+260
-0
lines changed

7 files changed

+260
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Demo.swiftpm/GoogleService-Info.plist
12
.DS_Store
23
/.build
34
/Packages

Demo.swiftpm/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Demo.swiftpm/ContentView.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import SwiftUI
2+
import FirebaseRemoteConfig
3+
import FirebaseRemoteConfigOpenFeatureProvider
4+
5+
struct ContentView: View {
6+
var remoteConfig: RemoteConfig?
7+
var provider: FirebaseRemoteConfigOpenFeatureProvider?
8+
9+
@RemoteConfigProperty(key: "LocalString", fallback: "")
10+
var localString: String
11+
@RemoteConfigProperty(key: "RemoteString", fallback: "")
12+
var remoteString: String
13+
14+
init() {
15+
let config = RemoteConfig.remoteConfig()
16+
try! config.setDefaults(from: [
17+
"LocalString": "This is local string value for Demo"
18+
])
19+
config.fetchAndActivate()
20+
21+
provider = FirebaseRemoteConfigOpenFeatureProvider(remoteConfig: config)
22+
remoteConfig = config
23+
}
24+
25+
var body: some View {
26+
VStack {
27+
Text("RemoteConfig Direct Value").font(.title)
28+
Text(localString)
29+
Text(remoteString)
30+
31+
Spacer().frame(height: 100)
32+
33+
Text("Through Provider Value").font(.title)
34+
Text(try! provider!.getStringEvaluation(key: "LocalString", defaultValue: "", context: nil).value)
35+
Text(try! provider!.getStringEvaluation(key: "RemoteString", defaultValue: "", context: nil).value)
36+
}
37+
}
38+
}

Demo.swiftpm/MyApp.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import SwiftUI
2+
import FirebaseCore
3+
4+
class AppDelegate: NSObject, UIApplicationDelegate {
5+
func application(_ application: UIApplication,
6+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
7+
FirebaseApp.configure()
8+
return true
9+
}
10+
}
11+
12+
@main
13+
struct MyApp: App {
14+
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
15+
16+
var body: some Scene {
17+
WindowGroup {
18+
ContentView()
19+
}
20+
}
21+
}

Demo.swiftpm/Package.resolved

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

Demo.swiftpm/Package.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// swift-tools-version: 5.8
2+
3+
// WARNING:
4+
// This file is automatically generated.
5+
// Do not edit it by hand because the contents will be replaced.
6+
7+
import PackageDescription
8+
import AppleProductTypes
9+
10+
let package = Package(
11+
name: "Demo",
12+
platforms: [
13+
.iOS("16.0")
14+
],
15+
products: [
16+
.iOSApplication(
17+
name: "Demo",
18+
targets: ["AppModule"],
19+
bundleIdentifier: "com.github.fumito-ito.FirebaseRemoteConfigOpenFeatureProvider.Demo",
20+
teamIdentifier: "L8LPZ499U7",
21+
displayVersion: "1.0",
22+
bundleVersion: "1",
23+
appIcon: .placeholder(icon: .checkmark),
24+
accentColor: .presetColor(.purple),
25+
supportedDeviceFamilies: [
26+
.pad,
27+
.phone
28+
],
29+
supportedInterfaceOrientations: [
30+
.portrait,
31+
.landscapeRight,
32+
.landscapeLeft,
33+
.portraitUpsideDown(.when(deviceFamilies: [.pad]))
34+
]
35+
)
36+
],
37+
dependencies: [
38+
.package(path: ".."),
39+
.package(url: "https://github.com/open-feature/swift-sdk", "0.0.2"..<"1.0.0")
40+
],
41+
targets: [
42+
.executableTarget(
43+
name: "AppModule",
44+
dependencies: [
45+
.product(name: "FirebaseRemoteConfigOpenFeatureProvider", package: "firebaseremoteconfig-openfeature-provider-swift"),
46+
.product(name: "OpenFeature", package: "swift-sdk")
47+
],
48+
path: ".",
49+
resources: [
50+
.process("GoogleService-Info.plist")
51+
]
52+
)
53+
]
54+
)

0 commit comments

Comments
 (0)