'SwiftUI - text gets truncated after embedded on a ScrollView

When added a long text inside a text view, it works as expected (not truncated).

Xcode 11.0 beta 6 (11M392q)

import SwiftUI

struct ContentView: View {

    var body: some View {



                Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")

                    .lineLimit(nil)



                }
            }



struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

enter image description here

But when embedded inside a ScrollView, it gets truncated (not expected):

import SwiftUI

struct ContentView: View {

    var body: some View {

        ScrollView {

                Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")

                    .lineLimit(nil)


                   }
                }
            }



struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

enter image description here

I tried setting a .lineLimit(nil) modifier, but also didn't avoid truncating the text.

Is this the expected behaviour for SwiftUI text? Or is it a bug?

Appreciate if someone can help! : )

Cheers



Solution 1:[1]

A solution for this problem (seems to be a bug with SwiftUI Xcode Beta 6), is to use the modifier bellow:

.frame(idealHeight: .greatestFiniteMagnitude)

Solution 2:[2]

Text("Your long text goes here")
    .fixedSize(horizontal: false, vertical: true)

should solve the problem.

This is default in iOS 13.1 beta 1 and above.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mattia Righetti
Solution 2 oguz ismail