Posts

Post marked as solved
1 Replies
815 Views
I've been building my app on Xcode 13 when suddenly it doesn't know about the iOS 15 APIs. Here are a couple error examples: self.modified = Date.now // Type 'Date' has no member 'now' and operation.modifySubscriptionsResultBlock = { result in // Value of type 'CKModifySubscriptionsOperation' has no member 'modifySubscriptionsResultBlock' I can take the exact same code and build it on my other Mac and it builds properly. Both Macs are using Xcode Version 13.0 (13A233) and running macOS 11.6 (20G165). I checked the deployment info for project and target (iOS 15.0), but of course using git I know I have the exact same code base on both machines. Is there an Xcode preference or system file that got hosed? I tried reinstalling Xcode, but it didn't help.
Posted Last updated
.
Post marked as solved
3 Replies
5.2k Views
This looks like a refresh of an old question. I'm using iOS 15 beta 7 and have presented a UIActivityViewController from a SwiftUI app. I get a ton of these errors when trying to share a two-item list containing String and UISimpleTextPrintFormatter. [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} [default] Attempt to map database failed: permission was denied. This attempt will not be retried. [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.) [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} It looks as if the API is checking for entitlements I haven't requested, but I am not trying to share images. I just want to share text as plaintext or a nicely formatted printable attributed string.
Posted Last updated
.
Post marked as solved
1 Replies
1.5k Views
To implement row reordering I know I could use List{ForEach{}.onMove} but in my situation I can't use List for reasons. So I need to implement my own item reordering using onDrag and onInsert. These modifiers use NSItemProvider. I think therefore my dragged data type needs to implement NSItemProviderWriting (and NSItemProviderReading). I've looked for examples but the closest code I've found is dragging URLs. When I try to implement these protocols in my type I end up with an error in .onInsert at (NSItemProvider item).loadObject(ofClass:MyType.self) that says "Instance method 'loadObject(ofClass:completionHandler:)' requires that 'MyType' conform to '_ObjectiveCBridgeable'" How should I be using .onDrag and .onInsert with a custom type?
Posted Last updated
.
Post not yet marked as solved
4 Replies
3.9k Views
I am making an iPhone-first app which has a 2 level data structure. I want the user to be able to drag List rows from section to section, but not reorder the sections. Is there a SwiftUI way to do it, or should I resort to UIKit? The basic problem seems to be that ForEach.onMove only allows reordering within its nearest datasource. That seems sensible as a general facility. As it stands now drags can only happen within a section. Swift ForEach(groups) { group in Section(header: Text(group.text)) { ForEach(group.items) { item in Text(item.text) } } } .onMove { … } I might be willing to dive into UIKit to get this done, if it'll handle it. Right now I've flattened the data and marked some items as "containers" and others as "leaves". All get emitted as a dumb flat list: Swift ForEach(items) { item in if item.isContainer { Text(item.text).bold() } else { Text(item.text) } } .onMove { … } The major downside is users can move the container "section header" lines. Drag and drop doesn't seem to work on iPhone, just iPads. I'm kinda shy about hierarchical lists using List(_,children:) because I expect move would still allow top level items (my containers) would be allowed to be moved.
Posted Last updated
.
Post marked as solved
1 Replies
1.6k Views
Why does a swipe action (using the new .swipeAction in SwiftUI 5.5, currently beta 3) set editMode? Notice when you swipe that "Edit" changes to "Done"? And yet this is not like full edit mode because tapping the EditButton shows the move handles (and the ever-annoying ugly blank indentation for the absent onDelete modifier). I think my next project won't use SwiftUI. import SwiftUI struct Fruit: Identifiable {     let id: UUID = UUID()     let name: String     let color: Color } struct ListingView: View {     @State var fruits: [Fruit] = [         Fruit(name: "banana", color: .yellow),         Fruit(name: "apple", color: .green),         Fruit(name: "tomato", color: .red)]          @Environment(\.editMode) private var editMode          var body: some View {         NavigationView {             VStack(alignment: .leading) {                 List {                     ForEach(fruits) { fruit in                         NavigationLink(                             destination: ZStack {                                 fruit.color                                 Text(fruit.name).bold().font(.largeTitle)                             }                                 .navigationTitle(fruit.name),                             label: {                                 HStack(alignment: .center) {                                     fruit.color.frame(width: 30, height: 30)                                     Text(fruit.name)                                 }                             })                             .swipeActions(edge: .leading, allowsFullSwipe: false) {                                 Button(action: { delete(fruit) },                                        label: { Image(systemName: "trash") }).tint(.red)                             }                     }                     .onMove(perform: { from, to in                         fruits.move(fromOffsets: from, toOffset: to)                     })                 }             }             .navigationBarTitle("Fruits")             .toolbar {                 ToolbarItem(placement: .primaryAction) {                     EditButton()                 }             }         }     }     private func delete(_ fruit: Fruit) {         guard let index = fruits.firstIndex(where: {$0.id == fruit.id}) else { return }         fruits.remove(at: index)     } } struct ListingView_Previews: PreviewProvider {     static var previews: some View {         ListingView()     } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
1k Views
Is there a variant of TextEditor that works with AttributedString? Does it expose the selectedText range? I want to create a custom text editor to mark ranges of an AttributedString. But I can make do in a clunky way with just String if I at least can get the selectedRange of the text in TextEditor. I expect I'll need to go to UIKit and use UITextView.
Posted Last updated
.
Post marked as solved
1 Replies
621 Views
Using CloudKit, when I perform CKFetchDatabaseChangesOperation(previousServerChangeToken:) the response in fetchDatabaseChangesCompletionBlock is an error: Metasync Continuation could not properly be parsed The first time through this works when the token is nil. The second time through it fails with this error. It was working at one time. I've tried deleting the app and resetting the development database as well. I am guessing this has to do with the server change token. I save and restore the server change token to UserDefaults using NSKeyedArchiver to archive/unachive it as Data, so it should be perfectly preserved. I'm using the privateCloudDatabase with a non-default zone.
Posted Last updated
.
Post not yet marked as solved
0 Replies
507 Views
I've made an "action extension" and now I need to make a glyph or template for NSExtensionServiceFinderPreviewIconName. The documentation has been useless for me. Everything I do ends up with a generic black image overlaid with some faint template lines: I understand a glyph ≠ template ≠ icon, but that glyph and template are both acceptable for the action extension. I've tried various ways to make my monochrome, black-and-transparent image but I'm missing something. I started with making it in Sketch. The PNG export has alpha and is black and white, though the color mode of the file is probably full color. I ran it through Icon Set Studio but Xcode warned me there were problems with it, and it came out entirely black. I took that PNG into Pixelmator Pro and used it to make a clipping mask since one of the hallmarks of a glyph is also supposed to be an alpha mask. Re-exported this new PNG with no change or improvement. Exported it as an SVG, but still nothing helping. The docs don't say where the image needs to be in the Xcode workspace. I've tried putting it in both the containing app's Asseets.xcassets and in the extension's Media.xcassets, but neither helps. Once I downloaded a glyph template file (for Sketch) from Apple, but it is tremendously complicated and I hope I can get away without making a version for every font weight and size class. A step by step guide would help a lot, so if anyone has some energy to make one I bet other indies would appreciate it. We can't all afford $$$ for a graphic artist.
Posted Last updated
.
Post not yet marked as solved
1 Replies
714 Views
I would like the first() operator to send a value as soon as it's received a value that satisfies the condition (and to finish publishing as well). But I don't know how to test this is really happening. The only test I've devised is below, but I suspect it is wrong. The map operator will keep demanding values of course, so I expect it to print all of them. Yet the sink subscriber doesn't invoke receiveValue or receiveCompletion until after map is done, which suggests first is awaiting upstream completion. Does first really does need the upstream to complete before it sends anything onward? What's really the story here for first? import Foundation import Combine let numbers = (-10...10) let cancellable = numbers.publisher     .map({ n in         Thread.sleep(forTimeInterval: 1)         print("sending \(n)")         return n     })     .first { $0 0 }     .sink { completion in         switch completion {         case .failure(_): print("failed")         case .finished: print("finished")         }     } receiveValue:  { print("\($0)") } My specific situation is I'm monitoring for when the network becomes available the first time. Of course the monitoring source will never (should never) finish but I do want completion for a pipeline subscribing to that monitor with first.
Posted Last updated
.
Post not yet marked as solved
1 Replies
515 Views
Is there a way to view the contents of an app's NSUbiquitousKeyValueStore? I was expecting to find a property or method that listed the keys, or maybe a web app like the CloudKit Dashboard.
Posted Last updated
.
Post not yet marked as solved
0 Replies
608 Views
My app deal with a lot of domain-specific jargon. Is there a way to augment the vocabulary used in a SwiftUI TextField (or a UITextInput) so that autocorrection and spelling anticipation will suggest the jargon words first? Augmentation of dictation support isn't necessary but would be a nice to have.
Posted Last updated
.
Post marked as solved
1 Replies
693 Views
I want my app to receive certain data types shared from other apps. I'm interested in text and URLs today, and maybe images later. UIActivity seems to be the way to start but I don't know what to do with the subclass I've created. I assume it at least needs to be declared in the app's properties, but I don't know where to read about that and nothing stands out in the project editor. I don't know the API or keywords to do my research, so if anyone can point me I'll appreciate it.
Posted Last updated
.
Post not yet marked as solved
0 Replies
345 Views
I'm curious if anyone has a way to remove or move the fixed buttons on the Xcode 12 Touch Bar? It's 2021 and 3 years ago this was the answer to a similar question. It doesn't discuss the fixed buttons for Run/Stop/Back/Next: https://developer.apple.com/forums/thread/80896?login=true I am forever hitting the Run button by accident and want to remove it or at least shove it over so no buttons are just right of the escape key on my MBP 2019.
Posted Last updated
.
Post marked as solved
2 Replies
649 Views
I made a subclass of UICollectionViewCell and Swift is complaining that I'm not allowed to use superclass properties like bounds, backgroundView or selectedBackgroundView. This very code was given by Appleʼs documentation - https://developer.apple.com/documentation/uikit/uicollectionviewdelegate/changing_the_appearance_of_selected_and_highlighted_cells so I don't understand why it's disallowed. I declared class MyCollectionViewCell: UICollectionViewCell method awakeFromNib. class MyCollectionViewCell: UICollectionViewCell { ... override class func awakeFromNib() { ... let redView = UIView(frame: bounds) redView.backgroundColor =  colorLiteral(red: 1, green: 0, blue: 0, alpha: 1) self.backgroundView = redView let blueView = UIView(frame: bounds) blueView.backgroundColor =  colorLiteral(red: 0, green: 0, blue: 1, alpha: 1) self.selectedBackgroundView = blueView Xcode 12.2 gives an error about bounds, backgroundView, and selectedBackgroundView saying stuff like "Instance member 'bounds' cannot be used on type 'MyCollectionViewCell'". If I declare a variable as UICollectionViewCell I can set these properties in it, but a function in a subclass of UICollectionViewCell cannot access its own properties?
Posted Last updated
.
Post marked as solved
2 Replies
1.1k Views
I read the vague guidance in the HIG (https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/custom-icons/) on making a "glyph". I've tried Pixelmator, Graphic, and Sketch to make all grayscale on transparent PNGs, SVGs, and PDFs. I still cannot make an asset that is tintable when I use it in a TabView tabItem Image. If I use an SF Symbols image (systemName) then I get a tintable icon. The technical guidance in the HIG is too vague. What is "monochomatic" here? 1-bit color? Grayscale? "Uses a mask to define its shape" is also vague. Do they mean an alpha channel? An alpha mask? I don't have Photoshop or Illustrator, so if someone can give me some clear technical guidance relevant to one of the tools I do have that'd be appreciated.
Posted Last updated
.