FileHandle throwing APIs (e.g. seekToEnd()) crash on iOS13.0-13.3 Simulator

Originator:ncreated
Number:rdar://FB7743153 Date Originated:Jun 19, 2020 at 7:06 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:13.0 - 13.3
Classification:Crash Reproducible:Always
 
Although the FileHandle's `func seekToEnd() throws -> UInt64` is marked as available since iOS 13.0:

```
@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func seekToEnd() throws -> UInt64
```

it crashes on iOS 13.0, 13.1, 13.2 and 13.3 Simulator.


Steps to reproduce the issue:

1. Run following code on iOS 13.0, 13.1, 13.2 or 13.3 Simulator:
```
let directoryURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
let fileURL = directoryURL.appendingPathComponent("foo.txt", isDirectory: false)
FileManager.default.createFile(atPath: fileURL.path, contents: nil, attributes: nil)

do {
    let fileHandle = FileHandle(forWritingAtPath: fileURL.path)!
    defer { fileHandle.closeFile() }

    try fileHandle.seekToEnd()
    fileHandle.write("abcd".data(using: .utf8)!)
} catch {
    print("\(error)")
}
```
2. It crashes with:
```
dyld: Symbol not found: _$sSo12NSFileHandleC10FoundationE9seekToEnds6UInt64VyKF
```


The same problem seems to occur for other new APIs:
```
@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func readToEnd() throws -> Data?

@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func read(upToCount count: Int) throws -> Data?

@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func offset() throws -> UInt64

@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func seekToEnd() throws -> UInt64

@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func write<T>(contentsOf data: T) throws where T : DataProtocol
```

I don't have iPhone running iOS prior to iOS 13.4 to confirm this on a real device.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!