Closed elepedus closed 9 months ago
Looks like you have a space in the closing tag in the broken example, but not the working example: </VStack >
vs. </VStack>
.
This fails to compile with the regular HEEx sigil, so I don't think this is a problem with LVN.
FWIW I had run into this issue a couple times even when attempting to update deps on the base ElixirConf Chat app. It has something to do with the hex published 0.1.0 versions of live_view_native
or live_view_native_swift_ui
and phoenix_live_view
19
.
I thought it was something related to this LiveView 0.19 > Imported and module-level functions not working in non-web render macros #50
lvn-components-repro % mix hex.outdated
Dependency Current Latest Status
ecto_sql 3.10.2 3.10.2 Up-to-date
esbuild 0.7.1 0.7.1 Up-to-date
finch 0.16.0 0.16.0 Up-to-date
floki 0.34.3 0.34.3 Up-to-date
gettext 0.23.1 0.23.1 Up-to-date
jason 1.4.1 1.4.1 Up-to-date
live_view_native 0.1.0 0.1.0 Up-to-date
live_view_native_swift_ui 0.1.0 0.1.0 Up-to-date
phoenix 1.7.9 1.7.9 Up-to-date
phoenix_ecto 4.4.2 4.4.2 Up-to-date
phoenix_html 3.3.3 3.3.3 Up-to-date
phoenix_live_dashboard 0.8.2 0.8.2 Up-to-date
phoenix_live_reload 1.4.1 1.4.1 Up-to-date
phoenix_live_view 0.19.5 0.20.1 Update not possible
plug_cowboy 2.6.1 2.6.1 Up-to-date
postgrex 0.17.3 0.17.3 Up-to-date
swoosh 1.12.0 1.12.0 Up-to-date
tailwind 0.2.1 0.2.1 Up-to-date
telemetry_metrics 0.6.1 0.6.1 Up-to-date
telemetry_poller 1.0.0 1.0.0 Up-to-date
Changing mix.exs
to pull live_view_native
and live_view_native_swift_ui
from the main github branch instead of 0.1.0 from hex will correct the issue, and then you can also upgrade to phoenix_live_view
0.20.x
# {:live_view_native, "~> 0.1"},
# {:live_view_native_swift_ui, "~> 0.1"}
{:live_view_native,
git: "https://github.com/liveview-native/live_view_native.git", branch: "main"},
{:live_view_native_swift_ui,
git: "https://github.com/liveview-native/liveview-client-swiftui", branch: "main"}
@carson-katri That's a good catch, but unfortunately, a red-herring. I messed about with the formatting in my OP for clarity, and scored an own-goal -- sorry about that. I can confirm that the issue occurs without the extraneous spaces. Here's an example from the linked repo:
def render(%{platform_id: :swiftui} = assigns) do
~SWIFTUI"""
<VStack>
<.asdf {assigns}/>
</VStack>
"""
end
defp asdf(assigns) do
~SWIFTUI"""
<VStack>ASDF</VStack>
"""
end
I can confirm that @cohawk's suggestion resolves the issue, but only if I use both phoenix_live_view
0.20.x
. Using the main branches of live_view_native
and live_view_native_swift_ui
with phoenix_live_view
0.19.x
results in a compile error.
== Compilation error in file lib/live_view_native/platforms.ex ==
** (UndefinedFunctionError) function LiveViewNativeSwiftUi.platforms/0 is undefined (module LiveViewNativeSwiftUi is not available)
(live_view_native_swift_ui 0.1.0) LiveViewNativeSwiftUi.platforms()
(elixir 1.15.6) lib/enum.ex:4317: Enum.flat_map_list/2
lib/live_view_native/platforms.ex:8: (module)
ping @supernintendo
Resolved by https://github.com/liveview-native/live_view_native/pull/53 -- thanks! :)
What happened?
When I try to extract parts of my SwiftUI DOM into components, I get the error above. For example:
This works:
But this errors:
Since this is a compile-time error, the web version can't be used either, but if I move the component usage to the Heex render function, it works. Eg:
This works:
Library Version
0.1
Xcode Version
15.0
Swift Version
¯_(ツ)_/¯
On which device or simulator are you running into the problem?
iPhone
Target Device Operating System Version
16.4
Relevant log output