Page 3 of 5

Creating a Launch Agent that provides an XPC service on macOS using Swift Oct 21 2019

Last week we discussed how to build XPC Services(the .xpc bundles) inside your macOS applications. This week we are going to explore how to provide XPC services that can be used from other applications or tools.

To make the XPC service available to other processes, we are going to create a launch agent. So let’s start by understanding how Launch Agents work.

* You can find the code for the Launch Agent in this GitHub repository

Read More...

Newsletter #5 - XPC Services on macOS apps using Swift Oct 18 2019

Hello,

The weekend is here, so before we go get some rest here is this week’s newsletter.

Did you see that Ken Thompson’s BSD Password was finally cracked? If you don’t know who he is, he was one of the creators of the UNIX operating system. Someone found an old(39 years old) /etc/passwd file containing some users and password from the source tree of BSD version 3. And they finally cracked the last password. The article is a fun read. I think you might enjoy it.

Read More...

XPC Services on macOS apps using Swift Oct 17 2019

We have access to many Inter-Process-Communication(IPC) mechanisms in macOS. One of the newest is XPC1. Before XPC a common way to use IPC, and provide services between processes, was through Sockets or Mach Messages (Using Mach Ports).

Nowadays, we are encouraged by Apple to use XPC in our applications and frameworks that provide services. Also, Apple, in their code, has updated many of its frameworks, daemons and applications to use XPC.

Read More...

Newsletter #4 Using Kernel Queues notifications in Swift Oct 11 2019

Hello,

New OS version this week! I hope you had an easy upgrade to macOS(10.15) Catalina. I’m glad that everything went smoothly on my laptop. A couple of friends reported that their installation got stuck at the “Setting Up Your Mac” screen. The solution was to force restart and after everything completed as expected.

It’s crazy how far we’ve come. Many people complained about the upgrade being buggy, but I think upgrading now is smooth. I remember having to recompile everything after a kernel update on my Linux box, that’s when things got interesting. Different times.

Read More...

Using Kernel Queues (kqueue) notifications in Swift Oct 9 2019

Many components of macOS trace their roots back to BSD. One key aspect inherited from BSD is the Kernel Event Notification mechanism know as Kernel Queues (kqueues for short).

In the past, before kqueue(2)1/ kevent(2)2, when we wanted to track events related to a socket, or if a file descriptor changed, we used a polling mechanism to test for readiness/events (maybe using select(2) or poll(2)). This polling techniques were inefficient and got replaced by the more efficient kqueue API. Instead of continually polling, we can now be notified about events by the kernel. Also, mechanisms like select(2) and poll(2) were restricted to work with file descriptors. kqueue increases the range of operating systems events to monitor not only for file descriptors but also elements like signals, timers, network devices, etc.

Read More...

Newsletter #3 - Understanding the RunLoop model Oct 4 2019

Hello,

This week I spent some time away from the computer relaxing and visiting San Francisco. Had such a good time with friends I haven’t seen in a long time.

This week’s post was about understanding the RunLoop. We used a basic shell implementation to show how to use different input sources on our RunLoop. There are not many examples on how to do this, and I feel that the RunLoop is central to the macOS architecture, and understanding it helps us design better applications.

Read More...

Understanding the RunLoop model by creating a basic shell Oct 1 2019

When we find ourselves listening for events, reacting to those events, and then going back to listening for more events, we have ourselves an Event-Loop. Having an event-loop is a common scenario. So common that Apple decided to provide us with a model to handle event-loops consistently. In this post, we are going to explore how RunLoops work and use them to build basic shell.

Let’s get started by creating a program that makes use of an event-loop.

Read More...

Newsletter #2 - Using BSD Sockets in Swift Sep 27 2019

This week was fun. It was the first time I got an award for one of my posts on Reddit. It’s always fun to receive messages from people that find my posts useful.

You can see the post with the little badges on top :) here:
https://www.reddit.com/r/swift/comments/d915ja/using_bsd_sockets_in_swift/

I usually share my posts on Reddit. I find it less cluttered with random posts (unless you subscribe to random subreddits). I don’t use Twitter much, but I think I’ll start using it as Seth Godin uses Twitter, mostly a feed for the blog. I want to share more content but spending time on Twitter takes time from researching and writing. So I’ll probably won’t pay much attention to it. Anyways, let me know if you have any thoughts on using Twitter.

Read More...

Using BSD Sockets in Swift Sep 24 2019

Apple provides many useful network frameworks. Network.framework (you can check my previous article on Network.framework if you want to see an example) is the latest. But sometimes we need to go deeper, and the abstractions might get in the way. In this post, we are going to see how to use BSD sockets directly in Swift.

Using BSD sockets means interfacing with C from Swift. Let’s first have a look at some concepts and tips that will help us with using sockets.

Read More...

Newsletter #1 - Objective-C and Swift Interoperability and Mach-O executables Sep 20 2019

Hello,

Another week has gone by trying to figure out how computers work under the hood, and also enjoying dark mode on iOS. I hope you are enjoying the update too. Everything went smooth on the update, the only problem I had was with my reminders.

I make heavy use of reminders, both on my phone and on my laptop. So you can imagine, I was all excited tapping yes to every new popup on my phone. And I didn’t pay attention to the warning for Reminders. If you update to the new reminders, you won’t be able to see them in macOS until you upgrade to Catalina. My advice, make sure you won’t be needing your reminders on macOS before tapping “upgrade”.

Read More...

$