Showing projects tagged with “Swift”

Noto

Plain-text editor for macOS written in Swift.

macOS Cocoa Swift

Screenshot of Noto

A plain-text editor for macOS with a focus on a minimalistic user interface, pretty and customizable themes, and useful features.

I enjoy having a small text editor for plain text files. Many editor apps try to do too much, or try to be portable and then sacrifice functionality instead. I decided I wanted to build something simple and targeted to macOS only so that I could use all of the cool features of macOS.

This project was inspired by a previous project of mine, TipTyper, which was also a plain-text editor, but written in Objective-C. That was the project that taught me Cocoa programming. Now that I feel I have an improved level of knowledge of Cocoa, I felt it would be appropriate to re-do that project, but now using the fantastic Swift programming language.

And because some people prefer light text on dark background, others dark text on white backgrounds, some others enjoy sepia tones, and others something completely different, I felt it was important to have a capable theme engine to allow the user to pick whichever colors they want for the entire document interface.

Work in this project is still ongoing, albeit a bit slow.

Kodex

Advanced code editor for iOS.

iOS UIKit Swift Objective-C

Screenshot of Kodex

I have always wanted to replace my notebook with a tablet for most of my daily tasks. I couldn't find a code editor for iOS that fit my needs and desires, especially regarding multi-caret edititng, so I decided to write my own.

Kodex has several features I couldn't find in other code editors available for iPad. The main one is multi-caret editing. This feature has become a major tool I consistently use to transform and replicate code, and not having it really hurt my productivity.

This project was started back in June 2017, and it has finally reached the App Store in March 2018. It took several late nights of creating problem solving; studying UIKit, TextKit, and other Apple APIs; and bug solving to reach an MVP.

Some other desktop-class features included in Kodex are:

  • Customizable key bindings
  • Regex search-replace, with capture group highlighting
  • Support for third party fonts (using Configurator system profiles)
  • Source minimap

Kodex development has been very educational and fun. It makes use of some free software packages, without which it Kodex wouldn't be possible. The list of used packages is listed in the Acknowledgements page of the Settings section. I have also made part of its source available under the LGPL license as the KeyCommandKit library, allowing the entire UIKeyCommand customization feature to be implemented by any App.

Mastonaut

Simple, elegant, and native Mastodon client for Mac.

macOS Cocoa Swift

Screenshot of Mastonaut

Mastonaut is a client for Mastodon, the distributed social network with over 2 million users worldwide.

I enjoyed using Mastodon a lot in the past already, but I felt that the experience could be better if I were using it from a desktop app instead of a web browser.

So I started this project back in December 2018, and six months later it made its way to the Mac App Store. Mastonaut has already gathered a significant user base, and I've since updated the app several times to add more features. It is an ongoing project that I work on during my spare time.

It is a Cocoa app written mostly in Swift, with some logic that's bound to strings and attributed strings processing in Objective-C for performance. No third party libraries are used, with the exception of MastodonKit (a library for the Mastodon API) and SVGKit, to render SVGs on the fly.

A lot of technical effort was placed on making Mastodon's custom animated emoji look good in the app, since most other clients (including for iOS) simply display their static versions. This is a whimsical feature that is technically difficult to implement well in Cocoa/AppKit, but I deemed it a worthwhile one, and in the end it looks great.

Pro:Sudoku

Sudoku game for iPad with support for Apple Pencil.

iOS Swift

Screenshot of Pro:Sudoku

I’ve been playing Sudoku since I learned about it in middle school. Either on my iPhone or on my iPad, I always have a game in progress that I go back to from time to time.

One day I had an epiphany: Wouldn’t it be nice if I could play Sudoku on my iPad with Apple Pencil, writing in numbers and clues just like on paper? After searching the App Store, I could only find a couple of apps that supported Apple Pencil input, but none of them preserved the strokes, kinda breaking the concept of playing like on paper.

So I decided to build it!

