kotlin multiplatform框架初体验

严永丰
2023-12-01

依赖

  • 不建议在windows,因为ios app只能在mac下开发(垃圾苹果)
  • andrioid studio + plugin:kotlin multiplatform
  • xcode13+
  • brew install cocoapods kdoctor
  • kdoctor检查依赖

kt基础


fun main() {
    val info = Info("xiaosaobei",20)
    info.age = 2
    println(info.age)
    println(Gnu().b) 
}
//data class
data class Info(private var name:String,var age:Int=10)

//sealed class
sealed class Equiment{
	var b = 1
}
data class Gnu(val name:String):Equiment()

// delegate
interface Op{
	fun add(value:Int)
}
class CeOp:Op{
	override fun add(value:Int){
		//...
	}
}
class CeOpDelegate(p:CeOp):Operation by p
fun main(){
	CeOpDelegate(CeOp()).add(1)//use delegate class
}

开始

  • androif studio点击kotlin multiplatform等待加载完就能进入,测试ios端能不能用
  • 测试android端
 类似资料: