zweifisch / ob-swift

org-babel functions for swift evaluation
12 stars 3 forks source link

Interested in a pull request for previewing SwiftUI? #4

Closed xenodium closed 3 years ago

xenodium commented 4 years ago

Wrote a snippet patching org-babel-execute:swift to preview SwiftUI blocks. Interested in including in ob-swift? Happy to send PR.

Wrote about it here http://xenodium.com/swiftui-layout-previews-using-emacs-org-blocks

ob-swiftui

scott56gps commented 3 years ago

I'm interested! This looks very helpful. Great job @xenodium

xenodium commented 3 years ago

I'm interested!

Nice. @scott56gps we may want to consider a separate package (maybe ob-swiftui). ob-swift seems a little inactive. Goals are likely different enough for separate packages anyway.

scott56gps commented 3 years ago

I agree that a separate package would be appropriate. By the way, I ran the swiftui code yesterday and it works great!

xenodium commented 3 years ago

By the way, I ran the swiftui code yesterday and it works great!

Ah nice to hear @scott56gps! Gave me a good nudge to give it a go... see if ob-swiftui works for ya. I'm sure it'll need changes but it's a start.

https://github.com/xenodium/ob-swiftui

xenodium commented 3 years ago

ps. It also supports multiple view structs now.

#+begin_src swiftui :results window :view FooView
  struct FooView: View {
    var body: some View {
      VStack(spacing: 10) {
        BarView()
        BazView()
      }
    }
  }

  struct BarView: View {
    var body: some View {
      Rectangle()
        .fill(Color.yellow)
        .frame(maxWidth: .infinity, maxHeight: .infinity)
    }
  }

  struct BazView: View {
    var body: some View {
      Rectangle()
        .fill(Color.blue)
        .frame(maxWidth: .infinity, maxHeight: .infinity)
    }
  }
#+end_src
scott56gps commented 3 years ago

@xenodium, I just installed the updated ob-swiftui.el and it works great! Thank you for providing this functionality.

xenodium commented 3 years ago

Thanks @scott56gps. Great to hear!

konrad1977 commented 2 years ago

Can this be used somehow as a minor mode to preview SwiftUI in Emacs? I mean outside org-mode. Like a side by side buffer ala Xcode? How can we preview more complex views with dependencies that lives outside the view?

xenodium commented 2 years ago

Can this be used somehow as a minor mode to preview SwiftUI in Emacs?

As is, no. But the logic could be moved/extended. Needs work.