• Mac OS X,  Mac Security,  Swift

    Interact With Shortcuts Via Scripts

    The /usr/bin/shortcuts command can be used to run, well, shortcuts. Shortcuts are small scripts that are interpreted by the Shortcuts app. They can run shell scripts, JavaScripts, and even SSH into other hosts to fire off more complex automations. These can be fairly complex automations programmatically by importing shortcuts from the Gallery of those Apple provides. This allows for what might not even be a possible atomic operation to run and daisy chain scripts to provide input or output to shortcuts. The scripting might be considered dangerous and so is disabled by default. To enable scripts to be run from a shortcut, open the Shortcuts app and select Settings from…

  • Swift

    Use The Shazam Binary To Capture Signatures Of Audio Tracks In Batches

    One of my favorite moments at Apple’s WWDC was when I got to see the developers of Shazam show off their new creation. A few years later, in 2017, Apple acquired Shazam. In the few years since, they have released ShazamKit, an API that Apple documented at https://developer.apple.com/documentation/shazamkit. ShazamKit allows independent developers to harness the abilities of Shazam to create their own audio pattern-matching services. One small part of Shazam is important in that it’s the input the powerful signature analysis capabilities of the platform. This is fed by .shazamsignature files that can be captured and then compared to other signatures. The APIs are integral to developing apps that can…

  • Mac OS X,  Mac Security,  Swift

    Removing Extensions Cruft from macOS

    Extensions have gotten a pretty substantial overhaul over the past few years. Traditionally, a kernel extension (or kext for short) would usually be located in /Library/Extensions or /System/Library/Extensions and have a file extension (no pun intended) of .kext. Apple began to move away from Kernel Extensions and towards more purpose-built extensions, which included System Extensions, located at /Library/SystemExtensions. Apple also introduced a number of new extension types that reside in application bundles. An app can load the extension and developers get those features “for free” rather than writing their own code to do what they once had to do with Kernel Extensions. To remove Extensions, Apple has introduced the Extensions…

  • cloud,  Mac Security,  Swift

    Configure Amazon SNS for Mac and iOS APNs Development

    Amazon SNS makes implementing Apple Push Notifications (APNs) a breeze. This might seem like a longer article but it’s really not as many steps as it seems (although buttons on web pages move around a lot so ymmv for specific words in button names). There’s a few main steps that we’ll go through: creating a cert in Keychain, generating a Push Notifications cert with the appropriate bundle ID and team ID, and adding an application instance. Notice that these are different for Mac and iOS so if doing both use iOS and if doing one for each, use the appropriate entry. Create a Cert in Keychain First, we’ll create a…

  • Swift

    Run A Script (eg build/test automation) From Xcode

    We’ve all been there. Write some code. Commit. Edit some code. Commit. Run the build automation. I had a little script I ran – so open terminal and run. Now there’s an easy button. Commit, use a keystroke to invoke the script without leaving Xcode. To set it up, open Xcode and click on Behaviors under the Xcode menu. Under there, click Edit Behaviors… Click the plus sign in the lower left corner of the screen and then in the list of options, scroll all the way down to the Run option Click Show Script… Select the preferred script and click OK You can also assign a keystroke – so…

  • Swift

    Apple Design Resources

    One of my favorite things about swiftui is how easy it is to pull in clean and beautiful iconography. I’m happy to go screw it up by crowding interfaces and building crap UI. Apple can’t make me a good designer. But they can arm me with plenty of tools to get there. One of the most impactful for me is the SF Symbols font, which can be downloaded at https://developer.apple.com/sf-symbols/. There are others to manipulate svg files and other formats, but the beauty of SF Symbols is that it’s simple to change size, color, placement, and even multiple colors concurrently (some fonts are multi-colored). For example, let’s say I want…

  • Swift

    Developer Mode System Extensions on macOS

    System and Network Extensions are fairly easy programmatically. However, there is some nuance around building them. Much of this is in getting the correct entitlements – but also a little in troubleshooting. To see (or set) those entitlements, look at the .entitlements file located in the root of an Xcode Project. That will be a plist with a few entries. In this one, we’ll see com.apple.developer.networking.networkextension so we’re working on a network extension. com.apple.security.app-sandbox com.apple.security.application-groups $(TeamIdentifierPrefix)com.krypted.firewall com.apple.developer.networking.networkextension content-filter-provider To add one, go to the General screen for the project, and locate the section for Frameworks, Libraries, and Embedded Content. Then use the plus sign to add and provide the name…

  • Swift

    Getting More Logs From Xcode

    Xcode has a number of logging features I’ve found help me figure out why various things are failing over the years. It’s usually (and by usually I mean always) due to something stupid I did, but the logs help me figure out what’s going on pretty quickly. So first up, let’s look at enabling the activity logs. To do this, we’ll send an EnableDebugActivityLogs Boolean variable into com.apple.dt.XCBuild.plist: defaults write com.apple.dt.XCBuild EnableDebugActivityLogs -bool YES Now let’s turn on the build debugging mode. Now, for the above command you can leave it on without a performance hit, but this one should be turned on and off as you’re going as you’ll…

  • Swift

    Use Carthage For Build Automation In Cocoa Apps

    Note: these are just my notes to get started with Carthage and by no means a definitive resource of information. Carthage is a tool that automates build dependencies for Cocoa apps and provides binary frameworks without modifying out-of-band project files. If you’re using homebrew, installing carthage is a one-liner: Once installed, build a Cartfile in the home directory of xcode projects. The cartfile will list required projects, by version, as you can see here, which lists AlamoFire: brew install carthage Once Carthage is installed, you’ll need a cartfile for each project, to map the dependencies. This gives you the chance to resolve those when you’re building new software. Each time you add something new, simply put the dependency in there, taking into account when you want to use…