I'm trying to follow the example here of building a native cross-platform mobile app in Kotlin. (I've linked to the step I'm having issues with, but I'm using the master branch of the linked repo which should contain ready-to-build code)
The Android version builds fine and I am able to simulate it, but I'm having issues with building the iOS app on Xcode. When I try to build the project, I get the following error:
/Users/myusername/Library/Developer/Xcode/DerivedData/KotlinIOS-ektaeprzdqunqygjxzrkmpdfyoyx/Build/Intermediates.noindex/KotlinIOS.build/Debug-iphonesimulator/KotlinIOS.build/Script-47729E7122F480EB00B9B36B.sh: line 4: cd: /Users/myusername/AndroidStudioProjects/mpp-ios-android/native/KotlinIOS/../../SharedCode/build/xcode-frameworks: No such file or directory
/Users/myusername/Library/Developer/Xcode/DerivedData/KotlinIOS-ektaeprzdqunqygjxzrkmpdfyoyx/Build/Intermediates.noindex/KotlinIOS.build/Debug-iphonesimulator/KotlinIOS.build/Script-47729E7122F480EB00B9B36B.sh: line 5: ./gradlew: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
Being a novice at both Kotlin and app development, I'm not sure how to debug this or how to proceed. It seems that gradlew
is a wrapper around gradle which I have installed (since I was able to build the Android app), but perhaps I've done something else wrong.
I'm using XCode 12.0 beta 6.
This turned out to be an issue with the Android build: you need to build the framework library for iOS in Android Studio, with the gradle task SharedCode/Tasks/build/packForXcode
. This was failing for me (hence the missing directory error in XCode) because I hadn't moved Xcode to the Applications
directory, which is where the gradle script expects to find the xcodebuild
executable. Moving Xcode.app to Applications
and running the packForXcode
gradle task allowed me to build and simulate the app correctly in iOS.