Missing/Broken features in SwiftUI [List]

Hi guys, as many of you (I think), I have been busy learning SwiftUI as fast as I can. In my case for a new app I want to develop for personal purposes and probably for an App Store release.


In my (small) learning journey I have found a few things that SwiftUI is missing or just not working, but since there is not too much information yet I wanted to make a simple thread with all the things I have found at the moment. This can be useful for anyone who is learning SwiftUI or wants to check current SwiftUI status.


I promise to add my findings here and update this post as fast as I can.

Feel free to mention every feature you think is important to have in the list, any features you think is not a bug or broken/missing feature, or any solution you may find to one of this mentioned problems.


Ps: I know we have Xcode release notes but many of the current bugs of SwiftUI are not mentioned there.


SwiftUI missing/broken features (as of beta 3):


  • Can’t remove rows separator from List
  • Can’t push or pop without navigationView
  • Can’t display a modal in full screen (only in the new style)
  • No dismiss modal programatically available (environment safe keypath maybe is the correct solution?)
  • Custom Fonts are sometimes not rendered correctly on Xcode Previews (A little bit fixed in Beta 3 but still buggy)
  • Code Completion in some places is not working (haven’t found a specific way to reproduce the bug consistently but definitely happens)
  • Pinch to Zoom is not working in Xcode Previews
  • Switching between files that have or not have a cambas may cause the cambas to remain open
  • No way to remove the accessory item of a navigationLink inside a List
  • Cant hide navigation bar from NavigationView (There is a new modifier called navigationBarHidden but when the next view is pushed, the navigationBar returns. The modifier only works for the first view not pushed ones)
  • Cant add a custom navigation bar to NavigationView
  • Colors in foregroundColor modifier are not updating in Previews correctly. Sometimes they work but most of the time is the same black color (Working better in beta 3 but some objects including navigationView are still having problems)
  • TextFields do not have a way of setting their keyboard type.
  • TextFields do not have the equivalent of UIKit beginFirstResponder and resignFirstResponder. That means there is no way of programatically setting or removing the focus from a text field.
  • SecureField does not have a way of knowing when the field became active, or inactive (TextField does have onEditChange, but SecureField does not).
  • Popovers as of beta3 seem to be broken.
  • Slider seems broken in Beta 3. No longer increment by Stride
  • .onAppear and .onDisappear are not firing during navigation transitions
  • TextFields are not resized properly when multiline text is used


Solved problems

  • Forms are not available (Now available in Beta 2)
  • Published property wrapper is not fully functional (Available since Beta 2 in Xcode projects. Playgrounds not working)
  • Colors added directly to the xcassets are not working in dark mode (Working in beta 3)
  • LaunchScreen is sometimes stuck with old layouts (happens to me only in SwiftUI projects sometimes) (Working in Beta 3)
  • There is no simple way to change the main view background color (Use background modifier, see answer 3)

Updating for beta 3

New finding, to add a background color for the main View just use the background modifier with a Color parameter. Since Color can have modifiers applied, apply a frame modifier with the values you need. In my case, a width of your screen width and a height of your screen height


Something like this

.background(Color.blue.frame(width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height))

Nice of you to create the list. If you accept suggestions for inclusion:


  • TextFields do not have a way of setting their keyboard type.
  • TextFields do not have the equivalent of UIKit beginFirstResponder and resignFirstResponder. That means there is no way of programatically setting or removing the focus from a text field.
  • SecureField does not have a way of knowing when the field became active, or inactive (TextField does have onEditChange, but SecureField does not).
  • Popovers as of beta3 seem to be broken.

I can't seem to re-activate a modal after dismissing it with a swipe down gesture (Not sure if this is related to "No dismiss modal programatically available", apologies if it is).


Force-quitting the app makes the modal available again.

Thanks guys, I'm going to update the original post with your suggestions

Can you share some code of how you're doing this defn?

Slider seems broken in Beta 3. No longer increment by Stride. In the following example, incrementing by 0.1 instead of 0.5


```

Slider(value: $game.score, from: 0.0, through: game.maxScore, by: 0.5)

```

Updating with your suggestion...

You forgot to close the parentheses after 'blue'.


This doesn't work well on a grouped list. The list still shows a gray background. I even tried a ZStack, with the bottom a solid color. No go.


There needs to be a way to specifically change the color of a list or a group list. I don't think that exists now, so please add that to the list.

Also, .onAppear and .onDisappear are not firing during navigation transitions. .onAppear is firing but not when going back. .onDisappear is not firing on navigation transitions.

TextFields are not resized properly when multiline text is used. As a result, some lines at the bottom are clipped from view. The number of lines clipped at the bottom appears to be quite random.

Added, thanks

Beta 4 is now live, I'm downloading and will try everything as soon as I can

Hi Juan,

I tried beta 4, there are 4 problems.

  • Can’t remove rows when peform onDelete modifier of ForEeach
  • Can’t show modal at 2nd times after 1st showing it via presentation modifier (in beta 4, it was called sheet modifier)
  • No way to show keyboard type ,such as decimal pad.
  • Can't find a better way when clicked actionsheet then navigate to anather way.



Thanks

Thanks for the collection. Here is an item from https://forums.developer.apple.com/thread/119541. This is still broken in beta 5 and in Apple's tututorial.


