简体   繁体   中英

Unable to run vapor as server into an iOS app

I am trying to add a REST API handling function to my existing iOS App. What I am trying to achieve is to make my iOS app work as local server.network. I just started to learn about Vapor.

Face a problem when I want to start the server. It throws error

Unknown command -NSDocumentRevisionsDebugMode

Here is my class

import Vapor
import Leaf

class BackendManager {
    
    var app = Application(.development)
    
    init() {
        app.http.server.configuration.hostname = "0.0.0.0"
        app.http.server.configuration.port = 8080
        
        app.views.use(.leaf)
        app.leaf.cache.isEnabled = app.environment.isRelease
        app.leaf.configuration.rootDirectory = Bundle.main.bundlePath
        app.routes.defaultMaxBodySize = "50MB"
    }
    
    func start() {
        Task(priority: .background) {
            do {
                try app.start()
            } catch {
                fatalError(String(describing: error))
            }
        }
    }
}

And here is how I call it

let server = BackendManager()
server.start()

Here is my configuration

在此处输入图像描述

What am I missing here? Thanks...

After followed the solution suggested in (Xcode and Python) error: unrecognized arguments: -NSDocumentRevisionsDebugMode

It will throw another error -AppleLanguages

Someone in the Discord group helped me to solve this by passing this configuration before start the server

app.environment.arguments = [app.environment.arguments[0]] and it is done

Hope this will help anyone affected in the future

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM