-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Natively support Launch Darkly #117
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a2bd0c2
WIP
kevincianfarini 0fc2b8c
WIP
kevincianfarini 9463980
Swift import works
kevincianfarini 61d076f
WIP
kevincianfarini 32f006b
WIP
kevincianfarini 3d9b618
Conditionally enable swift packages
kevincianfarini c92f6b0
Debug
kevincianfarini bcddb6a
More debug
kevincianfarini 1eacd7f
WIP
kevincianfarini 14f64a7
WIP
kevincianfarini 0bb7757
WIP
kevincianfarini c3a9986
WIP
kevincianfarini 6f3588d
WIP
kevincianfarini c6ba8d9
Remove extra includes
kevincianfarini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
.gradle | ||
**/build/ | ||
local.properties | ||
.kotlin | ||
.kotlin | ||
integrations/launch-darkly/exportedLaunchDarkly/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
integrations/launch-darkly/exportedSwiftlaunchdarkly/Package.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// swift-tools-version: 5.9 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "exportedSwiftlaunchdarkly", | ||
platforms: [.iOS("12.0"), .macOS("10.13"), .tvOS("12.0"), .watchOS("4.0")], | ||
products: [ | ||
.library( | ||
name: "exportedSwiftlaunchdarkly", | ||
type: .static, | ||
targets: ["exportedSwiftlaunchdarkly"]) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/launchdarkly/ios-client-sdk.git", exact: "9.12.0") | ||
], | ||
targets: [ | ||
.target( | ||
name: "exportedSwiftlaunchdarkly", | ||
dependencies: [ | ||
.product(name: "LaunchDarkly", package: "ios-client-sdk") | ||
], | ||
path: "Sources") | ||
|
||
] | ||
) |
1 change: 1 addition & 0 deletions
1
integrations/launch-darkly/exportedSwiftlaunchdarkly/Sources/DummySPMFile.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
POM_ARTIFACT_ID=launch-darkly-integration | ||
POM_NAME=Monarch Launch Darkly Integration | ||
POM_DESCRIPTION=Multiplatform integration with Launch Darkly feature flag SDKs | ||
POM_DESCRIPTION=Multiplatform integration with Launch Darkly feature flag SDKs | ||
|
||
kotlin.mpp.enableCInteropCommonization=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 40 additions & 12 deletions
52
...c/iosMain/kotlin/io/github/kevincianfarini/monarch/launchdarkly/LaunchDarklyClientShim.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,75 @@ | ||
package io.github.kevincianfarini.monarch.launchdarkly | ||
|
||
import LaunchDarkly.LDClient | ||
import kotlinx.cinterop.ExperimentalForeignApi | ||
|
||
/** | ||
* A temporary, experimental shim to allow iOS consumers of Monarch to wire their own LDClient | ||
* as a data store using [LaunchDarklyClientShim.asFeatureFlagDataStore]. This interface will be | ||
* removed in future versions of this library when future, first-party support of LaunchDarkly | ||
* is available. | ||
* An interface around [LDClient]. | ||
*/ | ||
public interface LaunchDarklyClientShim { | ||
internal interface LaunchDarklyClientShim { | ||
|
||
/** | ||
* Return a [Boolean] value [forKey], or [default] if no value exists. | ||
*/ | ||
public fun boolVariation(forKey: String, default: Boolean): Boolean | ||
fun boolVariation(forKey: String, default: Boolean): Boolean | ||
|
||
/** | ||
* Return an [Int] value [forKey], or [default] if no value exists. | ||
*/ | ||
public fun intVariation(forKey: String, default: Int): Int | ||
fun longVariation(forKey: String, default: Long): Long | ||
|
||
/** | ||
* Return a [Double] value [forKey], or [default] if no value exists. | ||
*/ | ||
public fun doubleVariation(forKey: String, default: Double): Double | ||
fun doubleVariation(forKey: String, default: Double): Double | ||
|
||
/** | ||
* Return a [String] value [forKey], or [default] if no value exists. | ||
*/ | ||
public fun stringVariation(forKey: String, default: String): String | ||
fun stringVariation(forKey: String, default: String): String | ||
|
||
/** | ||
* Register a [handler] to be invoked when the value associated with [key] changes, scoped | ||
* to [owner]. | ||
*/ | ||
public fun observe(key: String, owner: ObserverOwner, handler: () -> Unit) | ||
fun observe(key: String, owner: ObserverOwner, handler: () -> Unit) | ||
|
||
/** | ||
* Unregister all observers scoped to [owner]. | ||
*/ | ||
public fun stopObserving(owner: ObserverOwner) | ||
fun stopObserving(owner: ObserverOwner) | ||
} | ||
|
||
/** | ||
* A marker object used in [LaunchDarklyClientShim.observe] and | ||
* [LaunchDarklyClientShim.stopObserving]. | ||
*/ | ||
public class ObserverOwner internal constructor() | ||
internal class ObserverOwner internal constructor() | ||
|
||
@OptIn(ExperimentalForeignApi::class) | ||
internal class RealLaunchDarklyShim(private val client: LDClient) : LaunchDarklyClientShim { | ||
|
||
override fun boolVariation(forKey: String, default: Boolean): Boolean { | ||
return client.boolVariationForKey(forKey, default) | ||
} | ||
|
||
override fun longVariation(forKey: String, default: Long): Long { | ||
return client.integerVariationForKey(forKey, default) | ||
} | ||
|
||
override fun doubleVariation(forKey: String, default: Double): Double { | ||
return client.doubleVariationForKey(forKey, default) | ||
} | ||
|
||
override fun stringVariation(forKey: String, default: String): String { | ||
return client.stringVariationForKey(forKey, default) | ||
} | ||
|
||
override fun observe(key: String, owner: ObserverOwner, handler: () -> Unit) { | ||
client.observe(key, owner) { handler() } | ||
} | ||
|
||
override fun stopObserving(owner: ObserverOwner) { | ||
client.stopObservingForOwner(owner) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to push a snapshot release and dogfood it to see if there's anything weird going on with static linking.