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:
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
ya..these strictly typed languages aren't the most fun to work with because we haven't published these types 😕
I've been able to create a Swift package
You shouldn't be creating a swift package 🧐 do you mean just a function?
The package was created with compile errors
How are you compiling?
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
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
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
I may be approaching all this with the wrong mindset tho
best way to test is to deploy it and test using the Appwrite Console
alright, I'm going through the process right now
to update dependencies, you'd update the Package.swift file: https://github.com/appwrite/functions-starter/blob/main/swift-5.5/Package.swift
Recommended threads
- Urgent help required - Could not resolve...
I upgraded my production environment to 1.8.0 but experienced issues with appwrite running out of worker threads. I downgraded back to 1.6.1 and restored the da...
- In which format should i pass the date?
I have a column with the type `datetime`. So i want to know which format is suitable for passing the date
- Function permissions
In my app I have a CreateUser flow which makes several documents and at the end uses the functions.createExecution() to call a server-side function to create a ...