iOS SwiftUI how to bring up extra actions like "Embed in VStack" when interacting with code? - swiftui

I am looking at this SwiftUI tutorial and it suggests I can see extra actions upon Command-Clicking the SwiftUI elements in code. In my Xcode, this jumps me to the class definition.
I see there's an option in XCode 11.0 t change the Option key to show SwiftUI inspector, however, this still does not let me modify SwiftUI code elements using actions like "Embed in VStack"
How can I get both inspector and extra SwiftUI actions when interacting with SwiftUI Code (not the preview)?

Extra SwiftUI actions show when Canvas is opened (shortcut: Option-Command-Enter or ⌥+⌘+↵):
canvas is closed
canvas is opened

The accepted answer doesn't work for me on macOS 10.15.5 and Xcode 11.4.1.
The Good news is that you can get it via a shortcut of [Command][Shift][Left Click] on a SwiftUI element or by clicking Show Code Actions on the right click menu.

Instead of using the mouse, I recommend using the Xcode hotkey for bringing up code actions. Navigate to Preferences -> Key Bindings and search for Show Code Actions. You'll see the preset hotkey which you can then customize. My default key binding was Shift+Command+A. Just make sure you cursor is over the intended element when you press the hotkey.

You can change the command click behavior where you were looking under Xcode -> Preferences, Navigate tab.
Rather unintuitively, if you pick "Selects Code Structure", then command+click will bring up the SwiftUI menu options you're looking for (granted the canvas is open).
If you do this, you can still jump to definition via control+command+click
Conversely, if you'd prefer to continue to use command+click to jump to definition, you can instead use control+command+click to bring up the SwiftUI menu options.

Command clicking on a view will not work in Xcode 12.2 and 12.3 (under MacOS 10.15.5) if you have your preferences different than Xcode expects.
You have to change your Navigation preferences for Command-click on Code: to Selects Code Structure before the proper menu will appear when you command click on a View.
To change this. press command , to open your preferences and select the Navigation button. The option you need to change is in the first popup menu.

Related

How to fix not working keybind in WebStorm IDE

I generally have a bunch of custom keybinds for WebStorm, but this one particularly does not work - Select opened file. I've bound it with different key combinations (see screenshots below), and also I've verified that it does not conflict with any MacOS keybinds (although even the ones that conflict actually do work).
Also when I hover the actual UI button, it shows different keybind for it (which also does not work).
So, essentially, I have to always click the UI button with the mouse. I'd like to be able to do so with the keybind. I'm not even sure how to troubleshoot this...
Does anyone else using WebStorm have this keybind working properly?
It's a known usability issue, IDEA-271054. The actual action you need assigning a shortcut to is Other | Select File in Project View:

XCode 12.2/Big Sur: Where are the object inspector and SwiftUI library?

I don't know how to accurately phrase this, but after upgrading to Big Sur and XCode 12.2, I have discovered that I cannot Command-Click on a SwiftUI keyword (i.e., HStack or TextField) and get the object-specific inspector to come up. On my right panel I only ever see the inspector/settings for the .swift source file I have open; how do I get the object-specific context menu to come back?
Another issue, probably related to the first: when pressing the "+" button to insert a new object from the library, there are no longer any SwiftUI library objects available to pick; see the screenshot below:
[
The Canvas Editor must be open, and then everything works.

How do we add "InputAccessoryItem"s in Swift UI?

Using SwiftUI and running into an issue with the keyboard. I want to use the .deicmalPad but I can't dismiss it since it has no "return" button.
Found a workaround: use UIApplication.shared.windows[0].endEditing(true) on a button. (Tried using it on the viewController for the app but it broke NavigationLinks)
Now I want to add the "Next", "Previous" and "Submit" strip above the keyboard, like in this picture: http://brainwashinc.com/wp-content/uploads/2017/07/Simulator-Screen-Shot-Jul-28-2017-9.07.42-AM.png
can't find SwiftUI documentation for this feature, only finding incompatable UIKit solutions involving inputAccessoryView and it's items.
Ultimatly want to use the "Submit" button's event to use UIApplication.shared.windows[0].endEditing(true) and finally get the keyboard to go away.
Thanks in advance

XCode 6 Tab Bar tabs greyed out

Anytime I add a tab bar controller to XCode the tab bar is greyed out and I can't see any of the tabs in the storyboard. At runtime it displays fine. I can't figure out why it is happening.
Add an image to the Tab Bar Item and you will see the normal view of the tab bar on the specific View Controller where you changed it. When every single Tab Bar Item got an image you will also see the normal appearance in your Tab Bar Controller.
Setting an image for the Tab Bar Items and restarting xcode fixed it for me.
In the assets folder (or wherever your image is kept), set 'Render as' to Original image
It looks like this was a bug in the XCode UI. This has been fixed in later versions of XCode.

has uitabbarcontroller changed in xcode 4

I recently upgraded to xcode 4. My application utilizes tabbarcontroller. In old xcode 3.x, you were able to change the tabs to different types per this screenshot:
From what I gather in researching this issue, xcode 4 no longer offers this functionality. Am I missing something? From what I researched we are now suppose to delete/add tabs then change attributes to get the desired effect. So, to that end in xcode 4, I've added a new tab item and made the class a UINavigationController fully expecting the ability to toggle the "Shows Navigation Bar" with a checkbox. But, the "Navigation Controller" grouping never appears. What am I missing?
Thanks for your help.
I was surprised at first too and I was about to ask the same question. But, when you open the Object Library, in the bottom you can see a big star, "Tab Bar Item". Just drag that to the tab bar and you will notice a new item added to the tab bar controller.
Weird but works!
Just drag drop View Controller onto tabs!
Thanks
I played with xcode 4 a little bit more and discovered you can drag Navigation Controller from library onto your UITabBarController and it will create your tab item for you and set it up as a NavigationController. Pretty cool. Hopefully this will help others.