• Use of multiple buttons in a List row does not work

Good information, I'm bookmarking this topic. My short list of problems, as of beta 5:


  • Can't disable animation for when the contents of a List changes.
  • Can't change the List seperators
  • There is no callback or property binding for performing a task after an animation completes.
  • Can't set the keyboard type for TextFields
  • I haven't looked in depth, but I haven't found a way of adding an InputView to a TextField


TextField( self.placeholder, text: self.field )
    .inputView() {
        HStack {
        Spacer()
        Button( action: {...} { Text( "Prev" ) }
        Button( action: {...} { Text( "Next" ) }
   }
}

A few things I've hit (have filed Feedback for issues 2 and 3 below):


1. String(format: <format>, myVar)


For @Published vars, like myVar above, the following format mechanism doesn't work:


Text("\(String(format: "%.03f", model.myVar))")


2. Options spread across two Picker() do not update highlighting correctly


Previously (beta 3), when options were spread across two SegmentedControl() which update the same var in a BindableObject (now ObservableObject) and @EnvironmentObject is used in a View to read/update this var, the hightlight for one SegmentedControl() was updated (de-highlighted) when the other SegmentedControl() was tapped. This is no longer the case.


For example, consider SegmentedControlA() has options A,B,C,D and SegmentedControlB() has options E,F,G,H. These options are tied to $model.myVar. SegmentedControlA() option A is currently highlighted. Now the user taps SegmentedControlB() option G. In beta 3, option A was de-highlighted and option G was highlighted.


With beta 5, replacing SegmentedControl() with Picker(), we start with PickerA() option A highlighted. The user then taps PickerB() option G. In this case, model.myVar is updated, as expected, but the highlight is not removed from option A.


If, however, you either:


1) in a TabView() app, switch to a different Tab and then back to the Tab containing the Pickers() option A is now de-highlighted. Or,

2) background the app by switching to another app or going to the iDevice home screen and then foreground the app


Option A is now de-highlighted.


Example:

  
 
class FooModel: ObservableObject {
    @Published var foo:Double = 1.0
}
struct Foo : View {
    var body: some View {
            VStack {
                ChooseFooLo()
                ChooseFooHi()
        }
    }
}

struct ChooseFooLo : View {
    @EnvironmentObject var model: FooModel
    var body: some View {
         Picker(selection: $model.foo, label: Text("")) {
            Text("A").tag(1.0)
            Text("B").tag(10.0)
            Text("C").tag(100.0)
            Text("D").tag(1000.0)
        }.pickerStyle(SegmentedPickerStyle())
    }
}
struct ChooseFooHi : View {
    @EnvironmentObject var model: FooModel
    var body: some View {<br>
         Picker(selection: $model.foo, label: Text("")) {
            Text("E").tag(10000.0)
            Text("F").tag(20000.0)
            Text("G").tag(30000.0)
            Text("H").tag(40000.0)
        }.pickerStyle(SegmentedPickerStyle())
    }
}
As an aside, I wonder why Picker() requires label: ... I've tried setting label: .nil and that doesn't work. Sigh.


3. Stepper() with Slider() and .cornerRadius.

If a Stepper() and Slider() each control the same var and they are both included in a VStack, and .cornerRadius() is applied to the VStack, the Stepper() no longer works when tapped. Remove .cornerRadius() and everything works as expected. Below is an example. Remove .cornerRadius() and Stepper() works. Add it, and Stepper() no longer works (the example below removes .font() and .background(), since these are not required to reproduce. I've tried various things like changing the size of .cornerRadius(), adding a (e.g.) smaller .cornerRadius() to the Stepper() directly, etc.

  
 
struct ChooseFooSize : View {
     @EnvironmentObject var model: FooModel
     var body: some View {
          VStack {
             Stepper(value: $model.foo_size, in: 64...9216) {
                 Text("Foo size: \(Int(self.model.foo_size))")
             }
             Slider(value: $model.foo_size, in: 64...9216, step: 1)
         }.cornerRadius(10)
     }
}

You cant as of yet build catalyst Applications using SwiftUI (which is a Know Issue with SwiftUI)

can't get/set current scroll position in a List (or ScrollView)

Now it's easy to set keyboard type on a TextField.

TextField("Number", text: someNumber).keyboardType(UIKeyboardType.numbersAndPunctuation)

Unable to change Popover view size on iPad.

Bug Report: FB7465491


struct ContentView: View {
    @State var showPopover: Bool = false
   
    var body: some View {
        Button(action: {
            self.showPopover.toggle()
        }) {
            Text("View Popover")
        }
            .popover(isPresented: $showPopover) {
                Text("Popover")
                    .background(Color.red)
                    .frame(width: 100, height: 100)
            }
    }
}

Yes, but this runs you right into another problem: For some of those keyboards (numberPad, decimalPad, and others) there's no way to dismiss them and capture whatever the user typed into the bound variable.

SelectionShapeStyle (macOS only) is not usable, since it has no public initializers.

Bug Report: FB7511755

Unable to set List row appear/disappear animation.

Another bug: you are unable to rearrange the tab order in TabView without SwiftUI undoing the rearranging.

https://stackoverflow.com/questions/59255398/swiftui-tabview-rearrange-tab-order-preservation

Missing/Broken features in SwiftUI [List]
 
 
Q