https://kotlinlang.org logo
#ios
Title
# ios
s

salomonbrys

11/04/2021, 7:07 PM
Hey guys. How can we use InjectionIII with the new KMM project with Gradle generating the Xcodeproject ? In essence, I'd like to use this method : https://www.jetbrains.com/help/objc/create-a-swiftui-application.html but in a project created by AppCode with Gradle.
a

Aydar Mukhametzyanov

11/05/2021, 10:04 AM
Hi! I haven’t tried it by myself, but it seems it should work without any big differences. You still have
AppDelegate
with
didFinishLaunch
, where you setup InjectionIII. The only difference is that you would need to setup build settings
Other Linker Flags
in build.gradle.kts by using
buildSettings.OTHER_LDFLAGS("")
. If you create a new project you will see the commented example:
Copy code
plugins {
    id("org.jetbrains.gradle.apple.applePlugin") version "212.4638.14-0.14"
}

apple {
    iosApp {
        productName = "DeleteMeKMA2"

        sceneDelegateClass = "SceneDelegate"
        launchStoryboard = "LaunchScreen"

        //productInfo["NSAppTransportSecurity"] = mapOf("NSAllowsArbitraryLoads" to true)
        //buildSettings.OTHER_LDFLAGS("")

        dependencies {
            implementation(project(":shared"))
        }
    }
}
Would that work for you?
s

salomonbrys

11/05/2021, 10:10 AM
Tried that before posting 😉 Doesn’t work. The reason is, I believe, because the generated xcodeproj lives in
build/apple/iosApp
while sources are in
src/iosAppMain
, which InjectionIII is not watching (it is only watching sub directories of the directory containing the xcodeproj). Also, I couldn’t find a way to start the app in DEBUG (so I had to remove
#if DEBUG
to get InjectionIII stratup messages).
🤔 1
Having live previews is paramount to declarative UI programming with frameworks such as SwiftUI. We’ve used AppCode & InjectionIII with great success on a previous project. Not having InjectionIII working (or any other form of live preview) is, I believe, a major roadblock in adopting this new project model.
a

Aydar Mukhametzyanov

11/05/2021, 10:21 AM
I created an issue in the tracker: https://youtrack.jetbrains.com/issue/KMA-344 Feel free to follow it to be notified about the progress. We will have a closer look at the problem. Thank you for the report!
👍 1
🙏 1
5 Views