소스 검색

Update packaging of MLKit pods. (#3731)

This removes some unnecessary code due to previously duplicated
frameworks, woo!
Ryan Wilson 6 년 전
부모
커밋
ab7897232f
2개의 변경된 파일6개의 추가작업 그리고 65개의 파일을 삭제
  1. 5 56
      ZipBuilder/Sources/ZipBuilder/CocoaPod.swift
  2. 1 9
      ZipBuilder/Sources/ZipBuilder/main.swift

+ 5 - 56
ZipBuilder/Sources/ZipBuilder/CocoaPod.swift

@@ -93,49 +93,8 @@ public enum CocoaPod: String, CaseIterable {
   /// of frameworks get pulled in.
   public func duplicateFrameworksToRemove() -> [String] {
     switch self {
-    case .mlVision:
-      return ["BarcodeDetector.framework",
-              "FaceDetector.framework",
-              "LabelDetector.framework",
-              "TextDetector.framework"]
-    case .mlVisionBarcodeModel:
-      return ["FaceDetector.framework",
-              "GTMSessionFetcher.framework",
-              "GoogleMobileVision.framework",
-              "LabelDetector.framework",
-              "Protobuf.framework",
-              "TextDetector.framework"]
-    case .mlVisionFaceModel:
-      return ["BarcodeDetector.framework",
-              "GTMSessionFetcher.framework",
-              "GoogleMobileVision.framework",
-              "LabelDetector.framework",
-              "Protobuf.framework",
-              "TextDetector.framework"]
-    case .mlVisionLabelModel:
-      return ["BarcodeDetector.framework",
-              "FaceDetector.framework",
-              "GTMSessionFetcher.framework",
-              "GoogleMobileVision.framework",
-              "Protobuf.framework",
-              "TextDetector.framework"]
-    case .mlVisionTextModel:
-      return ["BarcodeDetector.framework",
-              "FaceDetector.framework",
-              "GTMSessionFetcher.framework",
-              "GoogleMobileVision.framework",
-              "LabelDetector.framework",
-              "Protobuf.framework"]
-    case .mlVisionAutoML:
-      return ["BarcodeDetector.framework",
-              "FaceDetector.framework",
-              "LabelDetector.framework",
-              "TextDetector.framework"]
-    case .mlVisionObjectDetection:
-      return ["BarcodeDetector.framework",
-              "FaceDetector.framework",
-              "LabelDetector.framework",
-              "TextDetector.framework"]
+    case .mlVisionBarcodeModel, .mlVisionFaceModel, .mlVisionLabelModel, .mlVisionTextModel:
+      return ["GTMSessionFetcher.framework", "Protobuf.framework"]
     case .abTesting,
          .adMob,
          .analytics,
@@ -154,6 +113,9 @@ public enum CocoaPod: String, CaseIterable {
          .mlNLLanguageID,
          .mlNLSmartReply,
          .mlNLTranslate,
+         .mlVision,
+         .mlVisionAutoML,
+         .mlVisionObjectDetection,
          .performance,
          .remoteConfig,
          .storage:
@@ -162,19 +124,6 @@ public enum CocoaPod: String, CaseIterable {
       return []
     }
   }
-
-  /// Returns a group of duplicate Resources that should be removed, if any.
-  public func duplicateResourcesToRemove() -> [String] {
-    switch self {
-    case .mlVisionFaceModel:
-      return ["GoogleMVTextDetectorResources.bundle"]
-    case .mlVisionTextModel:
-      return ["GoogleMVFaceDetectorResources.bundle"]
-    default:
-      // By default, no resources should be removed.
-      return []
-    }
-  }
 }
 
 /// Add comparitor for OperatingSystemVersion. We only need the `>` since we don't care about equals

+ 1 - 9
ZipBuilder/Sources/ZipBuilder/main.swift

@@ -105,15 +105,7 @@ do {
       // Move all the bundles in the frameworks out to a common "Resources" directory to match the
       // existing Zip structure.
       let resourcesDir = fullPath.appendingPathComponent("Resources")
-      let bundles = try ResourcesManager.moveAllBundles(inDirectory: fullPath, to: resourcesDir)
-
-      // Remove any extra bundles that were packaged, if possible, by using the folder name and
-      // getting the CocoaPod selected.
-      if let pod = CocoaPod(rawValue: fileOrFolder) {
-        let duplicateResources = pod.duplicateResourcesToRemove()
-        let toRemove = bundles.filter { duplicateResources.contains($0.lastPathComponent) }
-        try toRemove.forEach(fileManager.removeItem(at:))
-      }
+      _ = try ResourcesManager.moveAllBundles(inDirectory: fullPath, to: resourcesDir)
     }
   }