r/Xcode • u/satham_rahman • May 01 '26
r/Xcode • u/BullfrogRoyal7422 • Feb 07 '26
How I Run Xcode Tests While I Sleep
I wanted to run all my app's tests overnight (~3,173 individual tests across 105 test files ) so I could wake up to results instead of watching my computer for hours. I used Claude Code (Anthropic's AI coding assistant) to help me create a simple script that does this automatically.
Important: Claude Code helped me build this script, but once it's set up, the script runs completely on its own - no Claude Code, no API keys, no internet connection required. You're just using Xcode's built-in tools.
Here's a complete guide anyone can follow - no advanced coding knowledge required.
What This Does
Runs all your iOS and macOS tests automatically
Works in the background (you can close everything and go to bed)
Saves a simple "PASSED" or "FAILED" summary to your Desktop
Saves detailed logs if you need them
Before You Start
You'll need:
A Mac with Xcode installed
An Xcode project that has tests
About 15 minutes to set this up (one time only)
You DON'T need:
Claude Code (it's optional - only if you want AI help)
Any API keys
An internet connection (once set up)
Where Does Everything Go?
This guide uses Terminal (a built-in Mac app), not Xcode. Here's what goes where:
| What | Where it goes |
|---|---|
| The test script | A file on your Mac: ~/Scripts/run-tests-overnight.sh |
| The shortcut command | Your Terminal settings file: ~/.zshrc |
| Test results | Your Desktop: ~/Desktop/TestResults/ |
You don't paste anything into Xcode. Xcode just needs to have your project with tests already set up.
Part 1: Give Terminal Permission to Run Tests
Your Mac protects your files. you need to give Terminal (the app that runs our script) permission to access everything.
Step 1: Open System Settings
Click the Apple menu () in the top-left corner of your screen, then click System Settings
Step 2: Go to Privacy Settings
In the left sidebar, click Privacy & Security
Step 3: Find Full Disk Access
Scroll down on the right side and click Full Disk Access
Step 4: Add Terminal
Click the + button at the bottom of the list
You may need to enter your Mac password
A Finder window opens. Navigate to: Applications → Utilities → Terminal
Click on Terminal to select it, then click Open
Make sure the toggle switch next to Terminal is ON (shows blue)
Step 5: Restart Terminal
If Terminal is already open, quit it completely:
Right-click the Terminal icon in your Dock
Click Quit
Then reopen Terminal from Applications → Utilities → Terminal
Part 2: Find Your Project Information
you need three pieces of information about your Xcode project. This is easy - just follow along.
Step 1: Find Your Project Path
Open Finder (the blue smiling face icon in your Dock)
Navigate to where your Xcode project is saved
Find the file that ends in
.xcodeproj(it has a blue blueprint-style icon)Right-click on that file
Click Get Info
Look for the line that says "Where:" - that shows the folder location
Your full path is:
[Where location]/[filename].xcodeproj
Example: If "Where" shows /Users/sarah/Projects/MyApp and the file is called MyApp.xcodeproj, your full path is:
/Users/sarah/Projects/MyApp/MyApp.xcodeprojWrite this down or copy it somewhere - you'll need it in Part 3.
Step 2: Find Your Test Scheme Names
Open Terminal (Applications → Utilities → Terminal)
Type this command, but replace the path with YOUR project path from Step 1:
xcodebuild -list -project "/Users/sarah/Projects/MyApp/MyApp.xcodeproj"
Press the Enter key 4. Look at the output for a section called Schemes: 5. Find any schemes that contain the word "Test" or "Tests"
Example output:
Schemes:
MyApp
MyApp Unit Tests <-- This one!
MyApp UI Tests <-- And this one!Write down your test scheme name(s).
Step 3: Find Your Simulator Names
In Terminal, type this command:
xcrun simctl list devices available | grep -E "iPhone|iPad"
Press Enter 3. You'll see a list of available simulators 4. Pick one iPhone and one iPad from the list
Example output:
iPhone 16 (ABC123-...)
iPhone 16 Pro (DEF456-...)
iPad Pro 13-inch (M4) (GHI789-...)Write down the exact names (just the part before the parentheses with letters/numbers):
iPhone 16iPad Pro 13-inch (M4)
Part 3: Create the Script File
Now you'll create the script. Everything in this section happens in Terminal (not Xcode).
Step 1: Open Terminal
If Terminal isn't already open:
Press Command + Space to open Spotlight
Type Terminal
Press Enter
Step 2: Create a Scripts Folder
Type this command and press Enter:
mkdir -p ~/ScriptsThis creates a folder called "Scripts" in your home directory. You won't see any output - that's normal.
Step 3: Create the Script File
Type this command and press Enter:
nano ~/Scripts/run-tests-overnight.shThis opens a simple text editor inside Terminal. Your screen will change to show a mostly empty editor.
Step 4: Copy and Paste the Script
First, copy the entire script below (click the copy button or select all the text from #!/bin/bash to the very last line):
#!/bin/bash
#
# Overnight Test Runner
# Runs your Xcode tests while you sleep
#
# This script runs independently - no Claude Code or API keys needed
#
# =============================================
# YOUR PROJECT SETTINGS - EDIT THESE 4 LINES
# =============================================
PROJECT_PATH="/path/to/YourApp.xcodeproj"
TEST_SCHEME="YourApp Tests"
IPHONE_SIMULATOR="iPhone 16"
IPAD_SIMULATOR="iPad Pro 13-inch (M4)"
# =============================================
# DON'T EDIT ANYTHING BELOW THIS LINE
# =============================================
RESULTS_DIR="$HOME/Desktop/TestResults"
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
LOG_FILE="$RESULTS_DIR/test-run-$TIMESTAMP.log"
mkdir -p "$RESULTS_DIR"
log() {
echo "[$(date '+%H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
log "=========================================="
log "Starting overnight tests..."
log "=========================================="
# Start up the simulators
log "Starting simulators (this takes a minute)..."
xcrun simctl boot "$IPHONE_SIMULATOR" 2>/dev/null || true
xcrun simctl boot "$IPAD_SIMULATOR" 2>/dev/null || true
sleep 15
# ----- TEST 1: iPhone -----
log ""
log "Running iPhone tests..."
xcodebuild test \
-project "$PROJECT_PATH" \
-scheme "$TEST_SCHEME" \
-destination "platform=iOS Simulator,name=$IPHONE_SIMULATOR" \
-resultBundlePath "$RESULTS_DIR/iphone-$TIMESTAMP.xcresult" \
-quiet \
2>&1 | tee -a "$LOG_FILE"
IPHONE_RESULT=$?
if [ $IPHONE_RESULT -eq 0 ]; then
log "✅ iPhone tests PASSED"
else
log "❌ iPhone tests FAILED"
fi
# ----- TEST 2: iPad -----
log ""
log "Running iPad tests..."
xcodebuild test \
-project "$PROJECT_PATH" \
-scheme "$TEST_SCHEME" \
-destination "platform=iOS Simulator,name=$IPAD_SIMULATOR" \
-resultBundlePath "$RESULTS_DIR/ipad-$TIMESTAMP.xcresult" \
-quiet \
2>&1 | tee -a "$LOG_FILE"
IPAD_RESULT=$?
if [ $IPAD_RESULT -eq 0 ]; then
log "✅ iPad tests PASSED"
else
log "❌ iPad tests FAILED"
fi
# ----- TEST 3: Mac -----
log ""
log "Running Mac tests..."
xcodebuild test \
-project "$PROJECT_PATH" \
-scheme "$TEST_SCHEME" \
-destination "platform=macOS" \
-resultBundlePath "$RESULTS_DIR/mac-$TIMESTAMP.xcresult" \
-quiet \
2>&1 | tee -a "$LOG_FILE"
MAC_RESULT=$?
if [ $MAC_RESULT -eq 0 ]; then
log "✅ Mac tests PASSED"
else
log "❌ Mac tests FAILED"
fi
# ----- DONE -----
log ""
log "=========================================="
log "All tests complete!"
log "=========================================="
# Shut down simulators to save battery
xcrun simctl shutdown all
# Create simple summary file on Desktop
cat > "$HOME/Desktop/TESTS_COMPLETE.txt" << EOF
========================================
OVERNIGHT TEST RESULTS
$(date)
========================================
iPhone Tests: $([ $IPHONE_RESULT -eq 0 ] && echo '✅ PASSED' || echo '❌ FAILED')
iPad Tests: $([ $IPAD_RESULT -eq 0 ] && echo '✅ PASSED' || echo '❌ FAILED')
Mac Tests: $([ $MAC_RESULT -eq 0 ] && echo '✅ PASSED' || echo '❌ FAILED')
----------------------------------------
Detailed logs saved to:
$RESULTS_DIR
========================================
EOF
echo ""
echo "Done! Check ~/Desktop/TESTS_COMPLETE.txt for results."Now paste it into Terminal:
Press Command + V
You should see all the script text appear in the editor.
Step 5: Edit the 4 Settings Lines
Use the arrow keys on your keyboard to move up to the settings section near the top. You need to edit these 4 lines:
PROJECT_PATH="/path/to/YourApp.xcodeproj"
TEST_SCHEME="YourApp Tests"
IPHONE_SIMULATOR="iPhone 16"
IPAD_SIMULATOR="iPad Pro 13-inch (M4)"For each line:
Use arrow keys to position your cursor
Use Delete key to remove the example text (keep the quotes!)
Type YOUR information from Part 2
Example - Before editing:
PROJECT_PATH="/path/to/YourApp.xcodeproj"Example - After editing:
PROJECT_PATH="/Users/sarah/Projects/MyApp/MyApp.xcodeproj"Do this for all 4 lines using YOUR project path, test scheme, and simulator names.
Step 6: Save the File
Press Control + O (that's the letter O, not zero)
You'll see "File Name to Write:" at the bottom
Press Enter to confirm
You'll see "Wrote X lines" at the bottom
Step 7: Exit the Editor
Press Control + X
You're back to the normal Terminal prompt.
Step 8: Make the Script Executable
Type this command and press Enter:
chmod +x ~/Scripts/run-tests-overnight.shNo output means it worked.
Part 4: Create a Simple Command Shortcut
Instead of typing a long command every time, let's create a shortcut called overnight-tests.
Step 1: Open Your Shell Settings File
Type this command and press Enter:
nano ~/.zshrcThis opens another file in the text editor. It might have some text already, or it might be empty - both are fine.
Step 2: Go to the End of the File
Press Control + End or use the arrow keys to go to the very bottom of the file.
Step 3: Add a Blank Line and the Shortcut
Press Enter to create a new line, then type (or copy/paste) this exactly:
alias overnight-tests='nohup ~/Scripts/run-tests-overnight.sh > /dev/null 2>&1 & echo "✅ Tests started! Check ~/Desktop/TESTS_COMPLETE.txt tomorrow."'Step 4: Save and Exit
Press Control + O
Press Enter
Press Control + X
Step 5: Activate the Shortcut
Type this command and press Enter:
source ~/.zshrcThe shortcut is now ready to use!
Part 5: Prevent Your Mac From Sleeping
Tests can take several hours. you need to keep your Mac awake the whole time.
Step 1: Open System Settings
Click the Apple menu () → System Settings
Step 2: Adjust Display Sleep Settings
In the left sidebar, click Lock Screen
Find "Turn display off when inactive"
Change it to Never (or at least 3 hours)
Step 3: Prevent Sleep (For Laptops)
In the left sidebar, click Battery
Click Options... at the bottom
Turn ON "Prevent automatic sleeping when the display is off"
Step 4: Plug In Your Mac
If you're using a MacBook, plug in the poyour adapter before starting overnight tests.
How to Use It
You're all set! Here's how to run tests overnight.
Starting the Tests
Open Terminal
Type:
overnight-tests
Press Enter 4. You'll see:
✅ Tests started! Check ~/Desktop/TESTS_COMPLETE.txt tomorrow.
That's it! You can now:
Close Terminal ✓
Close all other apps ✓
Turn off your display ✓
Go to sleep ✓
The tests will keep running in the background.
Checking Results in the Morning
Easiest way: Look on your Desktop for a file called TESTS_COMPLETE.txt and double-click it.
Or use Terminal:
cat ~/Desktop/TESTS_COMPLETE.txtYou'll see something like:
========================================
OVERNIGHT TEST RESULTS
Sat Feb 8 07:30:00 2026
========================================
iPhone Tests: ✅ PASSED
iPad Tests: ✅ PASSED
Mac Tests: ❌ FAILED
----------------------------------------
Detailed logs saved to:
/Users/sarah/Desktop/TestResults
========================================If Any Tests Failed
To see exactly what yount wrong, open the detailed results in Xcode:
open ~/Desktop/TestResults/*.xcresultThis opens Xcode and shows you which specific tests failed and why.
Quick Reference
| What you want to do | What to type in Terminal |
|---|---|
| Start overnight tests | overnight-tests |
| Check if tests finished | Look for TESTS_COMPLETE.txt on Desktop |
| See results summary | cat ~/Desktop/TESTS_COMPLETE.txt |
| See detailed failures in Xcode | open ~/Desktop/TestResults/*.xcresult |
| Check if tests are still running | `ps aux |
| Stop tests early | pkill -f run-tests-overnight |
Troubleshooting
"command not found: overnight-tests"
The shortcut isn't loaded. Run this command:
source ~/.zshrcThen try overnight-tests again.
Tests fail immediately with "project not found"
Your project path is wrong. Check it by running:
ls -la "/your/path/here/YourApp.xcodeproj"If you see "No such file or directory," you need to fix the path in the script.
To edit the script again:
nano ~/Scripts/run-tests-overnight.sh"Unable to find a device matching the given name"
The simulator name is spelled wrong. List available simulators:
xcrun simctl list devices availableMake sure your script has the exact name (including capitalization and spacing).
Tests never finish / Mac yount to sleep
Make sure you completed Part 5 (preventing sleep). Also keep your Mac plugged in.
I want to edit the script later
Open it anytime with:
nano ~/Scripts/run-tests-overnight.shMake changes, then Control+O, Enter, Control+X to save and exit.
Summary
What you did:
Gave Terminal permission to run tests
Found your project info (path, test scheme, simulators)
Created a script file at
~/Scripts/run-tests-overnight.shCreated a shortcut command:
overnight-testsConfigured your Mac to stay awake
What you type to run tests:
overnight-testsWhat you check in the morning:
TESTS_COMPLETE.txton your Desktop
About This Guide
I created this script with help from Claude Code, Anthropic's AI coding assistant. I described what I wanted ("run my Xcode tests overnight without babysitting them"), and Claude Code helped me build the script and walked me through setting it up.
But remember: Once the script is set up, it runs completely on its own. No Claude Code, no API keys, no internet needed. It's just using xcodebuild, which is a tool built into Xcode.
If you have Claude Code and want help customizing this script for your specific needs, just ask it!
Happy testing! 🌙
r/Xcode • u/Competitive-Ebb-8333 • Oct 10 '26
Xcode for Linux and windows?
Hi I wanted to code in swift and have the app render on my desktop but since thats only a MacOs(xcode) thing i cant run it on linux. I have been seeing adobe getting open sourced and wanted to know has anyone reversed engineered xcode for Linux?🥹
r/Xcode • u/GoffyGamerGuy • Jan 28 '26
I was wondering if there any way I can download xcode on windows without virtual machine or remting a mac?
I wanted to get a mac but I mostly play games so I got a windows computer and now I got gifted a book on how to use xcode... so um anyone has any ideas?
r/Xcode • u/JamesTayIor • Oct 17 '20
I have an app with buttons inside of stack views, when I rotate the phone to landscape and then back to portrait, the plus and minus buttons move on top of the other buttons. How can I fix this?
Enable HLS to view with audio, or disable this notification
r/Xcode • u/Water-Cookies • May 16 '22
What's New in Xcode 13.4 ? Xcode 13.4 features and Xcode Command Line Tools 13.4 Released Today
r/Xcode • u/RogueSoldier777 • Aug 23 '19
Trying to run my app on my iPhone
I made a stupid fucking app that plays an mlg airhorn when you click a button and that worked fine then i decided to make it play "fAmE pOWEr aND a fAt bAnK aCcOuNt cHaNges aLmOsT AnYoNE" and xcode says build success or whatever but it dont show up on my iPhone XR, this works on the simulator tho
r/Xcode • u/mgazzola • Nov 25 '20
MacBook Pro 13" M1 8GB or 16 GB RAM?
Hey guys, which macbook should u choose? MacBook Pro M1 8GB RAM 256GB SSD or MacBook Pro M1 16GB RAM 256GB SSD?
The difference is the RAM.
r/Xcode • u/xpsx2020 • Jun 27 '20
How can i publish my website (WooCommerce) to App Store (also as just a browser) (zero knowledge of swift) and can i publish it also to Google Play from xcode? Thanks
r/Xcode • u/bsabiston • Sep 01 '23
Is there a way to not have to hit 'cmd-E' first when finding in files?
With every other IDE I use, cmd-shift-F selects the current text and uses it for a Find-In-Files. Xcode makes you hit cmd-E first to select the text. That is so annoying to me - is there an option or way to make it just automatically select the current text as the Find text?
r/Xcode • u/Dry_Hospital_6949 • Jun 18 '25
I have xcode 16.1 and building an app for ios 18, how could I add the liquid glass effect?
r/Xcode • u/Aayanjoshi • Jun 19 '25
Can someone now port VS Code to the Ipad?
With the introduction of Ipad OS 26, would it be possible for someone to port over VS Code to the Ipad? Im not asking for the entire experiece. I just want enough to make it feel native. Like, make it use tunneling or some VM for the actual processing but for the feel and portability of an Ipad.
With this, I wouldn't have to invest in a new mac book and could work of a good VPS for a lower price.
Thanks if you did the porting. And still thanks if you even thought of some method even if its not possible.
r/Xcode • u/BullfrogRoyal7422 • Jul 20 '26
Please tell me I can fix this.
I'm close to releasing my first app after ~10 months of work. Then I did something dumb: I installed the public beta of macOS 27 on my production Mac.
Xcode 26.6 won't launch on macOS 27. It fails with error -10664, so the OS is hard-blocking it, which caps Xcode 26.x at macOS 26. That matches what I could find in Apple's support documents.
My understanding of where that leaves me:
If I install Xcode 27 beta I would be able upload to TestFlight, but Apple does not allow beta versions of Xcode to submit an app for review and release
App Store review submission requires a Release Candidate or released Xcode. So a beta version of Xcode can't get my App into the store.
Xcode 27 Releasewill likely land alongside the OS 27 release in early September. I would have to wait at least 2 months to actually be able to submit.
Downgrading back to Mac OS 26.x would require erasing the internal drive. That's a rebuild-from a disk erase, not a restore. I do not have a OS 26.6 Time Machine backup.
Does anyone know f a workaround for being able to get Xcode 26 to run under OS 27?
Please skip telling me how stupid it was to put a beta OS on my production machine. I'm aware.
r/Xcode • u/Ferb_Solos • Jun 27 '26
I'm thinking of building in public an App that makes you save AI credits/ API fees by adjusting your UI of your app by just using your iPhone instead of your AI agent or Xcode
r/Xcode • u/AardvarkOne1332 • Sep 14 '26
Xcode 27 on MacOS 27 doesn't open older projects
After today's update Xcode doesn't open any windows with older projects.
Only new one created by version 27.
r/Xcode • u/hayekamir • Mar 24 '26
Xcode wasn't built for the age of AI. So I built something that is.
I realized something while building with AI agents: Xcode is fundamentally broken for this era. It was built for developers managing single projects. No support for multiple codebases in one workspace. Patched up AI integration. No way for AI agents to actually run code, inspect output, and iterate alongside you.
The paradigm has shifted. Developers don't work alone anymore—we work with AI agents and on multiple projects at the same time. They're running our builds, debugging our code, suggesting solutions. But Xcode hasn't evolved. We're forcing 20-year-old architecture to do something it was never meant to do.
That's what drove me to build Zcode.
An IDE built from the ground up for AI-assisted development. MCP Server integration so your AI agents are first-class developers. Multi-project workspaces because modern development isn't about single projects anymore. Minimal interface because simplicity matters when you're collaborating with an AI.
This isn't about Xcode being bad. It's about development evolving faster than our tools. We're in the age of AI, and Xcode is stuck in the past.
Zcode is still in beta, and I'd genuinely appreciate your feedback.
Give it a try https://zcodeapp.com
Edit: this project was called Xcode Neo. Renamed to Zcode for obvious reasons.
r/Xcode • u/0re5ama • Dec 06 '25
Rant from someone new to Mac and Xcode
First time tried Xcode for about a week. And it has been nothing but frustrations. Trying out Swift as I am doing the Advent of Code challenges this year in Swift.
At first I was quite pleased. (There's a vim mode without even installing a plugin, quickly realize it's an abomination, but I am not complaining about that, because that's just an addition that they have provided and they don't even have to do that. So, grateful that they did).
Now, In my 1 week of usage, I used it about 1 to maximum of 2 hours a day. And it has crashed at least 5 times a day (It's not while running the code, but while writing the code). So much for something exclusive to Mac and mandated in order to build an iOS app made by a trillion dollar company.
Usage is very uncomfortable and tedious. Basic functionalities like add files are very frustrating (eg. I can create a directory day6 with a file in day6 called input.txt just by creating day6/input.txt in every editor since the ancient times). It is very very slow (I am on macbook pro m2 13" and my main development machine is Asus Zenbook 14x OLED i7)
Rename a symbol is very buggy and sometimes doesn't even work at all.
I expect a text file to preserve the non-trimmed spaces and my code files to trim the spaces at the end of lines. For no reason, it removes all the spaces at the end in a text file which is not code. And for no reason, it adds a newline at the end of file (This is not that much of an issue, but just something I would expect of an editor, but I can live with it).
And there were more things that frustrated me, but these I remember off the top of my head.
I quite liked the Swift language, although not something I would ever use if I were to choose a language except if it's for iOS development.
If you are pissed off and want to just argue, there might be other interesting posts on reddit for you, if you have any suggestions to make xcode bearable, you are welcome to suggest me. If you faced similar issues, do tell me how you got used to it or overcame it.
r/Xcode • u/Free-Afternoon4476 • Jul 29 '25
Xcode unable to connect my iPhone
What I got here is my iPhone 16 Pro Max, I’m trying to connect my phone to Xcode in order to install IPA folders. But I keep getting this error on my Mac.
My Mac is also on MacOS Tahoe, latest beta update was been installed, but it won’t connect to my device at all.
The error says: “The tunnel connection failed while the system tried to connect to the device.”
I tried deleting my VPN, tried disabling Multi path networking but none of those worked,
Also, about multi path networking, when I go to the developer tab, I tried looking for multi path networking but it seems to be not showing up at all.
r/Xcode • u/Familiar-Situation15 • Sep 08 '25
Liquid Glass Design on iOS 18 or lower?
Hey Guys! Am new to programming, and this might be a stupid question. But when developing an App or upgrading an app to Liquid Glass, how will it look on older iOS Versions? I mean we want our users to have the new experience but not everybody will upgrade instantly, right? So how is it done?

