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
tasks.register("iosTest") { | |
val device = project.findProperty("iosDevice") as? String ?: "iPhone 11 Pro Max" | |
dependsOn("linkDebugTestIosX64") | |
group = JavaBasePlugin.VERIFICATION_GROUP | |
description = "Runs tests for target 'iosX64' on an iOS simulator" | |
doLast { | |
val binary = (kotlin.targets["iosX64"] as KotlinNativeTarget).binaries.getTest("DEBUG").outputFile | |
exec { | |
commandLine("xcrun", "simctl", "spawn", "--standalone", device, binary.absolutePath) | |
} |
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
/** | |
* @see [https://github.com/JetBrains/kotlinconf-app/blob/33f2d4e65f470d1444c5d4b46249af8feb243d03/common/src/mobileMain/kotlin/org/jetbrains/kotlinconf/FlowUtils.kt] | |
* */ | |
@FlowPreview | |
@ExperimentalCoroutinesApi | |
fun <T> ConflatedBroadcastChannel<T>.wrap(): CFlow<T> = CFlow(asFlow()) | |
fun <T> Flow<T>.wrap(coroutineScope: CoroutineScope? = null): CFlow<T> = CFlow(this, coroutineScope) | |
class CFlow<T>( |
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
private val databaseModule = DI.Module("database") { | |
bind<SqlDriver>() with singleton { | |
DatabaseFactory.createEngine(instance(), instance(), isDebug) | |
} | |
//... | |
} | |
private val viewModelModule = DI.Module("viewModel") { | |
bind<LoginViewModel>() with provider { |
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
//K/N | |
expect class AppDependencyProvider | |
//Android | |
actual class AppDependencyProvider(var context: Context) | |
//iOS | |
actual class AppDependencyProvider() |
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
val ktorVersion = "1.5.0" | |
val coroutinesVersion = "1.4.2-native-mt" | |
val serializationVersion = "1.0.1" | |
val kodeinVersion = "7.1.0" | |
val sqlDelightVersion = "1.4.4" | |
val datetimeVersion = "0.1.1" | |
val kryptoVersion = "1.12.0" | |
val junitVersion = "4.13.1" | |
sourceSets { |
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
import Foundation | |
private let SwapiURL = "https://swapi.dev/api/people/"; | |
class NativeSwapiClient { | |
func loadPeople(onSuccess: @escaping (([People]?) -> Void)) { | |
guard let url = URL(string: SwapiURL) else {return} | |
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in | |
guard let dataResponse = data, |
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
cbindgen::Builder::new() | |
.with_crate(crate_dir) | |
.with_language(C) | |
.generate() | |
.expect("Unable to generate bindings") | |
.write_to_file("src/greetings.h"); |
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
//return name | |
pub unsafe extern "C" fn people_get_name(person: *mut People) -> *mut c_char { | |
debug_assert!(!person.is_null()); | |
let person = person.as_ref().unwrap(); | |
return CString::new(person.name.to_owned()).unwrap().into_raw(); | |
} | |
//Or you can accept pointer to name as param | |
#[no_mangle] | |
pub unsafe extern "C" fn people_get_name_( |
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
/Wrapper for Rust SwapiClient | |
class SwapiLoader { | |
private let client: OpaquePointer | |
init() { | |
client = create_swapi_client() | |
} | |
deinit { |
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
//Create client | |
#[no_mangle] | |
pub extern "C" fn create_swapi_client() -> *mut SwapiClient { | |
Box::into_raw(Box::new(SwapiClient::new())) | |
} | |
//Release memory | |
#[no_mangle] | |
pub unsafe extern "C" fn free_swapi_client(client: *mut SwapiClient) { | |
assert!(!client.is_null()); |
NewerOlder