Swift 是否支持热重载

发布于 2025-01-15 10:20:28 字数 457 浏览 1 评论 0原文

我正在研究 Swift 功能,并有一个问题:是否有热重载功能或类似的功能(例如“即时运行”)。

https://developer.apple.com/xcode/swiftui/ 他们在此页面上表示:

“Xcode 包含直观的设计工具,使使用 SwiftUI 构建界面就像拖放一样简单。当您在设计画布中工作时,您编辑的所有内容都与相邻编辑器中的代码完全同步。当您键入时,代码会立即显示为预览,并且您对该预览所做的任何更改都会立即显示在您的代码中,Xcode 会立即重新编译您的更改并将它们插入到您的应用程序的运行版本中 - 始终可见且可编辑<。 /强>。”

我的问题是,这是否仅适用于使用 Swift 进行 UI 开发,但不适用于普通逻辑。

Im researching Swift features and have the Question if there is a Hot Reload Feature or something similar like "instant run".

https://developer.apple.com/xcode/swiftui/
On this Page they say:

"Xcode includes intuitive design tools that make building interfaces with SwiftUI as easy as dragging and dropping. As you work in the design canvas, everything you edit is completely in sync with the code in the adjoining editor. Code is instantly visible as a preview as you type, and any change you make to that preview immediately appears in your code. Xcode recompiles your changes instantly and inserts them into a running version of your app — visible, and editable at all times."

My question to that is if this is only true for UI-Development with Swift but doesnt work with thie normal Logic.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

独留℉清风醉 2025-01-22 10:20:28

对于处理正常逻辑而不仅仅是 UI 组件预览的问题,截至今天,Apple 尚未提供该功能,但是有一个开源项目旨在实现您正在寻找的功能:

https://github.com/krzysztofzablocki/Inject

To your question of processing normal logic and not just a preview of the UI components, as of today Apple does not provide that feature however there is an open source project that seeks to accomplish what you're looking for:

https://github.com/krzysztofzablocki/Inject

小瓶盖 2025-01-22 10:20:28

这只是预览的一个功能,但是如果您选择预览工具栏中的“运行”按钮,它将以与热重载非常相似的方式运行大量任意代码。

It's only a feature of Previews, but if you select the "run" button in the preview toolbar, it will run a lot of arbitrary code in ways that are very similar to hot reloading.

盗琴音 2025-01-22 10:20:28

不是真的......不像flutter,当你的代码在真正的虚拟机中运行......并允许热重载时,有某种预览,但你必须编写一些代码并更新环境参数。但它几乎不如真实虚拟机环境下那么好。

Not really... not like in flutter, when your code runs in true vm... and allows hot reloads, there is some kind of preview, but you will have to write some code and update env params. But it not nearlly as good as under real vm env.

他是夢罘是命 2025-01-22 10:20:28

我的问题是,这是否仅适用于使用 Swift 进行 UI 开发,但不适用于普通逻辑。

您是否在寻找REPL?如果是这样,您可能正在寻找 Swift Playground。 Xcode 也有它自己的游乐场系统,但我很难找到好的支持文档。

My question to that is if this is only true for UI-Development with Swift but doesnt work with thie normal Logic.

Are you looking for REPL? If so, you might be looking for Swift Playground. Xcode also has it's own playground system, but I'm having trouble finding good supporting documentations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文