Sam Soffes

Bundle Command Line Tool in macOS App

Posted on

I spend a lot of time in Terminal. There are several things that I’ll reach for in Terminal before something like Spotlight or Alfred. Here’s an example:

The s alias is defined as:

This simply opens the current directory in Sublime Text, my editor of choice. I really love how fast this let’s me get started on something. I first ran into this pattern with TextMate’s mate command. So great.

Continue reading →

Aggressively Hiding the Cursor

Posted on

I’m working on a Mac app that has a color picker in it. Here’s a screenshot:

Loupe

For this to work, I hide the cursor and have a custom view track your mouse movements. (When I say cursor I mean the pointer on screen you control with your mouse, and when I say mouse I mean your physical input device.) I use a full screen, borderless window and NSTrackingArea to do this. Nothing too crazy there. I do this to avoid dealing with custom a NSCursor since that was a lot more work.

Continue reading →

Automating Simple Things

Posted on

Most of my projects contain a Rakefile with some common tasks. rake is Ruby’s tool for running tasks. It’s my tool of choice for little scripts, but you could of course do whatever you want. My friend Ayaka even did a talk on scripting with Swift!

Usually my scripts are for something tedious that can be easily automated. Here’s a few examples in my own projects:

Some of the most elaborate scripts I’ve written in projects have been to automate gathering dependencies. This can be complicated depending on your setup. My goal is always for someone that isn’t a developer to clone, run the command, open Xcode, and build. That may seem like overkill, but if you make it that easy, you make it that easy for yourself and teammates which saves a ton of time.

Continue reading →

Cancel Borderless Window

Posted on

I just spent the last hour trying to figure out why cancelOperation wasn’t getting called in an NSWindowController subclass. At first I tried performKeyEquivalent in the window controller or in a custom NSWindow subclass. That didn’t work. I then resorted to keyDown in the window subclass and that wasn’t getting called.

After a long while, I figured out that my window wasn’t becoming key even after I called makeKeyAndOrderFront. It turns out windows with borderless in the styleMask cannot become key by default. You can solve this with a tiny amount of code in a window subclass:

So ya. Frustrating. This is actually documented, but it took me a really long time to realize the window wasn’t becoming key and then why.

Continue reading →

Share Confirmation

Posted on

Recently, I added some visual confirmation what something was shared with the system share sheet on iOS. For things like copy or save to camera roll, there isn't visual confirmation that it worked from the system.

At first I considered making my own share actions for this and disabling the system ones but that seemed like a lot of work for adding a simple “it worked” to the screen. Then I had this idea:

Pretty simple! This uses SVProgressHUD to show some visual feedback that it worked. This was really easy to add. I think this is a really welcome addition. You could obviously do this for any other type that you want. I didn’t want to do it for every type since some types (like share to Twitter) are really obvious when they work or are canceled.

Continue reading →