thebrowsercompany / windows-samples

Sample Apps for Swift on Windows
MIT License
271 stars 14 forks source link

swiftwinrt : error Could not find type 'Point' in namespace 'Windows.Foundation' #7

Closed damywise closed 8 months ago

damywise commented 10 months ago

Hi, I'm trying to build the WinUI3AnimationsPreview, but I encountered an issue during cmake --preset debug.

However, all I'm getting is an error code (1), and this is inside swiftwinrt.log:

swiftwinrt : error Could not find type 'Point' in namespace 'Windows.Foundation'

I'm purely guessing that either this is the problematic line, which generates this:

-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.UI.Text.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.UI.Xaml.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Web.WebView2.Core.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.AppLifecycle.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.AppNotifications.Builder.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.AppNotifications.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.ApplicationModel.DynamicDependency.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.ApplicationModel.Resources.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.ApplicationModel.WindowsAppRuntime.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.PushNotifications.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.Security.AccessControl.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.System.Power.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.System.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.Widgets.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0.17763/Microsoft.Foundation.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0.17763/Microsoft.Graphics.winmd
-input C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0.17763/Microsoft.UI.winmd

and removing it causes the error to go away,

or this, which doesn't generate anything in SwiftWinRT_TEMP.rsp. I did try changing it to WINAPP_SDK_WINMD_REF which generates this

-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.UI.Text.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.UI.Xaml.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Web.WebView2.Core.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.AppLifecycle.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.AppNotifications.Builder.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.AppNotifications.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.ApplicationModel.DynamicDependency.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.ApplicationModel.Resources.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.ApplicationModel.WindowsAppRuntime.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.PushNotifications.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.Security.AccessControl.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.System.Power.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.System.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0/Microsoft.Windows.Widgets.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0.17763/Microsoft.Foundation.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0.17763/Microsoft.Graphics.winmd
-reference C:/Users/AAAS/Documents/GitHub/windows-samples/build/NugetPackages/Microsoft.WindowsAppSDK.1.4.231008000/lib/uap10.0.17763/Microsoft.UI.winmd

but the error is still the same.

Swift version: https://github.com/thebrowsercompany/swift-build/releases/tag/20231214.3

compnerd.org Swift version 5.10-dev (LLVM 76fd286f1a92478, Swift 482c0d2bd1145c2)
Target: x86_64-unknown-windows-msvc

Windows version:

Microsoft Windows
Version 22H2 (OS Build 22621.2715)
art-divin commented 9 months ago

πŸ‘‹πŸ» Hello @damywise ,

thank you very much for reporting the issue!

I am receiving the same error, still could not understand what is going on exactly, but essentially it just means that there's something missing that was not provided to swiftwinrt which included Point type under Windows.Foundation namespace. It looks to me illogical to comment the -input line when swiftwinrt flags are constructed for CMake.

art-divin commented 9 months ago

πŸ‘‹ @stevenbrix excuse me for pinging, could you please shed some light on how to overcome this error?

Or please tag responsible/relevant people if possible 🀝

art-divin commented 9 months ago

Found the reference, indeed Point struct should be available as part of Windows.Foundation namespace in WindowsSDK 10.17763 build.

art-divin commented 9 months ago

Found out that https://github.com/thebrowsercompany/windows-samples/issues/1 already mentions this error and the solution seems to be:

this issue is due to a missing windows sdk. you should have 10.0.20348.0 installed. i realize this isn't in the pre-requisites.

art-divin commented 9 months ago

Checked, confirm, it indeed fixes the error in OP.

cc @damywise

-- Running swiftwinrt...
-- swifwinrt completed
-- Configuring done (12.2s)
-- Generating done (0.0s)
-- Build files have been written to:
art-divin commented 9 months ago

The problem is that WinRT repository mentions requirement Windows SDK 10.17763.0 whilst windows-samples requires 10.0.20348.0 in the README. It is confusing for a person who has 0 experience in this toolset.

This is the root cause in my opinion why @damywise and I faced this issue and probably wasted days (at least I did). I did get familiar with how CMake works though πŸ§‘πŸ»β€πŸŽ“

art-divin commented 9 months ago

After installing https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads I was able to execute the compiled demo app!

Though, debugging in VSCode does not work still, because LLDB extensions do not support arm64. I am using Parallels Desktop to run Windows 11, thus CPU type is arm64, while Windows is running as amd64.

image
stevenbrix commented 9 months ago

hey @art-divin! sorry folks for the delayed response here. thank you for the help. we should switch over to using the Contracts SDK package so that we can download the WINMDs and not require a pre-installed SDK version

damywise commented 8 months ago

I am happy to say that this error is no longer present and has been replaced with another error: error: unknown attribute 'retroactive' I'll probably open another issue within a few days/weeks if I can't figure out why.

stevenbrix commented 8 months ago

@damywise this is likely because you aren't using the latest swift build from here: https://github.com/thebrowsercompany/swift-build/releases

damywise commented 8 months ago

Ah yeah I thought I installed the latest swift but apparently I'm having trouble installing it. It just said it's completed even though nothing changed.

stevenbrix commented 8 months ago

odd, if you could uninstall and then re-install that would be great. really the generator should check for #if swift(5.11) before writing that attribute.

damywise commented 8 months ago

I've successfully installed the latest swift build, which now the only one that actually installs for some reason. Older builds doesn't. Still the same error though error: unknown attribute 'retroactive'

PS C:\Users\AAAS\Documents\GitHub\windows-samples> swift --version
compnerd.org Swift version 5.10-dev (LLVM 7c3b53ecaad54fb, Swift d7111290a279135)
Target: x86_64-unknown-windows-msvc