Is it possible to create a window/panel like the one which appears when you run a Xcode project. This type of windows appear through out macOS, but I can't seem to find out what they are called.
Here are examples:
Just playing with Swift UI basic app and the preview canvas is not showing even though I'm in canvas mode. App runs, and I have this little snippet what am I missing?
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
Maybe someone is looking for this:
Editor -> Canvas (Alt + Command + Enter)
To open the preview canvas, just go to Editor -> Canvas
Or do Alt + Command + Enter
If your macOS version is below 10.15, you will get the below error
Update mac and try the same.
To preview and interact with views from the canvas in Xcode, ensure your Mac is running on Catalina MacOS.
https://developer.apple.com/tutorials/swiftui/creating-and-combining-views
Please check apple document in the following URL
https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_2_release_notes
Xcode 11 beta supports development with SwiftUI.
Note
Tools for SwiftUI development are only available when running on macOS
Catalina 10.15 beta.
From the editor:
Top-Right corner of the editor, and then:
From the menu
Editor -> Canvas
Shortcuts
Open Canvas
⌥ option + ⌘ command + ↩ return
Refresh canvas
⌥ option + ⌘ command + P
A note about the macOS
In the mac environment, you can search for any menu option under the Help menu, then it will open the exact menu path you are looking for.
For example, searching for canvas result in this:
Additionally, if you are using macOS system older than beta version like 10.14 you can use Xcode playground to preview with following code.
import PlaygroundSupport
import SwiftUI
struct ContentView : View {
var body: some View {
Text("Hello World")
}
}
PlaygroundPage.current.liveView = UIHostingController(rootView: ContentView())
I'm running Xcode 12.2 on Catalina 10.15.7, and I not only need to make sure Canvas is selected but then I need to select Create Preview from the Editor menu.
To preview and interact with views from the canvas in Xcode, ensure your Mac is running macOS 10.15 beta.
In Xcode 11 Beta 6, there is a known issue and workaround for views that do not have their certain flags set (see below).
If this applies to you, and you are unable to set the corresponding flags, you may need to remove the #if debug flag around ContentView_Previews until the issue is fixed in a future Xcode release.
See the Xcode 11 Beta 6 Release Notes:
Preview providers that are defined in projects which don’t have -DDEBUG set for OTHER_SWIFT_FLAGS and wrapped in #if DEBUG don’t display in the canvas. That happens, for example, in Objective-C apps which that never had occasion to specify OTHER_SWIFT_FLAGS. (51138834)
Workaround: Remove the #if DEBUG and #endif from around the PreviewProvider declaration.
Alt + Command + Enter
Will solve the issue
Check this xcode_11_beta_5_release_notes https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_5_release_notes .
With Xcode 11 beta 5, previews are only available on macOS Catalina
10.15 beta 5, and only Xcode 11 beta 5 supports previews on macOS Catalina 10.15 beta 5. (52059562)
I have restarted the Xcode and machine and it's worked for me.
You can try this for many problems.
I was using using Xcode 4.5 to create an iPad application yesterday and completed it. But today when I took that same Xcode project and tried to run it on an older machine running Xcode 4.2, it is giving me an error about IBNSLayoutConstraint. Which i guess was due to the new features that were included in the new Xcode 4.5. So I was thinking is there a way to open project from new Xcode in the older version without having to install a new Xcode and OSX.
I am not sure if this question is asked here yet or not, but i tried to find a solution but no luck in that either.
PS. I already know that the best solution is to not opent those projects in older version but that is not what i am looking for.
There is an option in the inspector window when you select the xib file that will not use the constrains under "Show file the inspector" in the inspector called "Use autolayout".
Here is a screen shot of it.
uncheck autolayout feature from each xib file the open your project on xcode4.2, it works on my case, as autolayout is only available in iOS6
I'm using a 13" Macbook Pro. I'm beginning a project for University; I'm making an iPhone application. I bought the DevKit but had some problems opening Xcode, I realiased I'd upgraded to Lion since I downloaded it and needed to upgrade, so I did, so Xcode 4.3.
Now I can use Xcode fine (as far as I can tell) but Interface Builder gives me this error when I try to make a new iPhone Application Template/Project:
This version of Interface Builder does not support documents of type "Interface Builder Cocoa Touch Document (XIB 3.x)" targeting "iPhone/iPod touch".
And this one if I try to make a blank one, of any other the other options:
Interface Builder was unable to open the document "Empty.xib". iPhone/iPod touch development requires the iOS 3.1 SDK.
Now, I checked, and according the the AppStore (which is where I was forced to download it from) iOS 5.0/5.1 SDK is included. I tried to redownload a few times but to no avail. I have a feeling this is something really stupid, so feel free to call me so.
You should be using Xcode itself to create, view, and modify xib files for iOS 5 projects. Interface Builder as a separate application is no longer provided by Apple for iOS development.
Xcode 4 allows creation of user interface files from the File > New > New File menu item. When you select a user interface file from Xcode's project navigator (which you can show via View > Navigators > Show Project Navigator or by pressing Cmd-1), a user interface editor appears where the source code editor typically appears.
I have a project that has existed for quite a while, and I recently upgraded it to 4.0. Though it now throws out a bunch of warnings and an error similar to this:
{some xib setting} is not supported on iPhone OS versions prior to 3.0.
I have the Base SDK set to 4.0, and the deployment target set to 3.1, so why does XCode think it needs to care about "iPhone OS version prior to 3.0"? Is there a build setting I have set wrong that I'm not finding here?
Here is a screenshot of a handful of the warnings.
Xcode Errors http://beautifulpixel.com/assets/Info.plist_-_LatestChatty2-20100624-152508.jpg
Ah... eventually I deduced that if you click the waring icon in the lower right corner of the outline window of the opened xib, it brings up a window where you can set the deployment target for that xib. Changing it from 2.1 to 3.1 fixed my issues.