0

A project is in the latest version Xcode and swift. I have a main SwiftUI View as a home page like this:

import SwiftUI
import swiftScan //pods library
struct ContentView: View {
var body: some View {
    NavigationView {
        ZStack{
            NavigationLink(destination: LBXScanView()) {
            }        
        }
    }
}

LBXScanView is a UIView of a pod after I "install pods" in the project. It gives an error saying, "Generic struct 'NavigationLink' requires that 'LBXScanView' conform to 'View'". I do not want to change the origin codes in the pods as it may need to use a few pods.

Is there any way only to change the SwiftUI View? or something else? Any help will be appreciated.

  • 2
    Use UIViewRepresentable. Next should be helpful https://stackoverflow.com/questions/62131218/understanding-uiviewrepresentable – Asperi Feb 05 '21 at 06:19
  • I think it needs to set the UIView into UIViewRepresentable. But I do not want to change the UIView.swift in the pods. – Guodong Rong Feb 05 '21 at 06:24
  • 1
    You don't need to change the `UIView` but rather create a new `UIViewRepresentable` struct which will contain the UIView. See [How to wrap a custom UIView for SwiftUI](https://www.hackingwithswift.com/quick-start/swiftui/how-to-wrap-a-custom-uiview-for-swiftui) and [Using UIView and UIViewController in SwiftUI](https://www.vadimbulavin.com/using-uikit-uiviewcontroller-and-uiview-in-swiftui/) – pawello2222 Feb 05 '21 at 11:22

0 Answers0