readdle / swift-android-toolchain

MIT License
434 stars 32 forks source link

error: no such module 'PackageDescription' #43

Closed ploden closed 2 years ago

ploden commented 2 years ago

Hi, and thanks for all your work! I'm excited to run Swift on Android.

When I try to build the weather app with ./gradlew clean assembleDebug, I get the following:

Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
WARNING:: The specified Android SDK Build Tools version (29.0.3) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 4.2.2.
Android SDK Build Tools 30.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '29.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :app:installSwiftTools
Installing Swift Build Tools v1.9.7-swift5.4
Swift Build Tools v1.9.7-swift5.4 installed

> Task :app:kaptDebugKotlin
warning: JavaSwiftProcessor init startedwarning: Package moduleName: WeatherCoreBridgeGeneratedwarning: Package import: AnyCodablewarning: Package import: JavaCoderwarning: Package import> Task :app:swiftBuildArm64Debug FAILED
Swift PM flags: --configuration debug -Xswiftc -DDEBUG
/Users/pl/Downloads/swift-weather-app-master/android/app/src/main/swift: error: manifest parse error(s):
/Users/pl/Downloads/swift-weather-app-master/android/app/src/main/swift/Package.swift:3:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
unable to restore state from /Users/pl/Downloads/swift-weather-app-master/android/app/src/main/swift/.build/workspace-state.json; missingKey("path")

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:swiftBuildArm64Debug'.
> Process 'command '/Users/pl/android/swift-android-current/build-tools/1.9.7-swift5.4/swift-build'' finished with non-zero exit value 1
ploden commented 2 years ago

Finally figured this out. I had to disable MacOS System Integrity Protection, set SWIFTPM_PD_LIBS="/Library/Developer/Toolchains/swift-5.4.2-RELEASE.xctoolchain/usr/lib/swift/pm”, and add names to the package dependencies. Then I was able to build from both Android Studio and the command line. Thanks!