Skip to content

Commit ab78972

Browse files
authored
Update packaging of MLKit pods. (#3731)
This removes some unnecessary code due to previously duplicated frameworks, woo!
1 parent 932ab0e commit ab78972

File tree

2 files changed

+6
-65
lines changed

2 files changed

+6
-65
lines changed

ZipBuilder/Sources/ZipBuilder/CocoaPod.swift

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -93,49 +93,8 @@ public enum CocoaPod: String, CaseIterable {
9393
/// of frameworks get pulled in.
9494
public func duplicateFrameworksToRemove() -> [String] {
9595
switch self {
96-
case .mlVision:
97-
return ["BarcodeDetector.framework",
98-
"FaceDetector.framework",
99-
"LabelDetector.framework",
100-
"TextDetector.framework"]
101-
case .mlVisionBarcodeModel:
102-
return ["FaceDetector.framework",
103-
"GTMSessionFetcher.framework",
104-
"GoogleMobileVision.framework",
105-
"LabelDetector.framework",
106-
"Protobuf.framework",
107-
"TextDetector.framework"]
108-
case .mlVisionFaceModel:
109-
return ["BarcodeDetector.framework",
110-
"GTMSessionFetcher.framework",
111-
"GoogleMobileVision.framework",
112-
"LabelDetector.framework",
113-
"Protobuf.framework",
114-
"TextDetector.framework"]
115-
case .mlVisionLabelModel:
116-
return ["BarcodeDetector.framework",
117-
"FaceDetector.framework",
118-
"GTMSessionFetcher.framework",
119-
"GoogleMobileVision.framework",
120-
"Protobuf.framework",
121-
"TextDetector.framework"]
122-
case .mlVisionTextModel:
123-
return ["BarcodeDetector.framework",
124-
"FaceDetector.framework",
125-
"GTMSessionFetcher.framework",
126-
"GoogleMobileVision.framework",
127-
"LabelDetector.framework",
128-
"Protobuf.framework"]
129-
case .mlVisionAutoML:
130-
return ["BarcodeDetector.framework",
131-
"FaceDetector.framework",
132-
"LabelDetector.framework",
133-
"TextDetector.framework"]
134-
case .mlVisionObjectDetection:
135-
return ["BarcodeDetector.framework",
136-
"FaceDetector.framework",
137-
"LabelDetector.framework",
138-
"TextDetector.framework"]
96+
case .mlVisionBarcodeModel, .mlVisionFaceModel, .mlVisionLabelModel, .mlVisionTextModel:
97+
return ["GTMSessionFetcher.framework", "Protobuf.framework"]
13998
case .abTesting,
14099
.adMob,
141100
.analytics,
@@ -154,6 +113,9 @@ public enum CocoaPod: String, CaseIterable {
154113
.mlNLLanguageID,
155114
.mlNLSmartReply,
156115
.mlNLTranslate,
116+
.mlVision,
117+
.mlVisionAutoML,
118+
.mlVisionObjectDetection,
157119
.performance,
158120
.remoteConfig,
159121
.storage:
@@ -162,19 +124,6 @@ public enum CocoaPod: String, CaseIterable {
162124
return []
163125
}
164126
}
165-
166-
/// Returns a group of duplicate Resources that should be removed, if any.
167-
public func duplicateResourcesToRemove() -> [String] {
168-
switch self {
169-
case .mlVisionFaceModel:
170-
return ["GoogleMVTextDetectorResources.bundle"]
171-
case .mlVisionTextModel:
172-
return ["GoogleMVFaceDetectorResources.bundle"]
173-
default:
174-
// By default, no resources should be removed.
175-
return []
176-
}
177-
}
178127
}
179128

180129
/// Add comparitor for OperatingSystemVersion. We only need the `>` since we don't care about equals

ZipBuilder/Sources/ZipBuilder/main.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,7 @@ do {
105105
// Move all the bundles in the frameworks out to a common "Resources" directory to match the
106106
// existing Zip structure.
107107
let resourcesDir = fullPath.appendingPathComponent("Resources")
108-
let bundles = try ResourcesManager.moveAllBundles(inDirectory: fullPath, to: resourcesDir)
109-
110-
// Remove any extra bundles that were packaged, if possible, by using the folder name and
111-
// getting the CocoaPod selected.
112-
if let pod = CocoaPod(rawValue: fileOrFolder) {
113-
let duplicateResources = pod.duplicateResourcesToRemove()
114-
let toRemove = bundles.filter { duplicateResources.contains($0.lastPathComponent) }
115-
try toRemove.forEach(fileManager.removeItem(at:))
116-
}
108+
_ = try ResourcesManager.moveAllBundles(inDirectory: fullPath, to: resourcesDir)
117109
}
118110
}
119111

0 commit comments

Comments
 (0)