Skip to content

Commit ce7dbce

Browse files
committed
Xcode 14.3 Data(contentsOfFile:) crash fixed with NSData bridging
1 parent 0704c13 commit ce7dbce

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

PhoneNumberKit/PhoneNumberKit.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,14 @@ public final class PhoneNumberKit: NSObject {
327327
guard let jsonPath = frameworkBundle.path(forResource: "PhoneNumberMetadata", ofType: "json") else {
328328
throw PhoneNumberError.metadataNotFound
329329
}
330-
let data = try Data(contentsOf: URL(fileURLWithPath: jsonPath))
331-
return data
330+
// let data = try Data(contentsOf: URL(fileURLWithPath: jsonPath))
331+
// return data
332+
if let nsData = NSData(contentsOfFile: jsonPath) {
333+
let data = Data(referencing: nsData)
334+
return data
335+
} else {
336+
throw PhoneNumberError.metadataNotFound
337+
}
332338
}
333339
}
334340

0 commit comments

Comments
 (0)