skiptools / skip

Skip transpiler for creating SwiftUI apps for iOS and Android
https://skip.tools
GNU Lesser General Public License v3.0
1.47k stars 39 forks source link

swift build command line issue #162

Open nex5turbo opened 2 months ago

nex5turbo commented 2 months ago

First of all, Thanks for your hard working!

I found an error that occurs when I try to export gradle project. I tried this one below

$ skip init --appid=com.xyz.HelloSkip hello-skip HelloSkip

Initializing Skip library hello-skip
[✓] Create project hello-skip (0.73s)
[✓] Resolve dependencies (5.89s)
[✓] Build hello-skip (15.2s)
[✓] Created module HelloSkip in ~/Desktop/hello-skip/HelloSkip.xcodeproj

$ cd hello-skip 

$ swift build --build-tests

Fetched https://source.skip.tools/skip.git (0.92s)
…
[294/294] Linking libHelloSkip.dylib
Build complete! (23.13s)

$ skip gradle -p .build/plugins/outputs/hello-skip/HelloSkip/skipstone/HelloSkip test

GRADLE> > Task :HelloSkip:preBuild UP-TO-DATE
…
GRADLE> > Task :HelloSkip:testDebugUnitTest
GRADLE> > Task :HelloSkip:test
GRADLE> 
GRADLE> BUILD SUCCESSFUL in 20s
GRADLE> 204 actionable tasks: 204 executed
note: Gradle SUCCESSFUL

$ skip gradle -p Android/ assemble

GRADLE> > Task :app:preBuild UP-TO-DATE
GRADLE> > Task :app:preDebugBuild UP-TO-DATE
GRADLE> > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
GRADLE> > Task :app:generateDebugBuildConfig
GRADLE> > Task :HelloSkip:preBuild UP-TO-DATE
…
GRADLE> > Task :SkipUI:bundleReleaseAar
GRADLE> > Task :HelloSkip:compileDebugJavaWithJavac NO-SOURCE
…
GRADLE> > Task :app:processReleaseJavaRes
GRADLE> > Task :HelloSkip:extractDebugAnnotations
GRADLE> > Task :HelloSkip:mergeDebugGeneratedProguardFiles
GRADLE> > Task :HelloSkip:mergeDebugConsumerProguardFiles
GRADLE> > Task :SkipUI:assembleRelease
GRADLE> > Task :SkipUI:assemble
GRADLE> > Task :HelloSkip:mergeDebugJavaResource
GRADLE> > Task :app:compileDebugKotlin
GRADLE> > Task :HelloSkip:syncDebugLibJars
GRADLE> > Task :app:compileDebugJavaWithJavac
GRADLE> > Task :app:mergeReleaseJavaResource
GRADLE> > Task :app:dexBuilderDebug
GRADLE> > Task :app:processDebugJavaRes
GRADLE> > Task :app:mergeDebugGlobalSynthetics
GRADLE> > Task :app:mergeProjectDexDebug
GRADLE> > Task :app:mergeLibDexDebug
GRADLE> > Task :HelloSkip:bundleDebugAar
GRADLE> > Task :HelloSkip:assembleDebug
GRADLE> > Task :HelloSkip:assemble
GRADLE> > Task :app:mergeDebugJavaResource
GRADLE> > Task :app:minifyReleaseWithR8
GRADLE> > Task :app:shrinkReleaseRes
GRADLE> > Task :app:packageRelease
GRADLE> > Task :app:createReleaseApkListingFileRedirect
GRADLE> > Task :app:assembleRelease
GRADLE> > Task :app:assemble
GRADLE> 
GRADLE> BUILD SUCCESSFUL in 53s
GRADLE> 403 actionable tasks: 403 executed

this is the instruction in DOCS -> Gradle Projects -> Building Locally

but when I tried swift build --build-tests it shows me many error messages like below

Desktop/myMac/Apps/hello-global/Sources/HelloGlobal/ContentView.swift:68:87: error: Skip is unable to determine the owning type for member 'light'. This often occurs when other issues prevent Skip from matching the surrounding API call, and it may resolve when those issues are fixed. Or add the owning type explicitly (e.g. MyType.light)
        .preferredColorScheme(appearance == "dark" ? .dark : appearance == "light" ? .light : nil)
                                                                                      ^~~~~

In Xcode, it doesn't any matter but when I try to build with CLI, this kind of error message appears. I tried this with `skip test' again and then saw log.

[51/64] Skip ProjectRun
[52/64] Compiling SkipDrive Version.swift
[53/64] Emitting module SkipDrive
[54/64] Compiling SkipDrive GradleHarness.swift
error: fatalError

Even error log doesn't tell me what is wrong.

I'm trying to follow your instructions in DOCS but keep failing. Is there any doc that I can follow to make an .apk file manually?

I can manage about iOS Side with Xcode but have no idea what should I do if I want to extract .apk to test with my phone and manually upload .aab file

Thanks again and have a great day!!

nex5turbo commented 2 months ago

Self answer....

I found the error came from ToolBarItemPlacement. I used .topBarTrailing for all of my tool bar components, and error was also from it.

After I have removed that, build is successful. It works in swift, but doesn't work with swift build executable.

aabewhite commented 2 months ago

Are you saying that .topBarTrailing worked in full Skip Xcode builds but caused problems for Skip command-line builds? That would be very strange.

nex5turbo commented 2 months ago

Yes build with Xcode, it doesnt matter but with such like $swift build, $skip test, $skip export nothing works

aabewhite commented 2 months ago

When you have a chance, you might want to run "brew upgrade skip" and also in Xcode use File->Packages->Update to Latest. That way you'll definitely have all the latest in both environments. Then try again.

A warning, though: we recently updated some of our build configurations, so after upgrading you might have to update your application's build.gradle.kts:

buildgradlekts
nex5turbo commented 2 months ago

Thanks for advise aabewhite!

It works for some cases, but still doesn't work for other cases. Unfortunately, even though I marked #if !SKIP, UIApplication is unresolved when I try to build it with command line. And some features also, like ToolBarItemPlacement as I mentioned it at my previous comment.

I'll leave a comment if I find something!