Cannot preview in this file - active scheme does not build this file : SwiftUI on Xcode 11 in CatalinaOS

坚强是说给别人听的谎言 提交于 2020-12-26 05:51:44

问题


I opened Landmark App using SwiftUI on Xcode 11 in macOS Catalina(10.15) and while opening the Canvas Editor for .swift files containing SwiftUI is showing

Cannot preview in this file - active scheme does not build this file

Try Again, Diagonistics option or restarting Xcode not solving the problem.


回答1:


Select the Scheme that has the current file to Preview




回答2:


If this is a new project coming from a copied folder and inside an iCloud folder, just close Xcode and relaunch it. The sync was not yet done.




回答3:


I experienced the same issue. All I did was to copy the "StartingPoint" folder out of the downloaded folder and relaunched the project. It worked!!!




回答4:


I encountered the same error for some of my SwiftUI View files when trying to preview on Canvas. What fixed the issue was I copied the code within the current file, deleted the file, created a new SwiftUI View file under the same name and pasted the original code. Hope that helps!

Creating a new folder in Documents/Desktop and copying the files over also resolves the issue.




回答5:


In the schemes I was able to select, it contained only one scheme. Reopening the folder in a folder that's not in the Downloads directory made live editing work for me



来源:https://stackoverflow.com/questions/58416469/cannot-preview-in-this-file-active-scheme-does-not-build-this-file-swiftui-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!