Back

Missing `RuntimeContext` Object for Functions

  • 0
  • General
  • Functions
Kilo Loco
7 Feb, 2024, 04:20

tl;dr I'm having build errors in my Swift function because undefined RuntimeContext and RuntimeOutput.

I'm in the process of trying to launch a self hosted Swift function. I've been able to create a Swift package by running the following command in the terminal: appwrite init function. The package was created with compile errors which may be related to changes between Swift language versions. I attempted to get a basic working project by manually creating a hello world Swift package without using anything related to Appwrite and this worked. I then translated the changes to the Appwrite generated Swift package and this worked as well. The problem happened when trying to use appwrite/sdk-for-swift. I get the following errors:

TypeScript
Cannot find type 'RuntimeContext' in scope
Cannot find type 'RuntimeOutput' in scope

This issue would generally come up if the dependencies are not properly installed or if you forget to import them. However, I did both of these things and can run print("hello world") with Appwrite and AppwriteModels imported, signifying that Appwrite has been successfully added as a dependency.

I then started digging into the source files for the Appwrite SDK and can't find any reference to either RuntimeContext or RuntimeOutput. If these files failed to be generated, it could cause this behavior. I also checked https://github.com/appwrite/sdk-for-kotlin since it is a very similar language to Swift and couldn't find references to either of those two objects either.

I'll include some images of how I also tried searching in GitHub as well.

Both the generated code and the Appwrite docs https://appwrite.io/docs/products/functions/development#life-cycle are referencing these objects in both languages but are causing compile errors.

If this isn't a bug caused by sdk-generator then I must be missing something because there are instances of people being able to get Kotlin functions to work: https://dev.to/appwrite/cloud-functions-using-the-new-kotlin-runtime-3ejo

I'm using Appwrite API Version: 1.4.12 but I also checked back through the tags down to 0.3.0 and I dont see those objects so I must be doing something wrong, but I'm only trying to get the template from the docs working right now

TL;DR
Summary: The developer is experiencing build errors in their Swift function due to undefined `RuntimeContext` and `RuntimeOutput` objects. They have created a Swift package using the `appwrite init function` command but encountered compile errors when trying to use `appwrite/sdk-for-swift`. They have checked the Appwrite SDK source files and the Appwrite documentation, but could not find any references to these objects. They suspect that these files may have failed to generate or they may be missing something. They are seeking assistance in resolving this issue. Solution: It is suggested to ensure that the dependencies are properly installed and imported. If the
Steven
7 Feb, 2024, 04:47

ya..these strictly typed languages aren't the most fun to work with because we haven't published these types 😕

Steven
7 Feb, 2024, 04:48

I've been able to create a Swift package

You shouldn't be creating a swift package 🧐 do you mean just a function?

Steven
7 Feb, 2024, 04:49

The package was created with compile errors

How are you compiling?

Kilo Loco
7 Feb, 2024, 04:50

So I am creating a swift package, but that's also the same result from running appwrite function init I was following one of the docs but i think it was geared towards a different language

Kilo Loco
7 Feb, 2024, 04:50

I could go the route of trying to just create a file and uploading it, but I was hoping to be able to test the code prior to deploying the function

Kilo Loco
7 Feb, 2024, 04:51

Maybe the types I'm missing are available at that time somehow. But then I fail to understand how to change the dependencies of my function

Kilo Loco
7 Feb, 2024, 04:52

I may be approaching all this with the wrong mindset tho

Steven
7 Feb, 2024, 04:58

best way to test is to deploy it and test using the Appwrite Console

Kilo Loco
7 Feb, 2024, 04:58

alright, I'm going through the process right now

Steven
7 Feb, 2024, 04:59

to update dependencies, you'd update the Package.swift file: https://github.com/appwrite/functions-starter/blob/main/swift-5.5/Package.swift

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