ios - "project.app"需要-Onone Swift 优化级别来使用预览

标签 ios swift xcode swiftui

试图将 SwiftUI 集成到现有的大型项目中。我已按照步骤将其集成到我的项目中,但是当我尝试预览我的新 SwiftUI View 文件时,我收到了错误。

Cannot preview in this file - current target needs adjusted build settings

末尾有一个小 (i) 符号表示..
"project.app" needs -Onone Swift optimization level to use previews

尽管 SwiftUI 文件不是 Root View Controller ,但我已经添加了我的场景委托(delegate),因此我特别注意将 willConnectTo 方法留空。

默认情况下,在我的项目 < Build Settings < Swift Compiler - Code Generation < Optimization Level.. Debug 设置为 No Optimization[-Onone],release 是 Optimize for Speed[-O]... 这与我的实践设置相同SwiftUI 项目。

我尝试了许多解决方案,但都没有奏效。

Reviewing the license agreement in the terminal

Checking my Command Line Tools

Edit my Info.plist - 虽然这并没有解决它,但似乎这是一件很重要的事情。

Ultimate Explanation For Integration我跟着

最佳答案

确保 调试 在 Product -> Scheme -> Edit Scheme -> Build Configuration 中选择了配置帮助我解决了这个问题。

关于ios - "project.app"需要-Onone Swift 优化级别来使用预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59870106/

相关文章:

swift - SceneKit 动态对象从静态地板掉落

ios - 以编程方式检测 SwiftUI 中的暗模式以显示适当的图像

ios - Xcode 4.0.1 中的自动布局框在哪里

c++ - 是否可以在 Xcode 调试器中输入变量来检查它们是什么?

ios - 在 Swift 中使用 renderInContext 出现在屏幕上时捕获选定 View 的问题

ios - iOS 应用程序 swift 3 中的谷歌翻译 rest api 错误 403

iphone - 从 iOS 5 迁移到 iOS 6 可能出现的问题

ios - iOS-在4.0之前播放mp3

swift - 表格单元格内的 UIButton 不更改属性

ios - 在 Xcode UI Builder 的何处放置应用程序的启动画面?