Skip to content

[Bug]: LiveView Native SwiftUI Integration Connection Failure when use lvn-go #1557

@youfun

Description

@youfun

What happened?

Description

I'm experiencing an issue with LiveView Native SwiftUI integration. The server appears to be handling requests correctly (returning 200 responses), but the lvn-go shows a connection failure.
it work when i in 0.3.1 version

Environment

Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Mix 1.17.3 (compiled with Erlang/OTP 27)

  • {:phoenix, "~> 1.7.11"},
  • {:phoenix_live_view, "~> 1.0.2 "},
  • live_view_native: 0.4.0-rc.1
    live_view_native_live_form: 0.4.0-rc.1
    live_view_native_stylesheet: 0.4.0-rc.1
    live_view_native_swiftui: 0.4.0-rc.1
  • macOS: 14.2.1

Reproduction Steps

  1. upgrade livenaitve to 0.4.0 install deps
  2. Set up Phoenix LiveView with SwiftUI templates (root.swiftui.neex)and core_components.swiftui.ex(use mix lvn.swiftui.gen to recreate core_components.swiftui.ex )

code from(https://github.com/liveview-native/liveview-client-swiftui/blob/main/priv/templates/lvn.gen.layout/root.neex)

(if dont use this templates and recreat core_compoenents ,it can't be compile)
3. Launch the SwiftUI simulator app (com.dockyard.LiveViewNativeGo)
4. Attempt to connect to the Phoenix server

Current Behavior

The server log shows successful connections and request handling:

[info] Sent 200 in 5ms
[info] CONNECTED TO Phoenix.LiveView.Socket in 19µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
[info] GET /
[debug] Processing with [App]Web.[Feature]Live.Index.nil/2
  Parameters: {"_format": "swiftui", "_interface": {...}}
  Pipelines: [:browser]
[debug] QUERY OK source="[table]" db=1.6ms
[info] Sent 200 in 7ms

However, the SwiftUI simulator displays a connection failure message.

Expected Behavior

The SwiftUI simulator should successfully connect and display the LiveView content.

Server Configuration

# SwiftUI layout files
# app.swiftui.neex
<.flash_group flash={@flash} />
<%= @inner_content %>

# root.swiftui.neex
<csrf-token value={Phoenix.Controller.get_csrf_token()}/>
<Style url={~p"/assets/app.swiftui.styles"} />
<NavigationStack>
  <%= @inner_content %>
</NavigationStack>

Additional Information

  • The web browser interface works correctly at (http://localhost:4000)
  • No errors appear in the Phoenix server logs
  • The problem appears to be in the connection between the SwiftUI simulator and Phoenix server despite successful HTTP responses

Any help or suggestions would be greatly appreciated!

Library Version

0.4.0-rc.1

Xcode Version

15.4

Swift Version

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

On which device or simulator are you running into the problem?

MacOS

Target Device Operating System Version

mac

Relevant log output

[info] CONNECTED TO Phoenix.LiveView.Socket in 30µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "FkkUQX9HSQcuOz5XEzA6PhAoazQ1RRsbE9x63rdXzMx0WgiwZk-SBqDc", "_format" => "swiftui", "vsn" => "2.0.0"}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions