Post

Replies

Boosts

Views

Activity

How to fix "contains disallowed nested bundles" and "contains disallowed file 'Frameworks'" errors
Hi,My iOS Swift app contains a in-house built framework (A), which is also using Swift. This framework includes 2 in-house built frameworks (B and C) using Objective-C."Embedded Content Contains Swift Code" is set to YES for the app and to NO for the A, B and C frameworks.When I try to submit the app to iTC, I get these errors:ERROR ITMS-90205: "Invalid Bundle. The bundle at 'yourapp.app/Frameworks/A.framework' contains disallowed nested bundles."...ERROR ITMS-90206: "Invalid Bundle. The bundle at 'yourapp.app/Frameworks/A.framework' contains disallowed file 'Frameworks'."...How can I fix those?
9
0
40k
Sep ’15
Expired certificates now prevents apps from launching?
So my app had its distribution certificate expired today. Usually, apps that were signed while the certificate was still valid should be unaffected and keep running. To my knowledge, this has been the case for years. You'd just then create a new certificate next time you wanted to push an update.However, and I'm not sure if this is a new restriction in macOS 10.15, but now my app will refuse to launch! You can imagine the support nightmare that will be."You should've pushed an update with a new certificate already!" you might say? Well what happens if some of your users don't run you app very often and they miss the update? Well they´re stuck with an app that no longer launches and have to redownload the updated app entirely instead of getting it via in-app updates.I don't know if this is a bug on Apple's end or this is now by design. If so, well this socks as this not only hurt developers that distribute their apps outside the MAS but users as well that rely on those apps and may find themselves unable to use the apps they need to get their work done until they figure out how to fix the problem or contact the developer for a solution.Anyone else had this issue?
8
0
7.4k
Apr ’20
How to reset child view state variable
I'm sure it's something very silly but how should one reset the state value of a child view when another state has changed?For example, the code below shows 2 folders, which respectively have 2 and 3 items., which can be edited.If you select the second folder (Work) and its 3rd item (Peter) and then select the first folder (Home), the app crashes since `selectedItemIndex` is out of bounds.I tried to "reset" the state value when the view gets initialized but it seems like changing the state like such triggers out a "runtime: SwiftUI: Modifying state during view update, this will cause undefined behavior." warning.init(items: Binding<[Item]>) { self._items = items self._selectedItemIndex = State(wrappedValue: 0) }What is the proper way to do this? Thanks!Here's the code:AppDelegate.swiftimport Cocoa import SwiftUI @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { var window: NSWindow! func applicationDidFinishLaunching(_ aNotification: Notification) { // Create the SwiftUI view that provides the window contents. let store = ItemStore() let contentView = ContentView(store: store) // Create the window and set the content view. window = NSWindow( contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false) window.center() window.setFrameAutosaveName("Main Window") window.contentView = NSHostingView(rootView: contentView) window.makeKeyAndOrderFront(nil) } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } }ContentView.swiftimport SwiftUI final class ItemStore: ObservableObject { @Published var data: [Folder] = [Folder(name: "Home", items: [Item(name: "Mark"), Item(name: "Vincent")]), Folder(name: "Work", items:[Item(name: "Joseph"), Item(name: "Phil"), Item(name: "Peter")])] } struct Folder: Identifiable { var id = UUID() var name: String var items: [Item] } struct Item: Identifiable { static func == (lhs: Item, rhs: Item) -> Bool { return true } var id = UUID() var name: String var content = Date().description init(name: String) { self.name = name } } struct ContentView: View { @ObservedObject var store: ItemStore @State var selectedFolderIndex: Int? var body: some View { HSplitView { // FOLDERS List(selection: $selectedFolderIndex) { Section(header: Text("Groups")) { ForEach(store.data.indexed(), id: \.1.id) { index, folder in Text(folder.name).tag(index) } }.collapsible(false) } .listStyle(SidebarListStyle()) // ITEMS if selectedFolderIndex != nil { ItemsView(items: $store.data[selectedFolderIndex!].items) } } .frame(minWidth: 800, maxWidth: .infinity, maxHeight: .infinity) } } struct ItemsView: View { @Binding var items: [Item] @State var selectedItemIndex: Int? var body: some View { HSplitView { List(selection: $selectedItemIndex) { ForEach(items.indexed(), id: \.1.id) { index, item in Text(item.name).tag(index) } } .frame(width: 300) if selectedItemIndex != nil { DetailView(item: $items[selectedItemIndex!]) .padding() .frame(minWidth: 200, maxHeight: .infinity) } } } } struct DetailView: View { @Binding var item: Item var body: some View { VStack { TextField("", text: $item.name) } } } struct IndexedCollection<Base: RandomAccessCollection>: RandomAccessCollection { typealias Index = Base.Index typealias Element = (index: Index, element: Base.Element) let base: Base var startIndex: Index { base.startIndex } var endIndex: Index { base.endIndex } func index(after i: Index) -> Index { base.index(after: i) } func index(before i: Index) -> Index { base.index(before: i) } func index(_ i: Index, offsetBy distance: Int) -> Index { base.index(i, offsetBy: distance) } subscript(position: Index) -> Element { (index: position, element: base[position]) } } extension RandomAccessCollection { func indexed() -> IndexedCollection<Self> { IndexedCollection(base: self) } }
1
0
3.1k
Apr ’20
Generic parameter 'SelectionValue' could not be inferred
Hi! What is wrong with this code and why does this work for a Picker but not a List? struct ContentView: View {     enum FooBar: CaseIterable, Identifiable {         public var id : String { UUID().uuidString }                 case foo         case bar         case buzz         case bizz     }     @State var selectedFooBar: FooBar = .bar     var body: some View {         VStack {             Picker("Select", selection: $selectedFooBar) {                 ForEach(FooBar.allCases) { item in                     Text(self.string(from: item)).tag(item)                 }             }                         List(FooBar.allCases, selection: $selectedFooBar) { item in                 Text(self.string(from: item)).tag(item)             }                         Text("You selected: \(self.string(from: selectedFooBar))")         }     }     private func string(from item: FooBar) -> String {         var str = ""                  switch item {         case .foo:             str = "Foo"                      case .bar:             str = "Bar"                      case .buzz:             str = "Buzz"                      case .bizz:             str = "Bizz"         }         return str     } }
3
0
3.2k
Jul ’20
onDrag conflicts with clicks on macOS
I have a list of navigation links that I want to be draggable. However, it seems like onDrag conflicts with mouse clicks on macOS (iOS is fine). Here's some sample code: swift import SwiftUI struct ContentView: View { var items = ["Peter", "Mark", "Joe", "Frank", "Tim"] @State var selected: String? var body: some View { NavigationView { List { ForEach(items, id: \.self) { item in NavigationLink(destination: Text(item), tag: item, selection: $selected, label: { Text(item) .onDrag { () - NSItemProvider in return NSItemProvider(object: String(item) as NSString) } }) } } Text("") } } } Here's the weird part: if you click on the text, the item doesn't get selected and the link seems disabled. However, if you click on a section of the item that is empty, then it works! Again, this works just fine on iOS. Is this a SwiftUI bug/limitation or am I doing it wrong? Thanks!
1
2
1.3k
May ’21
Drag via pasteboard changed on Monterey?
This code works fine on macOS 11: var body: some View {         VStack {             ActionControl()                 .padding()                 .onDrag { () -> NSItemProvider in                     let value = Action(string: "hello, world").string                     let p = ActionProfile(value: value)                     return NSItemProvider(item: p, typeIdentifier: ActionProfile.pasteboardType)                 }                          MyTextView()                 .padding()         }     } class ActionProfile: NSObject, NSCoding, NSSecureCoding { static var supportsSecureCoding: Bool = true static var pasteboardType = "com.my.app.action.profile" @objc var rawValue: String func encode(with aCoder: NSCoder) { aCoder.encode(rawValue, forKey: "value") } required init(value: String) { self.rawValue = value } required init?(coder aDecoder: NSCoder) { self.rawValue = aDecoder.decodeObject(of: NSString.self, forKey: "value")! as String } required init?(pasteboardPropertyList propertyList: Any, ofType type: NSPasteboard.PasteboardType) { return nil } } extension ActionProfile: NSPasteboardWriting, NSPasteboardReading { static var nsPasteboardType: NSPasteboard.PasteboardType = .init(pasteboardType) static func readingOptions(forType type: NSPasteboard.PasteboardType, pasteboard: NSPasteboard) -> NSPasteboard.ReadingOptions { return .asKeyedArchive } func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] { return [ActionProfile.nsPasteboardType] } func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? { if type == ActionProfile.nsPasteboardType { return try! NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: false) } return nil } static func readableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] { return [ActionProfile.nsPasteboardType] } } extension MyTextViewControl { override internal var writablePasteboardTypes: [NSPasteboard.PasteboardType] { return [ActionProfile.nsPasteboardType] + super.writablePasteboardTypes } override func prepareForDragOperation(_ sender: NSDraggingInfo) -> Bool { return true } override func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation { let location = self.characterIndexForInsertion(at: self.convert(sender.draggingLocation, from: nil)) self.setSelectedRange(NSRange(location: location, length: 0)) return sender.draggingSource is MyTextViewControl ? .move : .copy } override func performDragOperation(_ sender: NSDraggingInfo) -> Bool { let pboard = sender.draggingPasteboard if pboard.availableType(from: [ActionProfile.nsPasteboardType]) == ActionProfile.nsPasteboardType { if let profiles = pboard.readObjects(forClasses: [ActionProfile.self], options: nil) as? [ActionProfile], !profiles.isEmpty { let alert = NSAlert() alert.messageText = "WORKS" alert.runModal() return true } else { let alert = NSAlert() alert.messageText = "FAILED" alert.runModal() return super.performDragOperation(sender) } } return super.performDragOperation(sender) } } On macOS 12 beta, when calling pboard.readObjects(...) I get this error when trying to drag the item into a NSTextView: Failed to initialize keyed unarchiver for pasteboard data: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?} I've noticed that encode(with aCoder: NSCoder) isn't called at all on macOS 12 but is on macOS 11. Are there any changes in macOS 12 regarding NSCoding or NSSecureCoding or is this just a bug?
2
0
993
Jul ’21
TestFlight for Mac: review required every single time a new build is pushed?
So I've started using TestFlight for Mac but unlike its iOS counterpart, it seems like every single build uploaded and pushed to testers has to be reviewed by Apple. This is not how that works on the iOS side. Ex: MyApp 4.1 build 1 -> Review required for both iOS and Mac MyApp 4.1 build 2 -> Review required for Mac, not iOS Is this a bug or by design? If so, this is crazy!
0
0
612
Nov ’21
ShareLink and DataRepresentation
In my app, I'd like to be able to share a .csv file via ShareLink and Transferable. I watched the "Meet Transferable" WWDC22 video and it should be possible as the presenter demonstrated that use case. However, when I try this on my end, I am able to share the content but somehow it is treated by iOS as plaintext and when sharing by email or messages, it will just add the text content to the body. If I try to share via AirDrop, it creates a random filename with the .txt extension even though I specify .commaSeparatedText. The only way this somewhat works is when saving to files. It will save as a .csv file but the filename is set to "comma-separated values". Here's some code: struct MyArchive {     enum ValidationError: Error {         case invalid     }     var filename: String { return "myarchive.csv"     }          init(csvData: Data) throws {         //...     }     func convertToCSV() throws -> Data {         let test = "Name,Email\nPete,pete@example.com"         if let data = test.data(using: .utf8) {             return data         }         else {             throw ValidationError.invalid         }     }  } extension MyArchive: Transferable {     static var transferRepresentation: some TransferRepresentation {         DataRepresentation(contentType: .commaSeparatedText) { archive in             try archive.convertToCSV()         } importing: { data in             try MyArchive(csvData: data)         }     } } And in my View: struct View: View { var body: some View { //... let csv = MyArchive() ShareLink( item: csv, preview: SharePreview(                         csv.filename,                         image: Image(systemName: "doc.plaintext")                     ) ) } } I'm at the point that I wonder if I'm doing something wrong or this just doesn't work in iOS 16 beta 1. Any hints? Thanks!
5
0
3.6k
Jun ’22