NotADiary
Photo journal, synced through CloudKit
The hard part was sync: conflict resolution, an offline operation queue and reconciliation across devices, with Core Data underneath.
- iPhone
- SwiftUI
- CloudKit
- Core Data
Open to iOS roles
iOS Developer
I build apps for the Apple ecosystem, contribute to the Swift compiler and write Sword, a systems language.
Featured
Frame-by-frame animation, played live
Mola
Animations drawn frame by frame in the app, during development.
Filho da pata
Talking about you
Pungaré
Conselhos do Alberto
Shrinker
Photo journal, synced through CloudKit
The hard part was sync: conflict resolution, an offline operation queue and reconciliation across devices, with Core Data underneath.
Lap timer and global ranking for kart drivers
Lap times, metrics and gamification. The ranking is shared through CloudKit, and local matches run over MultipeerConnectivity, with no server in between.
Narrative game about dinosaurs
The story runs on a stateful decision tree, built with GameplayKit.
Done or nearly, not on the store yet.
Queued for App Nominations
Frame-by-frame animation, played live
Each cycle is drawn by hand with the Apple Pencil. In the scene, some cycles follow the timeline and others are triggered on the spot by on-screen buttons and joysticks. The canvas has its own Metal renderer, and the app ships in 13 languages. It's queued for Apple's App Nominations, so it isn't on the store yet.
Mola's undo. Instead of a texture per step, at tens of megabytes each, every edit is a command that knows how to reverse itself, and carries ids rather than indices.
/// One reversible edit. The unit of undo.
/// Answers ADR 003 in favour of invertible commands over snapshots,
/// for the reason the canvas makes obvious: a texture snapshot per step
/// costs tens of megabytes, while a stroke costs 32 bytes per point.
///
/// Every case carries **ids, never indices**. Undoing the removal of
/// something in the middle of a stack renumbers everything above it,
/// and an index recorded a minute ago would point at the wrong thing now.
nonisolated enum EditCommand: Sendable, Equatable {
/// A stroke was committed to a frame. Reverses by dropping the last one.
case stroke(frameID: Frame.ID, stroke: Stroke)
/// A frame was emptied. Carries what was in it.
case clearFrame(frameID: Frame.ID, strokes: [Stroke])
/// A cycle's whole frame list, before and after. Merge, reverse,
/// ping-pong and reorder undo in one step, which is what a person
/// expects from "merge".
case reshapeFrames(cycleID: Cycle.ID, before: [Frame], after: [Frame])
/// A cycle **and everything that pointed at it**, as one step.
case deleteCycle(CycleDeletion)
case restoreCycle(CycleDeletion)
// …
} The table of a Norse RPG, on iPhone, iPad and Mac
The game master's Mac opens the session over Bonjour and players join from iPhone or iPad on the same network. Remote players join through CloudKit's public database with a six-letter code, with no server of my own, and both tables share one session. The map has water and snow animated with Metal shaders, fog of war and per-scene weather.
The game master's Mac advertises the session over Bonjour with Network.framework. Players on the same network join directly; remote ones arrive through CloudKit and land in the same list.
func start(campanha: String) {
stop()
do {
let params = NWParameters.tcp
params.includePeerToPeer = true
let listener = try NWListener(using: params)
listener.service = NWListener.Service(name: campanha, type: "_orlog._tcp")
listener.stateUpdateHandler = { [weak self] state in
DispatchQueue.main.async {
switch state {
case .ready:
self?.isRunning = true
self?.statusText = "Sessão aberta — \"\(campanha)\""
case .failed(let error):
self?.isRunning = false
self?.statusText = "Falha: \(error.localizedDescription)"
default: break
}
}
}
listener.newConnectionHandler = { [weak self] connection in
self?.accept(connection)
}
listener.start(queue: queue)
self.listener = listener
} catch {
statusText = "Não foi possível abrir a sessão: \(error.localizedDescription)"
}
} Simple spreadsheets that turn into charts on the spot
For small business owners who don't want to learn spreadsheets: type the numbers and the chart appears, with notes on data points and export to PDF and CSV. Offline, no account, with SwiftData and Swift Charts on iOS 26.
Prototypes, challenges and experiments.
Party game between iPhone and Apple TV
Up to four players: the iPhones become controllers and minigames, and the Apple TV is the arena. Peer discovery, state sync and messaging over MultipeerConnectivity, with the network isolated in an actor.
The MultipeerConnectivity delegate is a plain class; the network is an actor. This proxy bridges them, decoding before creating the Task so messages from other app versions are dropped.
final class SessionProxy: NSObject, MCSessionDelegate {
weak var owner: BaseNetworkActor?
func session(_ session: MCSession,
peer peerID: MCPeerID,
didChange state: MCSessionState) {
Task {
switch state {
case .connected: await owner?.emit(.connected(peerID))
case .notConnected: await owner?.emit(.disconnected(peerID))
default: break
}
}
}
func session(_ session: MCSession,
didReceive data: Data,
fromPeer peerID: MCPeerID) {
// Fora da `Task`: quem chega de uma versão diferente do app manda
// um tipo que este lado não conhece, e aí não há evento a emitir.
guard let envelope = NetworkEnvelope(framed: data) else { return }
Task { await owner?.emit(.received(envelope, peerID)) }
}
} Draw a shape, fire a shortcut
A menu bar app for macOS, with no Dock icon. Hold Control and draw with the mouse: a circle becomes ⌘C, a triangle ⌘V. Shapes are recognized by a $P recognizer written from scratch.
A $P recognizer. Tilt tolerance comes from rotating the templates, once, rather than the drawing, because rotation and squashing don't commute.
/// Girar o template em vez do desenho não é detalhe de eficiência,
/// é o que torna a tolerância correta. O traço de quem desenha é a forma
/// girada e depois achatada nos eixos da tela, e as duas operações não
/// comutam: desgirar o desenho não desfaz o achatamento.
init(templates: [GestureTemplate]) {
self.templates = templates.flatMap { template in
(0..<Self.rotationSteps).map { step in
let fraction = Double(step) / Double(Self.rotationSteps - 1) * 2 - 1
return template.rotated(by: fraction * Self.rotationTolerance)
}
}
}
func recognize(_ points: [StrokePoint]) -> RecognitionResult? {
guard points.count >= 2, !templates.isEmpty else { return nil }
let candidate = Self.normalize(points)
var best: RecognitionResult?
for template in templates {
let distance = Self.greedyCloudMatch(candidate, template.points)
let score = max((2.0 - distance) / 2.0, 0.0)
if score > (best?.score ?? -1) {
best = RecognitionResult(templateName: template.name, score: score)
}
}
return best
} Trigonometry as a game, for the Swift Student Challenge
Conceived and built in just over a week, with SpriteKit and SwiftUI. The animations and the game's behavior change as time passes.
Tetris in Swift, in the Mac terminal
No UI framework: key-by-key input and drawing straight in the terminal, using the Darwin library.
To read each key without waiting for Enter, the game turns off the terminal's canonical mode and echo through Darwin's termios, and makes reads non-blocking so the game loop keeps running.
// Configura o Modo Raw, que faz com que os inputs do usuário possam
// ser feitos sem a confirmação e sem o retorno do output
func configureRawMode() {
var terminalConfig = termios()
tcgetattr(STDIN_FILENO, &terminalConfig)
terminalConfig.c_lflag &= ~UInt(ICANON | ECHO)
tcsetattr(STDIN_FILENO, TCSANOW, &terminalConfig)
}
func setNonBlockMode() {
let flags = fcntl(STDIN_FILENO, F_GETFL)
fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK)
}
// Função que volta o terminal para as configurações padrão
func restoreTerminal() {
var terminalConfig = termios()
tcgetattr(STDIN_FILENO, &terminalConfig)
terminalConfig.c_lflag |= UInt(ICANON | ECHO)
tcsetattr(STDIN_FILENO, TCSANOW, &terminalConfig)
} Interface entirely in UIKit
An app with its interface built entirely in UIKit, with no SwiftUI.
Fixes to the Swift compiler and Apple's libraries. Each one starts from an issue someone else opened: reduce the case, find where the compiler contradicts itself, and leave a test that fails without the fix.
case iso(isolated Int) crashed the compiler on an ASTContext assertion. The case constructor's type was built with an empty ExtInfo while its parameter arrived flagged isolated. The flag is now dropped there, and the existing diagnostic, which the assertion used to beat, shows up again.
One branch of Package.swift defined the AsyncAlgorithms 1.2 macro twice and never 1.3, which FlatMapLatest relies on.
With typed throws (SE-0421), try await first(where:) inside a throws(Failure) broke SILGen: Sema treats the call as throwing Failure, but at the ABI level it throws any Error. The PR adds the missing cast and tests it with and without opaque values.
A consuming closure passed into a generic context failed SIL verification. The original report came from SwiftUI with @MainActor closures; I reduced it to two lines and showed concurrency had nothing to do with it.
The bug was already fixed on main, but no test held it in place. The new test fails on Swift 6.3.3 and passes on 6.5-dev.
A programming language
A compiled systems language with Go's syntax and Zig's memory model. There's no garbage collector, nothing allocates behind your back, and the compiler refuses to build a program where two tasks can touch the same memory at the same time.
current release 0.3.0 “Quench”
main.sword import "std/mem"
func square(xs []i64, mut out []i64) {
for i in 0..out.len {
out[i] = xs[i] * xs[i]
}
}
func main() !int {
mut backing := [4096]u8{}
mut arena := mem.NewArena(backing[..])
mut src := mem.Alloc[i64](&arena, 64) orelse return error.OutOfMemory
mut dst := mem.Alloc[i64](&arena, 64) orelse return error.OutOfMemory
scope {
for off, part in dst.chunks(8) {
spawn square(src[off..off+part.len], part)
}
}
return int(dst[63] % 100)
} Eight tasks write into eight pieces of the same array. That compiles because chunks hands out pieces that cannot overlap. Slice dst by hand inside the loop and the compiler stops you, because it has no way to know the pieces are distinct.
Any function that touches the heap takes an Allocator. That holds for the standard library too, so a signature without one cannot allocate.
spawn only exists inside scope, and the closing brace is the join. That's what makes it safe to lend a task a slice of memory the parent owns.
Immutable data crosses between tasks with no synchronisation at all, which is what the race checker leans on.
What the compiler can't see is the order tasks run in. shield test -sim runs each test under many interleavings, and a failure comes with the seed that reproduces it.
The standard library already has HTTP/1.1 and TLS, client and server, TCP and UDP, JSON, crypto, files, processes and calls into C. A work-stealing scheduler runs the tasks, each on its own stack: a task waiting on a socket is put down and the worker moves on. The compiler (shield) and the language server (swordls) are written in C++.
I'm an iOS developer at the Apple Developer Academy, at Mackenzie, in São Paulo. I have apps on the App Store: NotADiary, a photo journal synced through CloudKit; Karthos, with a global ranking on CloudKit and local matches over MultipeerConnectivity; and DeckExtinction, a narrative game built on a GameplayKit decision tree. Mola, an iPad animation editor built with a team, is queued for Apple's App Nominations, and ÖRLÖG Companion runs the table of an RPG across iPhone, iPad and Mac.
I like knowing what happens underneath Swift. I've sent fixes to the Swift compiler and to swift-async-algorithms, and I write Sword, a compiled language that refuses programs with data races. Before that I wrote an assembler, an interpreter and a terminal text editor.
I study Computer Science. I'm also a pianist and piano teacher, with prizes in international competitions.
Backend and low-level.
Numbers from the Go service that draws the terminal on my GitHub profile, read at build time and refreshed in the browser.