AI Agents Drained 500 GB of MacBook Disk in One Week: Swift Weekly #160
Rapidly Vanishing Disk Space — Dongpo Zhouzi's Swift Weekly #160
Rapidly Vanishing Disk Space
My MacBook holds almost nothing but development-related tools and data, and I usually keep at least 500–600 GB of free space. For a long time I assumed the built-in storage was more than enough. Then Agents changed that — last week I ran into two separate incidents where disk space was exhausted in a short period of time.
The first came from an Agent generating large amounts of data during development while the relevant directories were still inside Time Machine's backup scope. As files were continuously created, modified, and deleted, the data blocks retained by local snapshots kept accumulating, eventually eating up a huge amount of disk space. The problem only went away after I added those directories to the backup exclusion list and cleared the existing local snapshots.
The second came from a test script the Agent itself had written: it had a cleanup gap. It called mkdtempSync to create a temporary directory but had no corresponding cleanup operation. Every QA run fully unpacked a 5.7 GB Design repository. As tests repeated, a mountain of junk data quickly piled up on the disk.
Interestingly, both problems were ultimately solved with the Agent's help, but both were also caused by it. Compared with the linear working rhythm human developers are used to, Agents tend to push development forward in a more aggressive, parallelized way. This means that besides CPU and RAM, disk storage is also becoming a bottleneck that can't be ignored in this new workflow. And Apple's "gold-tier" storage pricing is famously expensive. I suspect many developers, when picking a new device that fits today's development needs, wince at the final configured price.
The AI "boom" has driven memory and flash prices up sharply in a short time, and the new development approach is in turn forcing developers to keep upgrading hardware. Everything feels like it has fallen into a strange "arms race."
Still, beyond spending money on more storage, what we may need to do instead is adapt to this working-paradigm shift sooner: define clearer, stricter environment boundaries for Agents, and establish reliable resource-management and cleanup rules. Otherwise, no hard drive is big enough to withstand an Agent's unbridled brute-force consumption.
This issue's content | Previous issue | All weekly issues
Recent Recommendations
Arborist — Manage Git worktrees with ease
A native Mac app: run Make, mise, npm, and just tasks on any branch, view the corresponding Pull Request, and resume Claude Code, Codex, or Copilot sessions where the conversation happened. Version 1.4 adds: find and clean up stale worktrees in one step.
Interesting ways of using Swift optionals
Optional is one of Swift's most fundamental, most commonly used, and most distinctive types. Around it, Swift offers a rich set of APIs and syntactic sugar. But beyond if let, guard let, and optional chaining, there is a lot more worth digging into. John Sundell introduces several interesting and less common usages in this article: take() combines two operations into one, unwrapping the wrapped value while resetting the variable to nil; switching over an optional Enum, handling nil together with each enum case; building continuous data-transformation chains with map and flatMap; and using generic constraints and KeyPath to extend Optional and package reusable judgment logic.
When I first learned Swift, I was always amazed at the little tricks Optional provides. You may no longer write code by hand that often, but these tricks still let you revisit the charm of the Swift language itself.
SwiftUI Performance: Find Redraws in Xcode Instruments
Antoine van der Lee uses a SwiftUI app with deliberately manufactured performance problems to show how to locate bottlenecks with the SwiftUI template in Xcode Instruments: using the View Body Updates hierarchy view to find views with high cumulative time, using the update details table to see the cost of each body execution and the Root Causes, then using the causality graph to trace the connection between state changes and view updates.
Antoine reminds readers that when analyzing SwiftUI performance, you can't only look at a single body execution's cost; you also need to combine update frequency and the trigger causes to judge the problem more accurately.
iOS 27: Now Playing Framework
For a long time, iOS's media metadata, playback state, and remote-control capabilities were scattered across different APIs. The Now Playing framework introduced in iOS 27 unifies these capabilities into a single media session model. Anton Gubarenko shows how to describe media content with MediaSessionRepresentable, provide playback state snapshots with MediaPlaybackSnapshot, and declare the playback operations the system can perform with MediaCommand.
Beyond simplifying system integration for local media playback, the new framework also supports Remote Media Sessions. With App Extensions and push notifications, playback state from external speakers, TVs, and other devices can be shown on the lock screen and in Control Center — and respond to user control — even when the main app isn't running.
Positioning SwiftUI views around the fold on iPhone Duo
When adapting to iPhone Duo, keeping views natural and stable as the device folds and unfolds is a new challenge for developers. Natalia Panferova puts forward an important idea in this article: adaptation isn't just about avoiding hardware constraints; you also need to consider visual continuity as the device's form changes.
Natalia shows how to use the .includeInactive option of GeometryProxy.reservedRegions(kind:options:) to obtain the not-yet-activated fold region in advance and prepare the layout for the folded state. By determining the grid column count ahead of time and dynamically adjusting column widths and spacing during the fold, content always stays distributed on both sides of the crease, avoiding large position shifts caused by column-count changes.
SwiftUI Text Interpolation Beyond Plain Strings
Although Text("Hello, \(name)") looks similar to String interpolation syntax, what actually runs behind it is a series of dedicated interpolation methods provided by LocalizedStringKey. It can interpolate not only strings, but also numbers, dates, Text, Image, and other types directly, presenting content according to each locale's language and formatting conventions.
Stewart Lynch covers many uses of Text interpolation: formatting currency, percentages, and dates with FormatStyle; using style: and timerInterval: for automatically updating relative time and countdowns; embedding differently styled Text or SF Symbols in a single sentence; and using AttributedString when text styles need to be set from runtime data. Also, compared with concatenating multiple Text values directly, interpolation preserves a complete localizable sentence, letting translators reorder content according to language conventions without being bound by the original concatenation order. This is also the important reason the + concatenation operator was deprecated for Text starting with iOS 26.
The Best API Change Is the One Nobody Notices
Adding new capabilities to a Swift framework often breaks compatibility — adding generic parameters or changing protocol requirements can force existing users to migrate code. Michael Long uses the example of adding Scene-level custom container support to the Factory dependency-injection framework to show how to extend functionality by adjusting internal design while keeping the public API essentially unchanged. To avoid changing the generic signatures of existing property wrappers, he chose to move the differences between container types from the type system to the data layer — managing multiple container instances through a single Environment Key and an ObjectIdentifier-based registry, falling back to the existing shared instance when no Scene container is found.
The article also covers preserving the existing Environment API with computed properties, and using DynamicProperty.update() to let @InjectedContainer read Scene containers in SwiftUI Views while maintaining the original behavior in regular classes.
Michael's practice raises a question worth considering for framework authors: new capabilities don't necessarily have to come at the price of breaking API changes. The key is finding the right internal abstraction boundary and balancing type safety, backward compatibility, SwiftUI environment mechanics, and API simplicity.
Run Multiple Claude Code Agents on the Same Xcode Project
Running multiple Agents in parallel on the same Xcode project is becoming increasingly common. But even if the source code is isolated with Git Worktrees, that doesn't mean the build and test environments are isolated too. For example, two Agents both report a successful build, but because they share the same Simulator, the later-installed app overwrote the earlier version. This means an Agent may unknowingly run and verify an app built by another Agent, making test results untrustworthy.
Amarildo Lucas analyzes how this problem arises and discusses how independent DerivedData, Simulators, and build configurations can reduce interference between parallel Agents. Amarildo reminds developers: multi-Agent collaboration requires isolating not just code, but also build products, the runtime environment, and the verification process.
Apple China App Store ICP Record Exemption Application
For developers who want to publish on the China mainland App Store, ICP filing can be a substantial hurdle — especially for overseas indie developers who lack mainland servers and the related filing prerequisites. However, for apps that run mainly locally and don't rely on self-hosted servers, Apple offers an exemption application path.
Fang Junyu shares his complete experience applying for an ICP filing exemption. From submitting a request through the Apple Developer contact page, to preparing a letter containing developer information, App ID, and related statements, to uploading PDF materials and receiving approval, the whole process took about 6 days. The article also provides a template for the statement letter and step-by-step instructions for each stage. Of course, this exemption isn't automatically granted to all offline apps; Apple's approval applies only to the specific app requested, and it doesn't mean other applicable laws and regulations are waived.
Tools
SwiftyDMG: A native SwiftUI DMG image maker
For developers distributing apps outside the Mac App Store, crafting a well-laid-out DMG is part of the polish before release. SwiftyDMG, developed by Chocoford, brings this workflow into a native SwiftUI interface: drop in a .app, adjust the positions of the app icon and the Applications folder shortcut with live preview, set window size, custom background, and disk icon, then generate the install image. It also offers a Finder right-click service and detailed build logs for quick packaging and troubleshooting.
PreviewMD: Quick Markdown preview and reader on macOS
Markdown has become one of the main formats for developer documentation, but unfortunately Quick Look on macOS still has no built-in full Markdown rendering preview. PreviewMD, developed by Adam Jesionkiewicz, fills this gap: select a file in Finder, press Space, and preview formatted headings, tables, task lists, code, and local images. It also includes a standalone reader app that can open an existing folder directly, browse documents, render Mermaid diagrams, jump between Obsidian backlinks, and switch between preview, split, and edit modes.
szt: An ultra-fast disk analysis command-line tool written in Swift
szt (sizetree), developed by Tommi Urtti, is an open-source command-line tool written in Swift that quickly scans a specified directory and shows disk-space usage in a colored tree view. It prioritizes expanding large directories and collapses less important content, letting developers quickly locate the main source of space consumption.
szt's other highlight is performance. It uses macOS's getattrlistbulk to fetch file metadata in batch and scans in parallel with multithreading. In the author's test, scanning a directory with 667,000 files totaling 123 GB took only 2.4 seconds, while the traditional du command took about 17 seconds. In the abnormal disk-space consumption problem I hit last week, szt sped up my investigation.
Previous Issues
- When apps no longer belong to a specific OS - #159
- Who is the real threat to AI-relay Apps - #158
- When Build in Public goes back underground - #157
- Swift Server, one more Google - #156
💝 Support and Feedback
If this issue of the weekly has been helpful, please:
- 👍 Like — help more developers see it
- 💬 Comment — share your thoughts or questions
- 🔄 Share — help your peers grow together
🚀 Expand your Swift horizons
- 📮 Email subscription | weekly.fatbobman.com — get exclusive technical insights
- 👥 Developer community | Discord — exchange development experience in real time
- 📚 Original tutorials | fatbobman.com — learn Swift/SwiftUI best practices
Top 1 of 3 from juejin.cn, machine-translated. The original thread is authoritative.
Anyway, I don't know where the disk went. There are clearly only a few projects left, but everything is dedicated to AI. I often use AI to help me analyze and troubleshoot, but it just never suffices.
AI occupies, AI checks, AI deletes.
AI spent your tokens.