SwiftUI Table column widths cannot be saved

I have a macOS app made with SwiftUI where I want to show a list of data in a tabular fashion. SwiftUI Table seems to be the only built-in component that can do this.

I would like to let the user size the columns and have their widths restored when the app is relaunched. I can find no documentation on how to do this and it does not seem to be saved and restored automatically.

I can find no way to listen for changes in the column widths when the user resizes and no way to set the size from code.

For a macOS app it seems that the only way to set the width of a column is to use e.g. .width(min: 200, max: 200). This in effect disables resizing of the column. It seems that idealSize is totally ignored on macOS.

Any suggestions?

That's currently not supported at the moment. You'll have to manually manage state restoration and the size of the width If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

How? I cannot see how to read the width and I cannot see how to set width?

I can fix the width but then the user cannot resize the columns.

Are there any way to achieve this with any other components in SwiftUI?

SwiftUI Table column widths cannot be saved
 
 
Q