Xcode 11: Canvas does not show up

2020-01-31 12:25发布

I´m trying to get the new Canvas feature from Xcode 11 running, but the Canvas won´t show up. What am I doing wrong?

I just created a new default project (single view app), compiled it and activated 'Editor > Editor and Canvas'. I can navigate to each file in the project, nothing shows up.

What else does need to be done?

11条回答
Lonely孤独者°
2楼-- · 2020-01-31 12:33

Some important checklist , please check one by one. If all this is done , you can easily get "Editor and Canvas" option.

  1. Your MacOS version is equal or upper than 10.15

  2. You are using at least Xcode 11 Beta or later. If you have Xcode 11 but your MacOS is bellow 10.15 , you won't be able to see the option.

  3. Run the commands from Terminal :

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

and then

sudo xcodebuild -license

  1. If check list 1 and 2 is done , go to to the Preferences option and select command Line Tools. Preferences -> Locations and assigning the Command Line Tools to Xcode 11/Beta.

Most of the time, option 4 is the problem.

查看更多
看我几分像从前
3楼-- · 2020-01-31 12:37

you can still see the live view (without Catalina installed ) with the playgrounds. using UIHostingController.

import UIKit
import SwiftUI
import PlaygroundSupport



struct ContentView : View {
    var body: some View {

        Text("Hello World")
            .color(Color.blue)
    }
}

// Present the view controller in the Live View window
PlaygroundPage.current.liveView = UIHostingController.init(rootView: ContentView())

enter image description here

查看更多
够拽才男人
4楼-- · 2020-01-31 12:40

To preview and interact with views from the canvas in Xcode, ensure your Mac is running MacOS 10.15 beta.

Tools for SwiftUI development are only available when running on macOS 10.15 beta.

https://developer.apple.com/tutorials/swiftui/creating-and-combining-views

查看更多
够拽才男人
5楼-- · 2020-01-31 12:40

As well as running MacOS Catalina [beta] it seems that you need to have the command line tools installed otherwise it fails and 'pauses' the canvas (this happened with Xcode 11 Beta 2). To install them run:

xcode-select --install
查看更多
叼着烟拽天下
6楼-- · 2020-01-31 12:40

Canvas preview only works after update MacOS 10.14 to 10.15

We have Mac OS Catalina Beta version (10.15)

Upgrade your system and it works. :)

Check this link.

查看更多
Melony?
7楼-- · 2020-01-31 12:43

You need to be on Catalina macOS version (10.15), as stated in official tutorial

Be warned: Catalina doesn't support 32-bit applications, some old apps will stop working after update.

查看更多
登录 后发表回答