Vapor opens xcode but not as .xcodeproj

I followed the tutorial here

But when I open with “vapor xcode”, it will open code but it will not show it as a project where I am able to select the target.

see screen shot below. The project icon doesn’t have the usual “A” icon

Screen Shot 2020-10-06 at 1.08.17 PM

Hi! So that’s because it opens up the project as a Swift Package instead of your usual app. This integrates with SwiftPM and means no Xcode project to commit to source control (yay!). Swift packages have no project because everything needed is contained in the manifest and there’s no Xcode on Linux

Thanks. Excuse my ignorance, but why is that a positive? I want to drop a coreML model from Apple’s machine learning library based on the link in apple docs…
where you drop the model into the xcode project Navigator and it does some autconfiguration it seems. Now that its not an xcode project, how do I go about doing that same thing?

I am essentially trying to recreate the project in the tutorial of a vapor API that wraps a CoreML machine learning model.

Ah that’s a slightly more interesting problem. I’m not sure how you’re supposed to link CoreML to a Swift package, but the easy option for now is instead of vapor xcode run swift package generate-xcodeproj which will generate you an Xcode project and you can follow the steps in the tutorial. Note that you won’t be able to deploy the app onto Linux if that’s your plan

Thanks! well…the tutorial deploys the api in a docker container. Is that no longer possible? what is an alternative if that is the case?

I can’t see where it deploys it in Docker in the tutorial linked? But yes, using any Apple framework other than foundation, XCTest or dispatch on Linux won’t work. For ML you have a few options, none of which are currently ideal:

  • try and integrate Swift4TensorFlow - I’ve no idea if this will work, theoretically it should but they may still be relying on a custom fork of Swift and I’m not sure if it’s available via SwiftPM
  • use a Python module and call that from Swift - again possible but getting it to compile will be a challenge
  • farm it out to a separate service like AWS or IBM Watson - this is the easiest and will work but it’s another service you need to setup, configure and pay for

The final option is you host this on macOS hardware, which is definitely possible but not a ‘standard’ approach

Maybe, I am not understanding this well. To my understanding, the article is about making CoreML available on all platforms. So the author chose Vapor to be able to incorporate the CoreML model. Since Vapor is just a web framework, it could be deployed via docker containers and I can thus interface the API with my python flask app. Is this not possible?

Thanks for your patience. I have no clue what I am doing in the Vapor/Swift technologies and trying to make sense of it all.

Yeah I can see why given the tagline of the article and introduction. Unfortunately the article is highly misleading at best - the Vapor framework can be deployed into Docker no problem. CoreML however is only available on Apple platforms so can’t be. I think what the author was trying to do was get a Python app talking to Vapor app to use CoreML, but the Vapor app was still running on macOS unfortunately

Got it. Thank you so much for clarifying. I spent so much time dealing with technical difficulties thinking it was me. But it cant be done at the moment lol.