title: How to call PHPhotoLibrary presentLimitedLibraryPicker from SwiftUI?
body: <p>What would be the correct way of calling PHPhotoLibrary's presentLimitedLibraryPicker method from SwiftUI?</p>
  <p>The method requires a UIViewController, which I don't have in SwiftUI.</p>
  <p>I have tried to use UIViewControllerRepresentable in order to create a UIViewController, and it works, but the result is that two View Controllers are presented, the one I create with UIViewControllerRepresentable, and the Limited Library Picker.</p>
  <p>Both View Controllers need to be dismissed in order to get to the original screen, which is not desirable.</p>
  <p>To sum up the issue I see:</p>
  <ol>
  <li>presentLimitedLibraryPicker works by passing a ViewController.</li>
  <li>This makes me create and present a dummy ViewController, just so I can call the method.</li>
  <li>There's no way to obtain a reference to the Limited Library Picker,    also it doesn't offer a delegate. So I can't detect when the Limited Library Picker controller is dismissed.</li>
  </ol>
  <p>This is my attempt (It shows the picker, but when you dismiss it, you need to dismiss the extra, dummy, view controller too:</p>
  <pre><code>import Foundation
  import SwiftUI
  import Photos
  import PhotosUI
  
  struct TestView: View {
  
     @State var showLibraryPicker = false
  
  var body: some View {
      NavigationView {
          VStack {
              Button(&quot;Open Library Picker&quot;) { showLibraryPicker = true }
          }
          .navigationBarTitle(&quot;Test&quot;, displayMode: .inline)
          .navigationViewStyle(StackNavigationViewStyle())
          .sheet(isPresented: $showLibraryPicker, onDismiss: { print(&quot;Dismissed&quot;) }) {
              TestLimitedLibraryPicker()
              }
          }
      }
  }
  
  
  struct TestLimitedLibraryPicker: UIViewControllerRepresentable {
  
       func makeUIViewController(context: Context) -&gt; UIViewController {
           let controller = UIViewController()
           PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: controller)
            return controller
       }
  
      func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
  
       }
  }
  </code></pre>