Post

Replies

Boosts

Views

Activity

App compiles but "Unable to install" on device
When I try to run my app on my iPhone, from Xcode, I get a popup that says Unable to Install "AppName". There is some text in the popup. Here's the first part of it. (I replaced the real app's name with "AppName".) Anyone know how to fix this? Unable to install "AppName" Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402653103 User Info: { DVTErrorCreationDateKey = "2024-09-28 04:04:29 +0000"; IDERunOperationFailingWorker = IDEInstalliPhoneLauncher; } -- Unable to install "AppName" Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402653103 -- Could not inspect the application package. Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402653103 User Info: { DVTRadarComponentKey = 282703; MobileDeviceErrorCode = "(0xE8000051)"; "com.apple.dtdevicekit.stacktrace" = ( ...
1
0
187
Sep ’24
simctl launch --console flag doesn't seem to work?
I created a simple app in Xcode. Installed and ran it in the iOS Simulator. I can also start it from command line like this: % xcrun simctl launch booted com.example.TestBuildCommands --console com.example.TestBuildCommands: 52877 % It just prints that one line and returns my shell prompt. But the help for launch says that --console should: "Block and print the application's stdout and stderr to the current terminal." In my main() function I have: int main(int argc, char * argv[]) { printf("In main.\n"); ... Shouldn't I be seeing that message in my terminal screen? % xcrun simctl help launch Launch an application by identifier on a device. Usage: simctl launch [-w | --wait-for-debugger] [--console|--console-pty] [--stdout=<path>] [--stderr=<path>] [--terminate-running-process] <device> <app bundle identifier> [<argv 1> <argv 2> ... <argv n>] --console Block and print the application's stdout and stderr to the current terminal. Signals received by simctl are passed through to the application. (Cannot be combined with --stdout or --stderr) [...] ps. Anyone know how to turn off syntax highlighting in those triple-backquoted code blocks that are meant to be just terminal text, not highlighted code?
1
1
910
Apr ’23
Getting container files when app not in "Installed App" list in Devices and Simulators window?
I need to get at the files of an app (one that I developed). It's sitting there on the home screen of my iPad, and I can run it. But in the "Devices and Simulators" window in Xcode, in the "Installed Apps" list, it's not there. That list is how I would normally get the "container" so I can see the files. Why would an app that is obviously on the device not be in the list? Is there another way to get the container/files?
0
0
553
Mar ’23
For cursor update events (with NSTrackingArea) how to know if it's coming or going?
I've added an NSTrackingArea to my NSView because I want a certain rectangular area to show a different cursor. As expected, my view gets a call to it's cursorUpdate:(NSEvent*) method, but how do I tell whether it's an "enter" or "leave". - (void)cursorUpdate:(NSEvent *)event { // Do I push or pop my custom NSCursor? } I notice the event.modifierFlags changes from 8 to 9. But I don't see any public enum constants to test that, so I don't know if I can depend on that. The public enum contains stuff like this, in the higher bits. typedef NS_OPTIONS(NSUInteger, NSEventModifierFlags) { NSEventModifierFlagCapsLock = 1 << 16, NSEventModifierFlagShift = 1 << 17, ... The tracking area setup code: NSRect nsRect = ... NSTrackingAreaOptions options = NSTrackingCursorUpdate | NSTrackingActiveInKeyWindow; NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect: nsRect options: options owner: owner userInfo: userInfo]; [myView addTrackingArea: trackingArea];
1
0
1.3k
Oct ’22
How to validate NLLanguage values for NLLanguageRecognizer?
I expected the initializer NLLanguage(rawValue: "...") to return nil if I gave it junk, but it doesn't. It accepts any string. I'm loading values from a database so I'd like to know if I'm getting one that is valid, like "en", "es", etc., as opposed to an error. Is there anyway to check that? I'm using it to set NLLanguageRecognizer.languageConstraints, so I guess by "valid" I mean all the languages that work with that property. The struct has a bunch of static constants: struct NLLanguage { static let english = ... static let spanish = ... ... } If those all work with NLLanguageRecognizer I guess I can paste them all into a dictionary.
0
0
1.1k
Jul ’22
SwiftUI, macOS, how to hook up to Edit menu's commands?
In SwiftUI on macOS, you can add items to the main menu by using things like CommandGroup, CommandMenu. But the default menus already have items. For example, the Edit menu has Undo, Redo, Cut, Copy, Paste, Delete, Select All. Those menu items are grayed out and don't do anything. Is there a way to hook some Swift code to these? Or do you just use CommandGroup(replacing: ...) to replace them? That doesn't seem right; why put them there if you just have to replace them? Besides hooking up a function to run when they get clicked, I'd like to know how to enable and disable them depending on app state.         WindowGroup {             MyContentView()         }.commands {             SidebarCommands()             CommandGroup(after: .newItem) {                 Button { newFolder() } label: { Text("New Folder") }                     .keyboardShortcut("n", modifiers: [.command, .option])             }         }
1
0
1.9k
Jun ’22
UIScrollView does not give touches to subview if drag starts quickly
I have a UIScrollView, and its subview inside needs to respond to some touchesMoved events without scrolling. I've got it mostly working, but with one sticking point that confuses the user: if I touch and quickly move my finger, then the UIScrollView takes the gesture as a scroll, and never calls the touchesBegan, touchesMoved, etc., of its subview. However, if I touch, then pause for a bit, then drag, then things work as intended: the subview gets touchesBegan, touchesMoved, etc., and things are handled without any scrolling. On my UIScrollView, I've set: delaysContentTouches = false canCancelContentTouches = true And I've overrode touchesShouldCancel(in view: UIView). But that does not get called in the case when I quickly drag my finger. Is there something else I need to do?
1
0
1.4k
Feb ’22
NSStackView edgeInsets top vs bottom bug?
Hard to believe something this old doesn't work, but it appears so. I set the top to 10 and the bottom to 0, but it uses 10 for both. Am I doing something wrong, or is it a bug? sv.edgeInsets = .init(top: 10, left: 10, bottom: 0, right: 0) Screenshot: Full code example below. (This is the ViewController.swift file after creating a new Xcode project with "Interface" of "Storyboard". No other changes to the project template.) class ViewController: NSViewController {     override func viewDidLoad() {         super.viewDidLoad()         let sv = NSStackView()         sv.translatesAutoresizingMaskIntoConstraints = false         let v1 = ColoredBlock(.red, width: 20)         let v2 = ColoredBlock(.green, width: 20)         let v3 = ColoredBlock(.blue)         sv.addArrangedSubview(v1)         sv.addArrangedSubview(v2)         sv.addArrangedSubview(v3)         sv.spacing = 0         sv.edgeInsets = .init(top: 10, left: 10, bottom: 0, right: 0)         // sv.setContentHuggingPriority(.required, for: .vertical)         view.addSubview(sv)         pinToFourEdges(view, sv)     } } class ColoredBlock: NSView {     let intrinsicHeight: CGFloat     let intrinsicWidth: CGFloat     init(_ color: NSColor, width: CGFloat = NSView.noIntrinsicMetric, height: CGFloat = NSView.noIntrinsicMetric) {         intrinsicWidth = width         intrinsicHeight = height         super.init(frame: .zero)         self.wantsLayer = true         if let layer = self.layer {             layer.backgroundColor = color.cgColor         }     }     required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }     override var intrinsicContentSize: NSSize {         return NSSize(width: intrinsicWidth, height: intrinsicHeight)     } } public func pinToFourEdges(_ view1: NSView, _ view2: NSView) {     view1.topAnchor.constraint(equalTo: view2.topAnchor).isActive = true     view1.bottomAnchor.constraint(equalTo: view2.bottomAnchor).isActive = true     view1.leftAnchor.constraint(equalTo: view2.leftAnchor).isActive = true     view1.rightAnchor.constraint(equalTo: view2.rightAnchor).isActive = true }
0
0
497
Feb ’22
Combining chars do not render right in some fonts
Here's a simple demo. I run it on macOS 12.1, compiled with Xcode 13.2. struct ContentView: View {     var body: some View {         VStack {             Text("ee")             Text("eé") Text("e\u{E9}") // "e with acute"             Text("ee\u{301}") // "combining acute"         }.font(.custom("Avenir", fixedSize: 18))          .padding(20)     } } In the 4rd one, the "e" is rendered in the wrong size/font. Screenshot: Other fonts do not have the problem. For example, "Avenir Next" and "Helvetica". Is there a way (in code) to tell which fonts can handle combining chars? Is this a bug? I notice the same thing happens when I use Core Text to draw the strings at a low level. So it's not just SwiftUI. In TextEdit, if have Avenir font, type "option-e" + "e" I get a nice letter. Maybe TextEdit is doing what Xcode did in the second line, and using the "e with acute" unicode character.
2
0
661
Jan ’22
Xcode build error about "cycle" that doesn't exist?
My project builds after a clean, but then fails to build. I can't understand these error messages. I have a macOS app target ("MyArchives") and a library target ("HelpPG") in the project. The app uses the library. Logically, there is no cycle. The library is an attempt to wrap PostgreSQL's libpq with some Swift stuff. It works when it runs after the clean build. I don't know what it's talking about with "headers before sources". That is already the case for the library target. There are no headers in the app target (which is all Swift). For readability, strings were substituted: [DEBUG] = /Users/me/Library/Developer/Xcode/DerivedData/MyArchives-flyvnqgqeolefjeztyopfnoaqmaj/Build/Products/Debug [UUID1] = bb030422ec80ba11076c24bcbd7fcd674d61e6313e2915ec58f3544977cb99a4 [UUID2] = bb030422ec80ba11076c24bcbd7fcd67db6f662ae7c65be0e231d735b4905dc3 Showing All Messages Cycle in dependencies between targets 'MyArchives' and 'HelpPG'; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources. Cycle path: MyArchives → HelpPG → MyArchives Cycle details: → Target 'MyArchives' has copy command from '[DEBUG]/libHelpPG.dylib' to '[DEBUG]/MyArchives.app/Contents/Frameworks/libHelpPG.dylib' → Target 'HelpPG' has link command with output '[DEBUG]/libHelpPG.dylib' ○ Target 'HelpPG' has copy command from '/usr/local/pgsql/lib/libpq.5.13.dylib' to '[DEBUG]/libpq.5.13.dylib' ○ Target 'HelpPG' has link command with output '[DEBUG]/libHelpPG.dylib' Raw dependency cycle trace: target: -> node: <all> -> command: <all> -> node: [DEBUG]/MyArchives.app/Contents/Frameworks/libHelpPG.dylib -> command: target-MyArchives-[UUID1]-:Debug:PBXCp [DEBUG]/libHelpPG.dylib [DEBUG]/MyArchives.app/Contents/Frameworks/libHelpPG.dylib -> node: [DEBUG]/libHelpPG.dylib/ -> directoryTreeSignature: ~ -> directoryContents: [DEBUG]/libHelpPG.dylib -> node: [DEBUG]/libHelpPG.dylib -> CYCLE POINT -> command: target-HelpPG-[UUID2]-:Debug:Ld [DEBUG]/libHelpPG.dylib normal -> node: [DEBUG]/libpq.5.13.dylib -> command: target-HelpPG-[UUID2]-:Debug:PBXCp /usr/local/pgsql/lib/libpq.5.13.dylib [DEBUG]/libpq.5.13.dylib -> node: <target-HelpPG-[UUID2]--phase1-compile-sources> -> command: Gate target-HelpPG-[UUID2]--phase1-compile-sources -> node: <Linked Binary [DEBUG]/libHelpPG.dylib> -> command: target-HelpPG-[UUID2]-:Debug:Ld [DEBUG]/libHelpPG.dylib normal
1
0
2.6k
Jan ’22