@@ -226,7 +226,7 @@ import BridgeJSUtilities
226226 withIntermediateDirectories: true ,
227227 attributes: nil
228228 )
229- try outputSwift . write ( to : outputSwiftURL , atomically : true , encoding : . utf8 )
229+ try writeIfChanged ( outputSwift , to : outputSwiftURL )
230230 }
231231 }
232232
@@ -241,7 +241,7 @@ import BridgeJSUtilities
241241 let encoder = JSONEncoder ( )
242242 encoder. outputFormatting = [ . prettyPrinted, . sortedKeys]
243243 let skeletonData = try encoder. encode ( skeleton)
244- try skeletonData . write ( to: outputSkeletonURL)
244+ try writeIfChanged ( skeletonData , to: outputSkeletonURL)
245245 }
246246
247247 if skeleton. exported != nil || skeleton. imported != nil {
@@ -283,6 +283,18 @@ private func hasBridgeJSSkipComment(_ content: String) -> Bool {
283283 BridgeJSGeneratedFile . hasSkipComment ( content)
284284}
285285
286+ private func writeIfChanged( _ content: String , to url: URL ) throws {
287+ let existing = try ? String ( contentsOf: url, encoding: . utf8)
288+ guard existing != content else { return }
289+ try content. write ( to: url, atomically: true , encoding: . utf8)
290+ }
291+
292+ private func writeIfChanged( _ data: Data , to url: URL ) throws {
293+ let existing = try ? Data ( contentsOf: url)
294+ guard existing != data else { return }
295+ try data. write ( to: url)
296+ }
297+
286298private func combineGeneratedSwift( _ pieces: [ String ] ) -> String {
287299 let trimmedPieces =
288300 pieces
0 commit comments