apple / apple/coreai-models

Swift package fails to compile for the iOS Simulator (no such module 'CoreAI')

Open
#49 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Swift
Stars
2.1k
Forks
202
Avg merge
2d 8h
Merged PRs (30d)
55

Description

## Problem

`CoreAI.framework` ships only in the device SDK (it's the Neural Engine inference runtime) and is **absent from the iOS Simulator SDK**. The library targets currently guard only the macOS-x86_64 case (`#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))`), so every source that `import CoreAI` fails to compile for an iOS Simulator destination.

Because Xcode pre-builds a referenced package for the active destination, any app that links a CoreAI product (e.g. `CoreAILM`) on device can no longer build its **Simulator** slice — it fails with `no such module 'CoreAI'`.

## Steps to reproduce

1. Add the package `https://github.com/apple/coreai-models` to an app target that links `CoreAILM` (or any `CoreAI*` library).
2. Select an iOS Simulator destination (e.g. iPhone 17, iOS 27.0).
3. Build.

→ Fails with `no such module 'CoreAI'` across `CoreAILanguageModels` / `CoreAIDiffusionPipeline` / `CoreAIImageSegmenter` / `CoreAIObjectDetector`.

**Environment:** Xcode 27.0 beta · iPhoneSimulator 27.0 SDK · iOS 27.0 deployment.

## Proposed fix (ready & verified)

Guard the CoreAI-dependent sources behind `#if canImport(CoreAI)` — **27 files** (every file that imports CoreAI, plus 4 that reference CoreAI-typed symbols: `CoreAIRunner`, `CoreAILanguageModel`, `PipelineDescriptor`, `ImageSegmenter`). On device `canImport(CoreAI)` is true and everything compiles unchanged; on the Simulator the CoreAI inference path compiles out (it can't run without the Neural Engine anyway). Purely additive: **+54 / −0**.

Verified: `CoreAILM`, `CoreAIDiffusion`, `CoreAISegmentation` and `CoreAIObjectDetection` all build for `generic/platform=iOS Simulator` (iPhoneSimulator 27.0 SDK).

Branch / diff:
https://github.com/apple/coreai-models/compare/main...KodaKoder:coreai-models:simulator-canimport-guard

> I couldn't open a PR directly — PR creation on this repository is currently limited to collaborators. Happy to open one if a maintainer lifts the restriction or wants me to.

## Apple Feedback

Also filed as Apple Feedback **FB23189921**.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the 27 sources that import CoreAI and the four additional sources referencing CoreAI-typed symbols such as CoreAIRunner and PipelineDescriptor. Build CoreAILM, CoreAIDiffusion, CoreAISegmentation, and CoreAIObjectDetection for generic/platform=iOS Simulator; done means all four compile successfully while device builds remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
ai, build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.