Skip to content
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

iOS Build Doesn't Work #2284

Open
gmitch215 opened this issue Aug 27, 2024 · 12 comments
Open

iOS Build Doesn't Work #2284

gmitch215 opened this issue Aug 27, 2024 · 12 comments

Comments

@gmitch215
Copy link

gmitch215 commented Aug 27, 2024

Main Issue

The KorGE iOS Build doesn't function correctly. Opening the app on my phone makes it instantly crash, causing a SIGABRT.

The issue seems to be in korlibs-io, where the app lacks permissions for storage. The app works correctly on JVM (Desktop) and Android, so it might be something with the Kotlin/Native wrapper.

I built it with gradlew build and opened build/platforms/ios in XCode. I archived and properly signed it to TestFlight. I also had to manually fix the other issues that are below this one.

Full Error:
https://hasteb.in/nv10iAKl7js8Qpi

Relevant Code:

val root: VfsFile = applicationDataVfs["combinatory_data"]

val settingsFile: VfsFile = root["settings.json"]

@Suppress("unchecked_cast")
suspend fun loadSettings() {
    // 'root' will exist at this point
    if (!settingsFile.exists())
        settingsFile.writeString("{}")

    // ...
}

Other Issues:

  • icon80.png doesn't exist and isn't used anymore, and should be replaced with icon87.png.
  • icon1024.png can't be transparent or have an alpha channel, so I copied it and turned it off.
@soywiz
Copy link
Member

soywiz commented Aug 27, 2024

Do the crash reproduces on the simulator? I tried the simulator right now and it seems to work properly (at least the hello world)

@gmitch215
Copy link
Author

The crash is related to the write function in korlibs-io. Does the hello world project use that?

@soywiz
Copy link
Member

soywiz commented Aug 27, 2024

Nope, no write in the hello-world, but does reading for the image.

Can you put a try...catch. Does the combinatory_data folder exists in the applicationDataVfs?

ensureParents would create ancestor folders if required:

settingsFile.ensureParents().writeString("...")

@gmitch215
Copy link
Author

I'll attempt with a try/catch. And yes, combinatory_data and root exist at that point, but I'll try with ensureParents.

Can you try the iOS simulator with a write function?

@soywiz
Copy link
Member

soywiz commented Aug 27, 2024

Throws an exception (if the file doesn't exist) but doesn't crashes.

./gradlew runIosSimulatorDebug
Screenshot 2024-08-27 at 15 27 33

@gmitch215
Copy link
Author

I'll try it in the CREATE stream mode when possible. The Exception might be causing the SIGABRT.

It's weird that this only happens on iOS. I don't get this kind of behavior on Android or on Desktop.

Would you happen to have access to an iPhone & Apple Developer Account you can test on? I probably won't be able to re-test it for a few hours.

@soywiz
Copy link
Member

soywiz commented Aug 27, 2024

I sold my iphone in my last minimalism step. I still don't understand why there are two variants: simulator and device since on M1* machines it is using ARM64 already. I could ask someone to lend me iphone for checking, but if you can figure it out it would be nice because that would likely take a few days.

@gmitch215
Copy link
Author

Tried create, getting a similar stacktrace.

New Stacktrace: https://hasteb.in/w23F20yUyevf33L

Relevant Code

suspend fun main() = Korge(
    gameId = ID,
    title = TITLE,
    windowSize = SIZE,
    backgroundColor = MAIN_COLOR,
    icon = ICON
) {
    container = sceneContainer(defaultTransition = TRANSITION)
    container.addTo(this)
    loadingSequence(this)
}
suspend fun loadingSequence(stage: Stage) {
    // ...
    // I/O
    loaded = withContext(Dispatchers.CIO) {
        // Storage
        if (!root.exists()) root.mkdirs()

        loadSettings()
        // ...
    }
}
val root: VfsFile = applicationDataVfs["combinatory_data"]

val settingsFile: VfsFile = root["settings.json"]

@Suppress("unchecked_cast")
suspend fun loadSettings() {
    if (!settingsFile.exists())
        settingsFile.open(VfsOpenMode.CREATE).use { it.writeString("{}") }

    val json = Json.parse(settingsFile.readString()) as Map<String, Any>
    Setting.load(json)
}

@gmitch215
Copy link
Author

@soywiz Any updates?

@soywiz
Copy link
Member

soywiz commented Sep 20, 2024

I'm on an hiatus and won't code or check messages in that time; will return around ~ early December.

@github-staff github-staff deleted a comment from vineet1401 Oct 23, 2024
@gmitch215
Copy link
Author

@soywiz Any updates?

@gmitch215
Copy link
Author

@soywiz Pinging you once again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pending
Development

No branches or pull requests

2 participants