Back

Trying to run a simple Swift Function

  • 0
  • Functions
  • Apple
bariscakmak
3 Sep, 2023, 12:21

I am using version 1.3.7 and facing with an issue when I try to run a swift function. Is there any example function/documentation about how to deploy a swift function? It was quite challenging for me to adding to the env and downloading the openruntimes swift image by myself.

TL;DR
User is asking for help with running a simple Swift function using appwrite-cli. They have a linking error and are using version 1.3.7. They also want an example function/documentation on how to deploy a Swift function.
darShan
3 Sep, 2023, 13:31

I believe the syntax for 1.3x was like this:

TypeScript
func main(req: RequestValue, res: RequestResponse) throws -> RequestResponse {
    let payload = req.payload.isEmpty ? "No payload provided. Add custom data when executing function" : req.payload
    
    let secretKey = req.variables["SECRET_KEY"] ?? "SECRET_KEY variable not found. You can set it in Function settings."

    let randomNumber = Double.random(in: 0...1)

    let trigger = req.variables["APPWRITE_FUNCTION_TRIGGER"]

    return res.json(data: [
        "message": "Hello from Appwrite!",
        "payload": payload,
        "secretKey": secretKey,
        "randomNumber": randomNumber,
        "trigger": trigger,
    ])
}
bariscakmak
3 Sep, 2023, 13:54

I have the following linking error

bariscakmak
3 Sep, 2023, 18:25

@Binyamin do you have any idea? πŸ™

Binyamin
3 Sep, 2023, 18:26

How are you deploying the function?

bariscakmak
3 Sep, 2023, 19:31

I am deploying manually with an entry point

Binyamin
3 Sep, 2023, 19:59

Can you try with appwrite-cli

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more