I am experiencing a strange error when opening a just-downloaded .mmpk. It only happens on the first download of the day. All subsequent downloads and opens of the same .mmpk work just fine. Same thing when I use a different iPad to download to. Here are some code snippets:
// destination
toURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
// after download code
// SUCCESS, SAVE FILE
if FileManager.default.fileExists(atPath: toURL.path) {
try FileManager.default.removeItem(atPath: toURL.path)
}
try data.write(to: toURL)