Piping stdout and stderr to Preview
Erica Sadun
by erica
2y ago
A while back, I wrote about how handy it was to redirect a man page into Preview. This allows you to keep the man page open, search it, and generally have a better user experience than struggling with more (or less) to navigate through the information provided there. man -t apropos | open -fa Preview Recently, someone asked me about more modern command line interaction, specifically, commands that use --help or similar to provide their documentation. Could that information be opened in Preview as well. So I put on my thinking hat and set to work. The first command line utility I decided ..read more
Visit website
Xcode: Vimpocalypse Now
Erica Sadun
by erica
3y ago
This has appeared at the bottom of Xcode’s Text Editing > Editing settings, sure to make many vi users very happy indeeed: The change is heralded in the Release Notes: Using the new vim features is super easy. When the Vim keybindings are enabled, the bottom of your source editor gets this, showing current state, plus a few reminders for those whose muscle memory isn’t quite current. It’s up to you to know your hjkluybn stuff. You can tell if you’re navigating or editing by the shape of the cursor. The cursor is a large block when you’re navigating or using any of the commands ..read more
Visit website
Controlling Screen Sharing from the command line
Erica Sadun
by erica
3y ago
My world often narrows to Xcode and Terminal. There are times I just want to check in on another computer quickly and I don’t want the hassle of creating a new Finder window, going to the network, waiting for the items to load, and clicking Screen Sharing. Let me share a quick osascript solution I use instead. This example connects to Esopus Spitzenburg, my Mojave computer (aka the one that still runs everything including Photoshop and Microsoft Office). #! /bin/sh /usr/bin/osascript -e 'tell application "Screen Sharing" to GetURL "vnc://Esopus-Spitzenburg.local"' If closed, the Screen Shar ..read more
Visit website
Crafting a custom word count service
Erica Sadun
by erica
3y ago
I just happened to need to do a lot of word counts today so I put together a service to make my life easier. While, I performed my initial work on Mojave but the same approach works all the way to Big Sur and, presumably, the upcoming macOS Malibu Barbie. Open Automator To get started, launch automator and create a new document. Select Quick Action, Choose from the new document dialog: Add Scripting Drop in a Run Shell Script and then an Apple Script. You can search from them in the top-left corner. Drag them in order into the right panel. I used /bin/bash for my shell script, shocking, I k ..read more
Visit website
Pasting quoted code perfectly
Erica Sadun
by erica
4y ago
You have some code you need to incorporate into a multi-line string. What’s the quickest and best way to handle it? Although I see people do this all the time, manually adding spaces to each line isn’t the best solution. Here’s a quick Xcode tip: First, paste your material into scope. Retain the indentation by using Edit > Paste and Preserve Formatting. Next, if you haven’t placed them already, add the assignment and triple-quotes above and below the pasted material. Select your material and use Editor > Structure > Shift-Right (Command-]) to line up the left edge of the text with th ..read more
Visit website
Executing command-line directly from Xcode
Erica Sadun
by erica
4y ago
I got pulled into one of those conversations where I end up saying, “Fine, I’ll put up a post about it” and this is the post. Yes, you can test and run command-line apps directly from Xcode but I pretty much never do. It’s a pain with few benefits. That said, here’s how you do it. Arguments Let’s say you need arguments. Open your scheme (⌘<) and select the Run > Arguments tab. Add the arguments you want to pass on launch one at a time. Double-click to edit any argument: The arguments are vended byCommandLine.arguments. Either count the array or use CommandLine.argc to fin ..read more
Visit website
A different way to develop SwiftPM Packages inside Xcode projects
Erica Sadun
by erica
4y ago
WWDC gave us many reasons to both migrate libraries to SwiftPM and to develop new ones to support our work. The integration between Xcode development and SwiftPM dependencies keeps growing stronger and more important. Apple’s Editing a Package Dependency as a Local Package assumes you’ll drag in your package to an Xcode project as a local package overrides one that’s imported through a normal package dependency. In Developing a Swift Package in Tandem with an App, Apple writes, “To develop a Swift package in tandem with an app, you can leverage the behavior whereby a local package ov ..read more
Visit website
The (Switch) Case of the Missing Binding
Erica Sadun
by erica
4y ago
Here’s a cool little challenge brought up this morning by a friend. Consider the following code: switch foo { case .a: return "a" case .b(let str) where str.hasPrefix("c"), .c: return "c" case .b: return "b" } It won’t compile. When you bind a symbol for one pattern, you must bind that symbol for every pattern in a case. This prevents you, for example, from binding str in one pattern and then attempting to use str in the shared case body. For example, consider this case. What would you expect to happen when foo is .c? func switchTheFallthroughOrder(foo: Foo) -> String ..read more
Visit website
Well that was a surprisingly bad Apple Store experience…
Erica Sadun
by erica
4y ago
Remember the battery amnesty? Despite the stores doing everything they could to try to convince me not to replace the batteries, I insisted and persisted. I figured $29 would buy me the start of a new battery life-cycle. Less than 2 years later, my daughter’s iPhone SE battery is dead. Let me try to explain how important her iPhone is to her. She goes everywhere with it: to stores, in the car, at appointments. There is no time when she’s not tapping on it, from morning until she sleeps. It’s one of those neurodiversity things and it is her great comfort. It took us a couple of weeks until ..read more
Visit website
Importing Web-based SwiftPM packages to your Xcode Playground
Erica Sadun
by erica
4y ago
I’ve been kicking the wheels on Xcode 12 and its ability to use frameworks and packages with playgrounds. Up until now, I’ve only been able to import packages that are either downloaded or developed locally on my home system. However, a lot of the packages I want to work with are hosted from GitHub. I decided to follow a hunch and see if I could import my dependency through a local Forwarding package and then use that code. Long story short: I could. Here’s my playground, successfully running. The RuntimeImplementation is declared in a GitHub-hosted package called Swift-General-Utility ..read more
Visit website

Follow Erica Sadun on FeedSpot

Continue with Google
Continue with Apple
OR