Posts

Post not yet marked as solved
5 Replies
1.9k Views
I'm creating a small Swift editor mac app. I want this app to be able to run entered code and then show output. For this reason, I used NSTask and it looks like this: let task = NSTask() task.standardOutput = outPipe task.standardInput = inPipe task.standardError = errPipe task.executableURL = URL(fileURLWithPath: "/usr/bin/swift") task.arguments = [pathToFile] //To run the code I create a temporary Swift file do { try task.run() } catch { //Error handling } //Rest of the code for reading output And this code works... without sandbox. When I turn App Sandbox on, there is an error: xcrun: error: cannot be used within an App Sandbox I made a research and found many people that had the same problem, however often the solution was just not turning App Sandbox, but I need it on because I want to release the app to Mac App Store. I know that this could be achieved using XPC helper, but I'd rather choose at very last. Could someone tell me how this could be achieved?
Posted Last updated
.
Post not yet marked as solved
0 Replies
380 Views
Hi. I have a Swift macOS app in Xcode 12. I have created NSBox subclass to implement drag-and-drop. When I add NSBox in Storyboard and set its class to my custom class, everything works. However, when I try to add this class to NSViewController programatically, like this: let box = EditCard() let button = NSTextField() let text = NSTextView.scrollableTextView()          let frame_box = NSRect(x: 17, y: 118, width: 320, height: 260) let frame_scroll = NSRect(x: 8, y: 10, width: 20, height: 20) let frame_button = NSRect(x: 8, y: 204, width: 300, height: 32) box.borderColor = .black box.cornerRadius = 18 box.fillColor = .black box.frame = frame_box box.titlePosition = .noTitle box.boxType = .custom box.borderWidth = 0.5 button.isEditable = true button.isSelectable = true button.refusesFirstResponder = true button.focusRingType = .none button.frame = frame_button button.isBordered = false button.alignment = .center button.backgroundColor = NSColor(calibratedWhite: 0.0, alpha: 0.0) button.font = .boldSystemFont(ofSize: 23) button.textColor = .textColor text.drawsBackground = false text.frame = frame_scroll (text.contentView.documentView as! NSTextView).font = .systemFont(ofSize: 12) (text.contentView.documentView as! NSTextView).isEditable = true (text.contentView.documentView as! NSTextView).isSelectable = true box.addSubview(button) box.addSubview(text) view.addSubview(box) it doesn't work properly. I can drag this view, but if I try to drop it on another similar view of the same class, none of the DragDestination functions run. Can somebody tell me what I am doing wrong?
Posted Last updated
.
Post marked as solved
5 Replies
1.9k Views
Hi. I have created status bar app. I have added global shortcut using HotKey by Sam Soffes. I want this shortcut to open window from Storyboard. My problem is that I don't know how to open NSWindow from function inside AppDelegate.swift. This project is written in UIKit and Swift using Xcode 12. Thank you in advance for help.
Posted Last updated
.
Post marked as solved
4 Replies
1.9k Views
Hi. I have an app that has a TextField, Label and ComboBox. I want user to be able to write a number in the TextField which will be then formatted and shown in the Label. However when I start writing something in the TextField, I can't change value of ComboBox. Can somebody tell me how can I end editing in TextField? I tried .resignFirstResponder() and .makeFirstResponder() .
Posted Last updated
.