The first thing I built was a basic game of Sudoku that uses a conventional input model: Taps and buttons. This didn’t take long, but the next step would be harder: I had to make the board accept pencil strokes, and preserve them.

I started with a basic prototype of input taking with the Pencil using a PKCanvasView. After I had that working I had to support scaling the drawings up and down, especially to handle the case where a user resizes the game window by placing a different app side-by-side. This was an important feature to support, because I wanted to let people play the game while reading a tutorial, or watching a video.

Next I had to transform the user drawings into actual numbers. Thankfully Apple’s turicreate makes this extremely straightforward. Once I had a data-set (EMNIST) creating a model that fit my needs took almost no effort. I mostly spent time creating my own classes, as I not only wanted to be able to identify numbers, but also the X character (to allow a simple X gesture to erase a cell), and also a "noise" class with characters I wanted to ignore.

When I had that working, I had to generate my puzzles. This turned out to be a lot harder than I anticipated. Turns out there’s entire bodies of research on this subject. I realized that in order to build a good generator, it was required that I build a step-by-step solver that applies techniques used by human solvers, after all if a human solver can’t solve the puzzle in a straightforward manner, it’s no fun for human solvers (which are the target audience of this app!)

That took a monumental effort, and I spent over two months perfecting my generator/solver against known easy/hard/tough puzzles. In the end I think I came up with a solution that produces interesting games that avoid some pitfalls that make a puzzle annoying to solve (like needing to guess – a good puzzle can be solved simply by applying deterministic rules.)

One last feature I added was giving users the ability to create their own puzzle boards. Previously, when I was playing Sudoku on different apps, I’d occasionally see puzzles on websites or on puzzle books that I wanted to solve on the app, but there was no way to do that. One last feature I wanted to add was challenge puzzles. I contacted the famed Finnish mathematician and Sudoku puzzle creator/solver Arto Inkala who provided me with permission to use his famous Top 10 hardest puzzles in Pro:Sudoku. These puzzles are so hard that most step-by-step solvers are not capable of solving them (including Pro:Sudoku’s).

Overall this was a super fun project to build, and although new features could always be added, I feel like it is in a rather well-rounded state where it could probably stay for a while.

Nixie Watch

Nixie-tube watch “face” for Apple Watch.

watchOS CoreImage Swift

Screenshot of Noto

Tap watch to run animation

When I saw Woz demonstrating his "Nixie-Tube wrist watch", a behemoth that makes the Apple watch look like futuristic miniature tech, I decided it would be a cool custom watch face to develop for myself. However once it became clear Apple doesn’t want developers to create third party faces, I decided to simply make it anyway and put it on GitHub.

It was quite a challenge to build, in the end, since watchOS (especially watchOS 2, at the time) has very limited graphics capabilities. I had to render the watch face to an image buffer using CoreGraphics, output that to an image, and only then display on the screen.

Afterwards I modified it to render several “dummy” faces that are displayed in quick succession before the actual hour/minute faces in order to resemble the animations used by some of the other nixie watches out there.

It is a project I go over every once in a while and change some small things, and it certainly makes people curious when I show them my "exclusive" watch face.

tune

Command-line interface for iTunes.

macOS ScriptingBridge Swift

Screenshot of tune

Many times while at work, or while managing one of my VPS machines, I felt like I wanted to play some specific song from my iTunes library. But because I had my screen covered with several terminal sessions, many times in full-screen, it felt more like breaking my workflow than anything else.

So in a reversal of what I did with Cakebrew, I wrote a command-line tool to control a graphical application. Because ScriptingBridge, a fantastic feature from the heydays of Mac OS X, is still present in macOS, this was as easy as it can be. A simple programming interface is auto-generated, to which you can link and build code that sends and receives information from other applications.

A first version was a simple command line input-output program, with at most a single prompt in case your query produced more than one relevant result. Later I rewrote almost the entire thing to have a prettier text interface, using ncurses.

Now that macOS has Siri, this has become less of a problem, as I can ask Siri to play a specific song for me. However the fun in creating a project in ncurses for the first time made it still worth it.