YOLO26n-Pose in Xcode

Hello, I am trying to run a yolo26n-pose model on my iphone and I am using xcode to do this. I have read the yolo on ios documentation on github, and have followed the instructions regarding converting the model to coreML and having that in the correct directory in xcode. I added packages from the github in order for my code to run.

YOLO IOS tutorial github link: GitHub - ultralytics/yolo-ios-app: Ultralytics YOLO iOS App source code for running YOLO in your own iOS apps 🌟 · GitHub

After that, I have attempted to build my code, but I run into errors from the source files in the package that I am unable to edit. The errors are:

”Reference to captured var ‘self’ in concurrently-executing code”

These are inside of the YOLOView file. How do I resolve this issue, and why does it occur in the first place?

Can you post the full error traceback

Not sure if it is a bug in the YOLOView code itself of a dependency issue of some sort.

Thanks — from that screenshot, this looks like a Swift/Xcode concurrency compatibility issue, not a problem with your Ultralytics YOLO26 CoreML export. The yolo-ios-app example was written before Swift 6’s stricter concurrency checks, so newer Xcode versions can throw Reference to captured var 'self' in concurrently-executing code in YOLOView.swift.

So the short answer is: it happens because newer Swift treats capturing mutable self inside async/concurrent closures as a possible data race.

The quickest workaround is usually to use Xcode 15 / Swift 5.x, or make the package local/forked and patch those closures in YOLOView.swift so they don’t capture mutable self directly. Common fixes are patterns like [weak self] or copying values to let constants before entering the async block.

Your CoreML export flow is still the right one per the CoreML export docs. If you paste the exact few lines around the failing code in YOLOView.swift, I can point you to the precise Swift fix.