Unverified Commit 9a4db01b authored by dima-avdeev-jb's avatar dima-avdeev-jb Committed by GitHub

ios sample with debug in appcode (#532)

* insert ios and share modules

* 1.6.20

* free compiler args

* SwiftHelper

* skiko debug with AppCode

* remove redundant code

* remove redundant code

* simplify AppDelegate.swift

* remove redundant storyboard

* simplify

* simplify

* simplify

* Revert "1.6.20"

This reverts commit a2b1d769fa0ea0bc114b5e92bb5b285ad5f45cba.

* samples/ios-appcode

* move shared to iOS

* move iOS to SkiaMultiplatformSample

* smiplify kotlin iOS files

* revert some changes

* revert some changes

* readme

* settings gradle skiko debug comment

* check SKIKO_COMPOSITE_BUILD=1

* runIosSim inside macos check

* readme

* readme

* sources in project.yml

* readme

* readme

* fix README.md after review

* fix README.md after review
parent cf67c819
# Skia multiplatform samples
## run iOS with Xcode
- Works only on Mac with Intel CPU (for now)
- Install xcodegen
- run `xcodegen`
- run `open SkikoSample.xcodeproj`
## run iOS with debug in AppCode
- If you need to debug skiko sources without publish to maven local, then set environment variable `export SKIKO_COMPOSITE_BUILD=1` (on MacOS in ~/.zshrc)
- Install KMM plugin for AppCode
- In AppCode open samples/SkiaMultiplatformSample (File -> Open).
Choose "Open as Project".
![import-build-gradle-project.png](import-build-gradle-project.png)
- Set target device and Run
![ios-run-in-appcode.png](ios-run-in-appcode.png)
- Now you may use breakpoints in common and native Kotlin code
## run on browser:
- `./gradlew jsBrowserRun`
## run desktop awt:
- `./gradlew runAwt`
## run desktop on native MacOS
- `./gradlew runNative`
......@@ -14,6 +14,7 @@ buildscript {
plugins {
kotlin("multiplatform") version "1.6.10"
id("org.jetbrains.gradle.apple.applePlugin") version "222.849-0.15.1"
}
val coroutinesVersion = "1.5.2"
......@@ -72,6 +73,19 @@ kotlin {
targets.add(iosX64())
targets.add(iosArm64())
ios {
binaries {
framework {
baseName = "shared"
freeCompilerArgs += listOf(
"-linker-option", "-framework", "-linker-option", "Metal",
"-linker-option", "-framework", "-linker-option", "CoreText",
"-linker-option", "-framework", "-linker-option", "CoreGraphics"
)
}
}
}
}
jvm("awt") {
......@@ -149,7 +163,7 @@ kotlin {
}
else -> throw GradleException("Host OS is not supported")
}
val iosMain by creating {
val iosMain by getting {
dependsOn(darwinMain)
}
val iosX64Main by getting {
......@@ -162,7 +176,8 @@ kotlin {
}
}
project.tasks.register<Exec>("runIosSim") {
if (hostOs == "macos") {
project.tasks.register<Exec>("runIosSim") {
val device = "iPhone 11"
workingDir = project.buildDir
val binTask = project.tasks.named("linkReleaseExecutableIosX64")
......@@ -178,9 +193,8 @@ project.tasks.register<Exec>("runIosSim") {
val out = fileTree(binTask.get().outputs.files.files.single()) { include("*.kexe") }
listOf(out.single { it.name.endsWith(".kexe") }.absolutePath)
}
}
project.tasks.register<Exec>("runNative") {
}
project.tasks.register<Exec>("runNative") {
workingDir = project.buildDir
val binTask = project.tasks.named("linkDebugExecutable${hostOs.capitalize()}${hostArch.capitalize()}")
dependsOn(binTask)
......@@ -191,6 +205,7 @@ project.tasks.register<Exec>("runNative") {
println("Run $out")
listOf(out.single { it.name.endsWith(".kexe") }.absolutePath)
}
}
}
project.tasks.register<JavaExec>("runAwt") {
......@@ -280,3 +295,13 @@ if (hostOs == "macos") {
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}
apple {
iosApp {
productName = "SkikoAppCode"
sceneDelegateClass = "SceneDelegate"
dependencies {
implementation(project(":"))
}
}
}
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
org.gradle.jvmargs=-Xmx3G -XX:MaxMetaspaceSize=512m
......@@ -21,7 +21,12 @@ targets:
properties:
UILaunchStoryboardName: ""
sources:
- "src/"
- path: "src/"
excludes:
- "android*/**"
- "awt*/**"
- "iosApp*/**"
- "js*/**"
settings:
LIBRARY_SEARCH_PATHS: "$(inherited)"
ENABLE_BITCODE: "YES"
......
......@@ -8,3 +8,10 @@ pluginManagement {
}
rootProject.name = "SkiaMultiplatformSample"
if (System.getenv("SKIKO_COMPOSITE_BUILD") == "1") {
includeBuild("../../skiko") {
dependencySubstitution {
substitute(module("org.jetbrains.skiko:skiko")).using(project(":"))
}
}
}
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
}
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
import UIKit
import SwiftUI
import shared
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = SwiftHelper().getViewController()
self.window = window
window.makeKeyAndVisible()
}
}
}
......@@ -11,8 +11,6 @@ import org.jetbrains.skiko.SkikoGestureEventKind
import platform.UIKit.*
import platform.Foundation.*
fun makeApp(skiaLayer: SkiaLayer) = Clocks(skiaLayer)
fun main() {
val args = emptyArray<String>()
memScoped {
......@@ -38,14 +36,7 @@ class SkikoAppDelegate : UIResponder, UIApplicationDelegateProtocol {
override fun application(application: UIApplication, didFinishLaunchingWithOptions: Map<Any?, *>?): Boolean {
window = UIWindow(frame = UIScreen.mainScreen.bounds)
window!!.rootViewController = SkikoViewController(
SkikoUIView(
SkiaLayer().apply {
gesturesToListen = SkikoGestureEventKind.values()
skikoView = GenericSkikoView(this, makeApp(this))
}
)
)
window!!.rootViewController = getSkikoViewContoller()
window!!.makeKeyAndVisible()
return true
}
......
package org.jetbrains.skiko.sample
import org.jetbrains.skiko.SkiaLayer
class SwiftHelper {
fun getViewController() = getSkikoViewContoller()
}
package org.jetbrains.skiko.sample
import kotlinx.cinterop.*
import org.jetbrains.skiko.*
import org.jetbrains.skiko.sample.*
import platform.Foundation.*
import platform.UIKit.*
fun makeApp(skiaLayer: SkiaLayer) = Clocks(skiaLayer)
fun getSkikoViewContoller(): UIViewController = SkikoViewController(
SkikoUIView(
SkiaLayer().apply {
gesturesToListen = SkikoGestureEventKind.values()
skikoView = GenericSkikoView(this, makeApp(this))
}
)
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment