Let’s Build a Fart Button App for Apple Vision Pro
One of Us In our community, it is a rite of passage to build the cult classic fart button app. Will you record your own farts? Invent a way to generate all kinds of different farts? Surprise us with something different? That’s up to you. You can built any app you like, as long as it’s the fart button. This guide will walk you through creating a simple Fart Button app for Apple Vision Pro using SwiftUI and RealityKit. The app will display a floating button in visionOS, and when pressed, it will play a fart sound. Prerequisites Before you begin, ensure you have: 1. A Mac running macOS Sonoma or later 2. Xcode 15 or later installed 3. The visionOS SDK (comes with Xcode) 4. Basic knowledge of Swift ⸻ Step 1: Create a New visionOS Project 1. Open Xcode. 2. Click Create a new project. 3. Select visionOS App and click Next. 4. Name your app Fart Button, set Interface to SwiftUI, and set the Language to Swift. 5. Choose a location to save the project and click Create. ⸻ Step 2: Add a Fart Sound to Your Project You need a fart sound file for the app: 1. Record one of your farts with a phone or voice recorder. You could also download a fart sound effect (MP3 or WAV). Ensure you have the rights to use it. 2. Drag the sound file into Xcode’s Assets folder. 3. Rename it to fart.mp3 (or fart.wav if using WAV). ⸻ Step 3: Create the Fart Button UI Open ContentView.swift and replace its contents with the following code: import SwiftUI import AVFoundation struct ContentView: View { @State private var audioPlayer: AVAudioPlayer? var body: some View { VStack { Button(action: playFartSound) { Text("

One of Us
In our community, it is a rite of passage to build the cult classic fart button app.
Will you record your own farts? Invent a way to generate all kinds of different farts? Surprise us with something different? That’s up to you. You can built any app you like, as long as it’s the fart button.
This guide will walk you through creating a simple Fart Button app for Apple Vision Pro using SwiftUI and RealityKit. The app will display a floating button in visionOS, and when pressed, it will play a fart sound.
Prerequisites
Before you begin, ensure you have:
1. A Mac running macOS Sonoma or later
2. Xcode 15 or later installed
3. The visionOS SDK (comes with Xcode)
4. Basic knowledge of Swift
⸻
Step 1: Create a New visionOS Project
1. Open Xcode.
2. Click Create a new project.
3. Select visionOS App and click Next.
4. Name your app Fart Button, set Interface to SwiftUI, and set the Language to Swift.
5. Choose a location to save the project and click Create.
⸻
Step 2: Add a Fart Sound to Your Project
You need a fart sound file for the app:
1. Record one of your farts with a phone or voice recorder. You could also download a fart sound effect (MP3 or WAV). Ensure you have the rights to use it.
2. Drag the sound file into Xcode’s Assets folder.
3. Rename it to fart.mp3 (or fart.wav if using WAV).
⸻
Step 3: Create the Fart Button UI
Open ContentView.swift and replace its contents with the following code:
import SwiftUI
import AVFoundation
struct ContentView: View {
@State private var audioPlayer: AVAudioPlayer?
var body: some View {
VStack {
Button(action: playFartSound) {
Text("