Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Sources/EMGFaultOrdering/Constructor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <mach/mach.h>
#import <mach-o/dyld.h>
#import <mach-o/dyld_images.h>
#import <sys/utsname.h>
#import <dlfcn.h>
#import <libgen.h>
#import <mach-o/getsect.h>
Expand Down Expand Up @@ -61,6 +62,13 @@
return [NSJSONSerialization dataWithJSONObject:result options:0 error:nil];
}

bool isSimulator(void) {
struct utsname systemInfo;
uname(&systemInfo);
NSString *machine = [NSString stringWithUTF8String:systemInfo.machine];
return [machine containsString:@"x86_64"] || [machine containsString:@"arm64"];
}

bool isDebuggerAttached() {
const pid_t self = getpid();
int mib[5] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, self, 0};
Expand Down Expand Up @@ -237,7 +245,7 @@ bool parseFunctionStarts(const struct mach_header_64 *header, intptr_t slide, vm
return getAddresses();
}];

if (!isDebuggerAttached()) {
if (!isSimulator() && !isDebuggerAttached()) {
printf("The debugger is not attached\n");
abort();
}
Expand Down
35 changes: 35 additions & 0 deletions run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -euo pipefail

# Configurable variables
PROJECT_PATH="Demos/DemoApp/DemoApp.xcodeproj"
SCHEME="DemoApp"
DESTINATION="name=iPhone 16 Pro"
XCRESULT_PATH="TestResults.xcresult"
OUTPUT_FILE="order-file.txt"

# 1. Run the test
echo "Running xcodebuild test..."
xcodebuild test \
-project "$PROJECT_PATH" \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-resultBundlePath "$XCRESULT_PATH"

echo "Test finished. Searching for attachment..."

# Run xcparse to extract plain text attachments
xcparse attachments "$XCRESULT_PATH" ./out/ --uti public.plain-text

# Find the output file matching the order-file pattern
ORDER_FILE=$(find ./out -type f -name "order-file_*.txt" | head -n 1)

if [[ -z "$ORDER_FILE" ]]; then
echo "❌ No 'order-file_*.txt' found in ./out"
exit 1
fi

# Move and rename it
mv "$ORDER_FILE" ./order-file.txt
echo "✅ Done"