Post

Replies

Boosts

Views

Activity

Code to read from iCloud Drive works on Mac Catalyst and iOS Simulator, gives permission errors on physical iOS device - Why?
The code here works on Mac Catalyst, and on the iOS simulator; on a physical iOS device it throws an error on the try Data line with an error, NSCocoaErrorDomain Cocoa=257: "The file couldn't be opened because you don't have permission to view it." let puzzleParser = PuzzleParser() var pseudoPuzzleData: Data let urlToLoad = UserDefaults.standard.url(forKey: "lastSavedDocument") if urlToLoad != nil { let decoder = JSONDecoder() do { let result = urlToLoad?.startAccessingSecurityScopedResource() print("hello from loadInitialPuzzle(), \(result)") pseudoPuzzleData = try Data(contentsOf: urlToLoad!) urlToLoad?.stopAccessingSecurityScopedResource() AppDelegate.puzzle = try decoder.decode(Puzzle.self, from: pseudoPuzzleData) } catch // etc. Any ideas why this is happening, and what to do about it? I could really use some help here ...
1
0
775
Jul ’21
Why are dates all messed up in Google search of Developer Forums??
I don't know if this is a question for Google or Apple, but when I do a Google search that leads to results on developer.apple.com, Google reports dates that typically originate from June 2020. But when I go to the link, it's often for a question that's years older. For example, I just did a search on "delete all records from CloudKit zone en masse". The image shows the link -- it says Jun 20, 2020 -- but if I follow the link it shows the question was asked 4 years ago. Obviously date is hugely important when doing a search, why is this happening? [Tangential question: why won't Apple provide a utility to delete all the CloudKit records in a zone??!!]
1
0
667
Jul ’21
Mac Catalyst - can't override highlight color in UITextField
I want to override the highlight color for text in UITextFields (for a Mac Catalyst app) so that I can't actually see it. I've tried setting the tintColor property to UIColor.clear, but it has no effect: when I select text, behind it I see the color that the user selects in System Preferences General Highlight color. Here is a picture of the problem: hi.stack.imgur.com/ku2iJ.png The text is highlighted, but instead of yellow (the background color of the UITextField), it's showing the highlight color (blended with the yellow). Is this a bug? What's the work around? Any hints would be greatly appreciated!
1
0
889
May ’21
UIDocumentPickerViewController works on iOS, not on Mac Catalyst??
The code below works fine on an iPad or iPhone -- saveDocument() writes to /Users/me/Library/Containers/My-App/Data/Documents, and openDocument() shows me the content of that folder. Beautiful. On macOS, openDocument() shows the Documents folder at the root level of iCloud Drive, not the sandboxed version, which is local to my computer It's like the documentPickerVC.directoryURL is being ignored. Why?? What am I doing wrong. If it helps, the documentURL looks like this: file:///Users/me/Library/Containers/org.me.My-App/Data/Documents/ Any help would be really, really appreciated! func saveDocument(){         let encoder = JSONEncoder()         encoder.outputFormatting = .prettyPrinted         do {             let puzzleData = try? encoder.encode(puzzle) 						print("Saving: \(documentURL)")             let saveableURL = documentURL!.appendingPathComponent("\( .puzzle.date)")             try puzzleData!.write(to: saveableURL)         } catch {             displayError(title: "Error while saving document", message: "There was an error: \(error)")         }     }         // when the user taps on the Open button     @objc func openDocument(){         documentPickerVC = UIDocumentPickerViewController(forOpeningContentTypes: [UTType("public.item")!, UTType("public.data")!], asCopy: true )         documentPickerVC.delegate = self         documentPickerVC.modalPresentationStyle = .formSheet         documentPickerVC.directoryURL = documentURL         self.present(documentPickerVC, animated: true)     }
1
0
1.1k
Dec ’20
UIBarButtonItem(title:image:primaryAction:menu:) not available in Mac Catalyst?
Now that my app is in the App Store for iOS and iPadOS, I'm trying to go for the trifecta using Mac Catalyst. Specifically, I'm trying to invoke UIBarButtonItem(title:image:primaryAction:menu:), and when I've checked the magic Mac button in Deployment Info (invoking Mac Catalyst), the compiler is complaining about this statement: saying that it "Cannot convert value of type 'UIMenu' to expected argument type 'Selector?'. There's another form of UIBarButtonItem's initializer that does want a selector -- and I'm using that elsewhere -- but the documentation states - https://developer.apple.com/documentation/uikit/uibarbuttonitem/3600776-init that this method *is* available for Mac Catalyst. What's going on? Thanks for any help.
0
0
550
Sep ’20
Can't Deploy iOS app to macOS
I've made an app for iOS 14 for iPhone and iPad. When I try to build for macOS as well by checking on the magic Mac box, I get this: The operation couldn’t be completed. (OSStatus error -10670.) Domain: NSOSStatusErrorDomain Code: -10670 User Info: {     "_LSFunction" = "_LSOpenStuffCallLocal";     "_LSLine" = 3664; }- System Information macOS Version 11.0 (Build 20A5364e) Xcode 12.0 (17210.1) I'm running the latest version of macOS and Xcode beta, I've cleaned the project, I've Googled -- I can't even *find* this particular error number -- and that's exhausted my problem-solving skills. I *had* opened the project up in Xcode (non-beta), because I was going to build it for The App Store, maybe that did something? Anyways, any help would be appreciated.
7
0
1.5k
Sep ’20
Wanted: URL to iCloud Drive's Downloads folder
I am trying to configure a UIDocumentPickerViewController so that when it is presented, it will show the contents of the user's iCloud Drive Downloads folder. This mean that I need to set its directoryURL property. What I can't figure out is what to set that directoryURL to. I tried: crosswordPuzzleDownloadsURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)!.appendingPathComponent("Downloads") but the app just crashes on that line, since url(forUbiquityContainerIdentifier:nil) returns nil. I think this has something to do with iCloud Container Identifiers in the Entitlements File, but I can't find a good example that walks through this. Anyways, without good documentation, I'm lost. Can someone please tell me how to accomplish what I hope is a simple task?
0
0
553
Sep ’20
Safari crashing when downloading?
I'm working on an app, and have turned over download responsibilities to Safari, thusly: UIApplication.shared.open(URL(string: "nytimes.com/crosswords")!, options: [:], completionHandler: nil) // If I put in the https the Forums software objects, but it is there, Safari does get to the site. Once I'm at the site, I tap to download, and immediately get a crash (see below). At first I thought it was my app, but then I reset the iPad with Erase All Contents and Settings, and just downloaded directly from Safari (my app wasn't even installed), yet the error persists. Is anybody else seeing this? Path:									/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Applications/MobileSafari.app/MobileSafari Identifier:						MobileSafari Version:							 14.0 (604.1) Code Type:						 X86-64 (Native) Parent Process:				launchd_sim [7210] Responsible:					 SimulatorTrampoline [615] User ID:							 501 Date/Time:						 2020-09-04 17:59:56.697 -0500 OS Version:						Mac OS X 10.16 (20A5354i) Report Version:				12 Bridge OS Version:		 5.0 (18P50358b) Anonymous UUID:				4CC279BD-C050-70BE-3C9C-80C6689A987C Sleep/Wake UUID:			 C3BB6F1F-67AB-41B2-A5A6-85122824DD46 Time Awake Since Boot: 35000 seconds Time Since Wake:			 15000 seconds System Integrity Protection: enabled Crashed Thread:				1	Dispatch queue: com.apple.NSXPCConnection.user.com.apple.DocumentManagerCore.Downloads Exception Type:				EXC_BAD_ACCESS (SIGBUS) Exception Codes:			 KERN_PROTECTION_FAILURE at 0x000070000b32ff68 Exception Note:				EXC_CORPSE_NOTIFY Termination Signal:		Bus error: 10 Termination Reason:		Namespace SIGNAL, Code 0xa Terminating Process:	 exc handler [7402] VM Regions Near 0x70000b32ff68: 		JS JIT generated code			27af4b001000-27af4b002000		 [		4K] ---/rwx SM=NUL	-> STACK GUARD								70000b32f000-70000b330000		 [		4K] ---/rwx SM=NUL	stack guard for thread 1 		Stack											70000b330000-70000b3b2000		 [	520K] rw-/rwx SM=COW	thread 1 Application Specific Information: CoreSimulator 732.13 - Device: iPad Pro (11-inch) (2nd generation) (DCD41CB8-B807-4A59-9504-7B2BC3559167) - Runtime: iOS 14.0 (18A5357e) - DeviceType: iPad Pro (11-inch) (2nd generation) Thread 0:: Dispatch queue: com.apple.main-thread 0	 libsystem_kernel.dylib				 0x00007fff5da0ff6e mach_msg_trap + 10 1	 libsystem_kernel.dylib				 0x00007fff5da102e0 mach_msg + 60 2	 com.apple.CoreFoundation			 0x0000000107040e77 __CFRunLoopServiceMachPort + 316 3	 com.apple.CoreFoundation			 0x000000010703b58d __CFRunLoopRun + 1284 4	 com.apple.CoreFoundation			 0x000000010703ab9e CFRunLoopRunSpecific + 567 5	 com.apple.GraphicsServices		 0x00000001160f2db3 GSEventRunModal + 139 6	 com.apple.UIKitCore					 0x0000000110f15c73 -[UIApplication _run] + 912 7	 com.apple.UIKitCore					 0x0000000110f1ab84 UIApplicationMain + 101 8	 com.apple.mobilesafari				 0x00000001042e65e2 0x104260000 + 550370
1
0
1k
Sep ’20
UIDocumentPickerViewController - ignoring directoryURL - bug or programmer error?
The UIDocumentPickerViewController is not working, and I'm not sure if it's a bug or misinterpretation of the "documentation". If I set UIDocumentPickerViewController's directoryURL, it seems to just ignore it. For instance, directoryURL is file:///var/mobile/Containers/Data/Application/abcdefgh-abcd-efgh-ijkl-mnopqrstuvwx/Downloads/. But this code opens it up in the directory from the last time I'd presented a UIDocumentPickerViewController: 		crosswordPuzzleDocumentPickerVC.delegate = self 		crosswordPuzzleDocumentPickerVC.modalPresentationStyle = .formSheet 		crosswordPuzzleDocumentPickerVC.directoryURL = crosswordPuzzleDownloadsURL 		fileBeingOpened = .crosswordPuzzleFile 		self.present(crosswordPuzzleDocumentPickerVC, animated: true) Why isn't it heeding the directoryURL? Any help would be appreciated, my app is this close to being ready to submit, but making the user scrounge for a folder just seems cheap.
0
0
519
Sep ’20
Can a UIDocumentPickerViewController show the contents of my app's Documents folder?
I am working on an app that is successfully saving and retrieving crossword files (writing them out in JSON) but currently only works with hardcoded file names. I now want my user to be able to select files from the Documents folder, and I would like the UI to look a) good, and b) follow Apple's guidelines. I tried using the UIDocumentPickerViewController, but this article - https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories seems to imply that it only works with files that are external to the sandbox. With the code below, I just end up seeing a Downloads folder. let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.item", "public.data"], in: .im) 		documentPicker.delegate = self 		documentPicker.modalPresentationStyle = .formSheet 		documentPicker.directoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMasks[0] 		print(documentPicker.directoryURL) // yup, this is right 		self.present(documentPicker, animated: true) What's the right way to let the user see the contents of their Documents folder, so they can pick a file from it? I could read the contents and put them in a table view, but the UIDocumentPickerView's view looks (of course) very polished. Thanks for any help!
3
0
970
Aug ’20
Xcode beta crashes whenever I try to open Devices/Simulator window
Whenever I try to open the Devices/Simulator window, it opens for a second, then I get a spinning beachball and Xcode crashes with this message shown below. It's a good thing this wasn't an *important* window, like the editor 😀 😀 Still, any ideas how I can fix this? I've tried reinstalling, deleting ~/Library/Developer/Xcode, rebooting, nothing seems to work. Path:&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;/Applications/Xcode-beta.app/Contents/MacOS/Xcode Identifier:&#9;&#9;&#9;&#9;&#9;&#9;com.apple.dt.Xcode Version:&#9;&#9;&#9;&#9;&#9;&#9;&#9; 12.0 (17210.1) Build Info:&#9;&#9;&#9;&#9;&#9;&#9;IDEFrameworks-17210001000000000~14 (12A8189n) Code Type:&#9;&#9;&#9;&#9;&#9;&#9; X86-64 (Native) Parent Process:&#9;&#9;&#9;&#9;??? [1] Responsible:&#9;&#9;&#9;&#9;&#9; Xcode [1110] User ID:&#9;&#9;&#9;&#9;&#9;&#9;&#9; 501 Date/Time:&#9;&#9;&#9;&#9;&#9;&#9; 2020-08-30 15:14:23.931 -0500 OS Version:&#9;&#9;&#9;&#9;&#9;&#9;Mac OS X 10.16 (20A5354i) Report Version:&#9;&#9;&#9;&#9;12 Bridge OS Version:&#9;&#9; 5.0 (18P50358b) Anonymous UUID:&#9;&#9;&#9;&#9;4CC279BD-C050-70BE-3C9C-80C6689A987C Time Awake Since Boot: 1000 seconds System Integrity Protection: enabled Crashed Thread:&#9;&#9;&#9;&#9;0&#9;Dispatch queue: com.apple.main-thread Exception Type:&#9;&#9;&#9;&#9;EXC_BAD_INSTRUCTION (SIGILL) Exception Codes:&#9;&#9;&#9; 0x0000000000000001, 0x0000000000000000 Exception Note:&#9;&#9;&#9;&#9;EXC_CORPSE_NOTIFY Termination Signal:&#9;&#9;Illegal instruction: 4 Termination Reason:&#9;&#9;Namespace SIGNAL, Code 0x4 Terminating Process:&#9; exc handler [1110] Application Specific Information: ProductBuildVersion: 12A8189n Crashing on exception: The window has been marked as needing another Update Constraints in Window pass, but it has already had more Update Constraints in Window passes than there are views in the window. <DVTDevicesWindow: 0x7ff0819a7f80> 0x359 (857) {{367, 369}, {1040, 700}} Devices en
5
0
1.4k
Aug ’20
SwiftUI - Debug Preview not working in Xcode 12 beta 2?
Nothing prints to the console when I tap on a button, although the debugger will break on the print() lines. I've chosen Debug Preview rather than just Live Preview in the Canvas, and I've tried restarting Xcode. Before I file feedback, is anyone else seeing this?     var body: some View {         VStack(alignment: .leading){             Button("One Fish"){                 print("One")             }             Button("Two fish"){                 print("Two")             }         }     } }
22
0
7.9k
Jul ’20
SwiftUI - Picker Binding not Working :-(
I am trying to bind a Picker, but it's not working. I create a BindableObject, an instance of Settings, add it to the environment using environmentObject() in SceneDelegate, and address it in the View using @EnvironmentObjectstruct ContentView : View { var favoriteFoods = ["Tofu", "Seitan", "Nilla Wafers", "Avocado Toast"] @EnvironmentObject var settings : Settings // meanwhile, inside var body: some View ... Picker(selection: $settings.favoriteFoodChoice, label: Text("Favorite Food")){ ForEach(self.favoriteFoods.identified(by: \.self)){ food in Text(food) } }Here's what my Settings looks like:class Settings : BindableObject { var didChange = PassthroughSubject&lt;void,never&gt;() var favoriteFoodChoice:Int { willSet { print("Favorite Food Choice will be \(newValue)") didChange.send() print("Favorite Food Choice: \(favoriteFoodChoice)")// never changes when I select a different food. } didSet { print("Favorite Food Choice was \(oldValue)") didChange.send() print("Favorite Food Choice: \(favoriteFoodChoice)")// never changes when I select a different food. } } init(favoriteFoodChoice:Int) { self.favoriteFoodChoice = favoriteFoodChoice } convenience init(){ self.init(favoriteFoodChoice:0) } }When I change the selected food, I see output from print(), but favoriteFoodChoice stays the same. Isn't it supposed to change?? Or am I misunderstanding how binding works with Pickers?Any help would be appreciated!
7
0
10k
Jun ’19
Multiple Developers at One Company?
Hi, All:We have been told that one company can only have one developer account -- and so at our university, the media relations folk own that account, and so our students have no way to publish. However the University of Wisconsin at Madison is able to somehow do this -- they have multiple departments, apparently, publishing apps.Does anyone know how they get around this restriction? We tried getting a separate DUNS number, but that didn't work -- Apple said that as long as we were at one address, we can only get one account.Michael
7
0
21k
Nov ’15