andriydruk / swift-weather-app

Cross-platform Swift application for iOS/Mac/Android/Windows
MIT License
49 stars 10 forks source link

swift-build error: ExitCode(rawValue: 1) when executing ``swift-build`` from ``core`` folder #25

Closed pedrovgs closed 3 years ago

pedrovgs commented 3 years ago

Hi! I'm trying to build the core module manually but I always get the same error:

$ swift-build                                                                                                     ‹ruby-2.7.2›
/Users/pedro/Development/Projects/swift-weather-app/core: error: manifest parse error(s):
/Users/pedro/Development/Projects/swift-weather-app/core/Package.swift:2:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
error: ExitCode(rawValue: 1)
[0/1] Planning buildwarning: failed to load the cached build description: fatalError
/Users/pedro/Development/Projects/swift-weather-app/core: error: manifest parse error(s):
/Users/pedro/Development/Projects/swift-weather-app/core/Package.swift:2:8: error: no such module 'PackageDescription'
import PackageDescription
       ^

I've followed the swift-android-toolchain README.md instructions and configured all the requested dependencies but I'm not able to build any swift package, not even with a simple HelloWorld.swift file inside. However, I can build and run the Android app from the android folder using Android Studio or my terminal as expected.

I'd love to be able to build the iOS package manually and link the .so libraries generated manually. Could you please help me and check whats going on?

Here you have some information in case you need it:

andriydruk commented 3 years ago

Hi, I guess you just call default swift compiler from XCode

You should call android swift-build directly:

$SWIFT_ANDROID_HOME/build-tools/current/swift-build

or you can add it to your PATH:

export PATH=$SWIFT_ANDROID_HOME/bin:$SWIFT_ANDROID_HOME/build-tools/current:$PATH

Also please check TOOLCHAINS:

export TOOLCHAINS=org.swift.540202104261a
pedrovgs commented 3 years ago

Thank you so much @andriydruk !!! I've created an alias like this in my .zshrc file so I don't mix the default swift compiler with the Android one. Right below the profile env variables load command.

source $HOME/.profile
alias swift-android-toolchain=$SWIFT_ANDROID_HOME/build-tools/current/swift-build

Now it works 😃