Hi there,
I've encountered a file permission bug in iOS 18.1.1 when using FileManager.default.copyItem(at:to:) to copy files from an iCloud shared folder to the app sandbox. This issue occurs under the following conditions:
The source file resides in an iCloud shared folder.
The iCloud shared folder is owned by another iCloud user and shared with read-only permissions.
The app copies the file to its sandbox using the copyItem(at:to:) method.
Observed Behavior:
After copying the file to the app sandbox, the original file's read-only permissions are propagated to the copied file. This results in an inability to delete the copied file from the app sandbox, with the following error message:
NSCocoaErrorDomain, Code 513: "The file couldn’t be removed because you don’t have permission to access it."
Steps to Reproduce:
Access a shared iCloud folder owned by another user with read-only permissions.
Copy a file from this folder to the app sandbox using FileManager.default.copyItem(at:to:).
Attempt to delete the copied file within the app sandbox.
Workaround:
Until this issue is resolved, the bug can be avoided by initializing the UIDocumentPickerViewController with the asCopy: true parameter:
UIDocumentPickerViewController(forOpeningContentTypes: contentTypes, asCopy: true)
This ensures that the copied file does not inherit the original permissions from the shared source file.
Example Project:
To reproduce the issue and observe the error, I’ve created a sample project hosted on GitHub:
https://github.com/giomurru/FileDeletePermissionBug
This project provides step-by-step instructions for testing and reproducing the bug.
Environment:
iOS/iPadOS Version: 18.1.1
Devices: [iPhone 15, iPad 9th Gen]
Development Tool: Xcode 16.1
I hope this helps Apple engineers and other developers experiencing the same issue. Feedback or additional insights would be appreciated.
Giovanni
Post
Replies
Boosts
Views
Activity
Hi, I'd like to know if I have to set ITSAppUsesNonExemptEncryption key to true when using encrypted CoreML models as explained in the WWDC20-10152 video Use model deployment and security with Core ML
Thank you.
Gio
Hi there, do you happen to know if XCode 14 will support macOS 12 Monterey? I can see that its beta release still works with macOS Monterey but what about the final version?
I noticed that current release of XCode 13 does not support the previous macOS 11 Big Sur. They dropped support with the update 13.3. Does someone know if it will be the same for XCode 14? Will they initially maintain support for Monterey and then drop support at some point in time?
Hi, I am trying to create an action extension for my iOS app.
My action extension for now is a simple image viewer, the one of the default action extension template.
My problem is that the action extension is working only for jpg images but not for heif images. I am testing this with the Apple's Photos app.
This is my plist:
keyNSExtension/key
dict
keyNSExtensionActionWantsFullScreenPresentation/key
true/
keyNSExtensionAttributes/key
dict
keyNSExtensionActivationRule/key
dict
keyNSExtensionActivationDictionaryVersion/key
integer2/integer
keyNSExtensionActivationSupportsImageWithMaxCount/key
integer1/integer
/dict
keyNSExtensionServiceAllowsFinderPreviewItem/key
true/
keyNSExtensionServiceAllowsTouchBarItem/key
true/
keyNSExtensionServiceFinderPreviewIconName/key
stringNSActionTemplate/string
keyNSExtensionServiceTouchBarBezelColorName/key
stringTouchBarBezel/string
keyNSExtensionServiceTouchBarIconName/key
stringNSActionTemplate/string
/dict
keyNSExtensionMainStoryboard/key
stringMainInterface/string
keyNSExtensionPointIdentifier/key
stringcom.apple.ui-services/string
/dict
Do you know how to make it work also for HEIF pictures?
Hi guys,
I'd like to trigger an event, in particular I'd like to load another scene when the camera node transform property is similar to a particular target transform.
Is it possible?
I thought about computing a distance between the camera transform and my target transform, but I don't know how to compute this distance. Any idea?
The measure of similarity does not need to be super precise but it has to be efficient since it has to run at 60fps.
Thank you
Giohn
I can't find some of the deployment targets in the General tab however I can add them manually from the Build Settings tab.
The missing targets are iOS 12.0, 14.2, 14.0, 13.3, 13.1, 12.2, 12.0 and the list goes on...
Do you experience the same problem?
I am running Xcode 12.4 on MacOS Catalina 10.15.7
Cheers,
Giohn
Hi guys, I watched the talk about adding support for local network privacy permissions in iOS 14.
I can't understand if there is a way to check if user has denied the local network privacy permission. I need it so that when the permission is denied I can suggest the user to enable it in order to use the function in the app.
Is there an API I can use or is there any suggestion you have on how to deal with this situation?
Thank you.
Giohn
Hi just clicked update on the App Store to install the Xcode 11.6 update and it is now overwriting my Xcode 12 beta installation... Thank you Apple.... 🤦♂️
Ok... false alarm. It looked like it was updating Xcode 12 beta but it did update Xcode 11 indeed. Just a bug in the UI I suppose.
Have a nice day! 🙃
Hi guys,I am having memory leaks using AVPlayerViewController with iOS 12.4 and XCode 10.3.I built a test to reproduce it.Just create a new project using Single View App template, then use this code in the ViewController.swift override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
DispatchQueue.main.asyncAfter(deadline: .now() + 7.0) {
self.playerViewController = AVPlayerViewController()
let player = AVPlayer(url: URL(string: "https://wolverine.raywenderlich.com/content/ios/tutorials/video_streaming/foxVillage.m3u8")!)
self.playerViewController.player = player
NotificationCenter.default.addObserver(self, selector: #selector(self.playerDidFinishPlaying(note:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.playerViewController.player?.currentItem)
self.present(self.playerViewController, animated: true) {
player.play()
}
}
}
@objc func playerDidFinishPlaying(note: NSNotification) {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.playerViewController.player?.currentItem)
self.playerViewController.dismiss(animated: true)
}The code presents (with a 7 seconds delay) an AVPlayerViewController with a video url (you can use another one if you prefer) and close it automatically when the video ends. Since the code is in viewDidAppear the process is repeated in loop.The memory leaks appear everytime the AVPlayerViewController is dismissed and memory keeps growing and is never released.The leaks are present even if you don't do the automatic dismiss using the AVPlayerItemDidPlayToEndTime notification.Just add this code to your viewcontroller and dismiss the AVPlayerViewController using the close button.The problem of memory leaks persists.override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
self.playerViewController = AVPlayerViewController()
let player = AVPlayer(url: URL(string: "https://wolverine.raywenderlich.com/content/ios/tutorials/video_streaming/foxVillage.m3u8")!)
self.playerViewController.player = player
self.present(self.playerViewController, animated: true) {
player.play()
}
}
}If I am doing something wrong please help me understand what is it.Thank you for your time.Gio