Skip to content

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

Description

@KodaKoder

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:
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions