I am trying to add a TextField in SwiftUI. It successfully appears with the initial text, but it is not editable in the preview display, only when I run a simulator. Any ideas?
#State var smth: String = "smth"
var body: some View {
//Not editable in preview
TextField("Number", text: $smth)
}
Since the comment was a legit answer I just copy paste it here. Glad it worked for you as well
There has been an Xcode bug in the past were live preview TextField input was broken. Seems to be back :(. I just experienced the same on 13.2.1. running the preview on iOS 15.2. switching to an iOS 14.3 simulator seems to fix it in my case. (wait for the Preparing iPhone Simulator for Previews to finish). Related to
I just download Xcode 13.3.1, and MacOs 12.4 Beta, and now I can use the physical keyboard for enter data in a TextField on a preview.I don't know if you can download only Xcode 13.3.1 without downloading the MacOs 12.4 Beta, or if Xcode 13.3.1 download alone resolve the problem.
Related
I've already added AppIcon.appiconset Icon Files in info.plist, also no xcassets warnings. If I understand correctly, the app should show AppIcon if I set IconFiles in info.plist and AppIcons in General right?
Turns out it's a bug in Xcode 13. Restarting my Mac solved the problem.
https://developer.apple.com/forums/thread/682648
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.
As I have developed the iOS application using Xcode 7.3.
When reviewing the AutoLayout constraint on the device which having iOS 10 using Xcode 7.3 it properly display it but when using the Xcode 8 and then reviewing on the device then it does not show properly.
So my question if I am deploy the application on the AppStore using Xcode 7.3, so there is any chance that the AutoLayout constraint do not show properly in iOS 10.
Any help is much appreciated.
I am having the same issues in one of my iOS application as the constraint works in Xcode 7.x but not in Xcode 8, so I have found some work around for resolve it. Please find the below steps.
1) Open your storyboard in Xcode 8, then it popup regarding choose an initial device view, please select one of the option and then click on Choose Device. Please find the below GIF representation for same.
2) When you complete your changes, select the storyboard, go to File Inspector, on Interface Builder Document section, select the Opens In field and apply the Xcode 7.x. After that it popup regarding save so please select "Save and Close" option when it is prompted. Please find the below GIF representation for same.
3) Close the Xcode and then open the application.
Your storyboard changes will be saved, and your storyboard will function as it did on Xcode 7.x.
Hope it works for you!!!
The build given by Xcode 7.3 will not affect for constraint issue on iOS10.
Lately when I have been deploying any iOS application to the simulator (iPad or iPhone), XCode locks up (Not Responding) and the simulator simply displays a black screen. I have to force quit both.
Steps I have taken so far towards a resolution:
Clean
Reset the Simulator
Deleted the simulator folder
Reinstalled XCode from the App Store
Reinstalled XCode from the developer center
Has anyone else encountered this? Any suggestions for a solution?
Other info:
OSX Lion 10.7.3
XCode 4.3.2
Shibboleet
Thanks in advance for any help.
I had this problem and was able to continue by:
1) Edit the run scheme by clicking on the first part of the App name to the right of the "Stop" button to bring down the scheme list and click "Edit Scheme..."
2) Click on the Run item and change the debugger from LLDB to GDB.
3) Run
I think the problem was that I validated the settings and it offered to automatically change the debugger from GDB and LLDB and I clicked "OK" because the advisor message sounded very self-assured.
Enjoy.
Under Scheme, go to edit scheme, and change launch from wait for App.app to launch to automatically under the Info tab.
EDIT: If you upgraded Xcode, make sure the old separate simulator is uninstalled.
hmmm, weird simulator, instruments issue i had once would work when i command-tabbed back and forth. try deleting derived data?
Wow, finally the XCode 4.2 / iOS5 simulator has StoreKit support.
In my app I've noticed that when StoreKit asks for an AppleID/password, I can enter that information using the simulator on-screen keyboard, but NOT via the Mac keyboard.
Is this normal or do I have some other issue?
I have the same issue but I do this as a workaround:
Type your password somewhere, copy it, paste into the simulator using cmd + v and then use the iOS paste function (press and hold in the passeword field) to paste it into the dialogue.
Saved me a lot of time!
From the iOS Simulator menu, select "Reset Content and Settings..."
Sometimes the simulator just gets confused and loses the ability to interact with the keyboard. This should fix it.