CreateML not available on iOS Simulator

One part of my app uses CreateML but I still need to test the UI on other screen sizes with the simulator. I tried using this condition but still get the same error.

#if os(iOS)
import CreateML // CreateML is not available when building for iOS Simulator. Consider using `#if os(iOS)` to conditionally import this framework when building for iOS.
#endif

Replies

CreateML is not on simulator now, please consider using #if targetEnvironment(simulator) to do a platform check.

  • I have imported CreateML in Build Phases -> Link Library With Library and made CreateML optional. There isn't a single line of CreateML mentioned in the project nor has it been imported in any file since its a new project that I created to test since the above solution was failing in the production project. But I still get this error "CreateML is not available when building for iOS Simulator", which is wierd since there is no reference of import CreateML in the project. I am currently on Xcode 13.2.1. Can you please help with this. Steps to reproduce: 1. Create a new iOS project in Xcode 13.2.1. 2. Add CreateML in Build Phases -> Link Library With Library and mark CreateML optional. 3. Change device to Simulator. Outcome: Build fails with message "CreateML is not available when building for iOS Simulator". And if you try to import CreateML with #if targetEnvironment(simulator) and device type is Simulator the error within the file is "No such module 'CreateML'" --- Note: Running this project on physical devices with iOS 15 work and iOS 14 works [since CreateML is made optional to support devices with iOS < 15]

Add a Comment