Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"project.app" needs -Onone Swift optimization level to use previews

Trying to integrate SwiftUI into an large existing project. I have followed steps to integrate this into my project, but when I try to preview my new SwiftUI view file, I get the error..

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

There is a little (i) symbol at the end which states..

"project.app" needs -Onone Swift optimization level to use previews

I have added my Scene delegate though the SwiftUI file is not the root view controller so I made careful attention of leaving willConnectTo method empty.

By default under my Project < Build Settings < Swift Compiler - Code Generation < Optimization Level.. Debug is set to No Optimization[-Onone], release is Optimize for Speed[-O]... This is the same settings as my practice SwiftUI project.

I have tried a number of solutions but nothing has worked yet.

Reviewing the license agreement in the terminal

Checking my Command Line Tools

Edit my Info.plist - Though this didn't solve it, it seems like this was something important to do.

Ultimate Explanation For Integration that I followed

like image 426
C. Skjerdal Avatar asked Jan 23 '20 00:01

C. Skjerdal


1 Answers

Ensuring the Debug config is chosen in Product -> Scheme -> Edit Scheme -> Build Configuration helped me to solve the issue.

like image 158
Shengchalover Avatar answered Nov 08 '22 20:11

Shengchalover