How to convert usdz to obj with code?

Use the  ModelIO

          print("Processing is complete!")
          let objPath = <#Your OBJ Path#>
          /// usdz file 
          let modelAsset = MDLAsset(url: URL(fileURLWithPath: outputFilename))
          modelAsset.loadTextures()
          do {
            try modelAsset.export(to:URL(fileURLWithPath: objPath))
            print("Exported to OBJ!")	
          }
          catch {
            print(error)
          }

The exported obj is missing most of the information compared to the original usdz.