In my opinion SwiftUI preview is the most useful feature in SwiftUI if you want to work with older version of IOS. In this post I share how I set up my project.
Create project like showing in the pictures:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiP7ce78AOMd486TFcBvcwY7zSd9zfExAAnGlQmQEemega0YgpCc_lz4A5rtAGnf3hFYKA7rROH4RIyzSDjXG_TWqLUHS9wtctLYZ0f6cJeZXHrTWyqEV9Lp9x-y_1lLVmGXiBrCAcwBsk/s400/project-type2.png)
Delete the unused ContentView which use the SwiftUI.
Modify AppDelegate as follow.
Build the project and refresh Canvas. The previews should show now. You can try to change a background color of the ViewController and see the change take effect immediately. Like in the video:
Finally, Link to the code.
- ninjahoahong
Comments
Post a Comment