Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCode 12 consequences on my model #930

Closed
timocafe opened this issue Sep 17, 2020 · 15 comments
Closed

XCode 12 consequences on my model #930

timocafe opened this issue Sep 17, 2020 · 15 comments
Labels
question Response providing clarification needed. Will not be assigned to a release. (type)

Comments

@timocafe
Copy link

timocafe commented Sep 17, 2020

❓Question

During the night my Xcode has been updated, and currently I am not anymore able to initialize my model in swift.
I get the error:

Type 'MLModel' has no member '__loadContents'

A user reports similar issue in StackOverflow: https://stackoverflow.com/questions/63917164/ml-build-error-for-catalyst-xcode-12-gm

my workflow

Convert my own model developed/obtained using TF. Plug it to Hello World MacOS swift App

swift code

let encoder: generic_4 = {
    do {
        let config = MLModelConfiguration()
        return try generic_4(configuration: config)
    } catch {
        print(error)
        fatalError("Couldn't create encoder model")
    }
}()

System Information

  • Catalina 10.15.6
  • Python homeBrew 3.8.5
  • TF 2.3
  • CoreTool 4.0b3
  • Xcode 12 - 12A7209
@timocafe timocafe added the question Response providing clarification needed. Will not be assigned to a release. (type) label Sep 17, 2020
@baaj2109
Copy link

same error

@anilkatti
Copy link

@baaj2109 @timocafe unfortunately, I have been able to repro this with the latest Xcode. I am trying to gather some information so I could repro this issue myself. Did you install Xcode via Mac app store? Is your app iOS, Mac or Catalyst?

@timocafe
Copy link
Author

Hello, thank you very much for the fast answer. I am dinosaur C++ dev, but baby MacOS. The app was for MacOS only. I just try to load the models by the code, I described on the top. The update was automatic, my Xcode version was updated during night. I did not try to delete and redownload from the App Store.

@anilkatti
Copy link

I don't see any issue in your steps. All seems reasonable. We will keep looking.

@anilkatti
Copy link

@timocafe what is the macOS deployment target set to in Project -> Info -> Deployment Target?

@baaj2109
Copy link

thank you for reply. my Xcode version is Xcode_12_GM_seed(12A7209) and download from developer.apple.com. The app is for Mac

@anilkatti
Copy link

anilkatti commented Sep 18, 2020

@baaj2109 @timocafe we root-caused this to a mismatch in SDKs in Xcode 12.0 GM. The official note on https://developer.apple.com/download/release/:

Xcode 12 includes everything you need to create amazing apps for all Apple platforms. Includes the latest SDKs for iOS, watchOS, and tvOS, and macOS Catalina. For development on macOS Big Sur or to support Apple silicon, continue to use Xcode 12 beta 6.

CoreML compiler in Xcode 12.0 GM is generating code that has symbols available only on macOS BigSur causing the compilation issue. If the goal is to build a catalyst or macOS-only app with Xcode 12.0, please follow this workaround:

Turn off code generation in the project, use xcrun coremlcompiler generate <YourModel.mlmodel> --language Swift to generate the code manually and then remove the offending method and add that swift file to their project.

This issue is resolved with latest beta release of Xcode 12.2, which can be found here: https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_12.2_beta/Xcode_12.2_beta.xip

@timocafe
Copy link
Author

Indeed it works, I turnoff the CoreML generation, and import the code manually. Thank you, have a good day

@oskarko
Copy link

oskarko commented Sep 22, 2020

How can I generate swift classes?
xcrun coremlcompiler generate <YourModel.mlmodel> —lang Swift
always create ObjC classes...

@msiracusa
Copy link
Collaborator

msiracusa commented Sep 22, 2020

I believe it may be —language Swift. Please give that a try or consult xcrun coremlcompiler -h

@anilkatti
Copy link

Sorry @oskarko - my mistake. I fixed the earlier comment. Here's the correct command line arguments.

xcrun coremlcompiler generate <YourModel.mlmodel> --language Swift

@vizaiapp
Copy link

How does one disable code generation for coreml models?

@msiracusa
Copy link
Collaborator

To disable code generation in Xcode 12 you should be able to:

  • Click on your .mlmodel in the left hand navigator
  • Show the file inspector on the right
  • In the Target Membership section of the file inspector go to the associated target and choose "No Generated Classes"

Alternatively I believe in your targets build settings you can set COREML_CODEGEN_LANGUAGE to "None"

@vizaiapp
Copy link

Thank you, @msiracusa !

@v1ergar
Copy link

v1ergar commented Oct 2, 2020

@anilkatti I did exactly this and now i get an error: Cannot call value non-function type 'module<...>'. I am a noob

Birch-san pushed a commit to Birch-san/coremltools that referenced this issue Nov 27, 2022
…apple#930)

* add community pipeline docs

* fix style in code snippets (lol)

* clean up loading docs

* add license to doc files

* fix some weird links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Response providing clarification needed. Will not be assigned to a release. (type)
Projects
None yet
Development

No branches or pull requests

7 participants