I am applying for a $5k Developer Grant.
Please review my application and discuss! See DFINITY’s directions for becoming a registered reviewer here. They will be collected by DFINITY. When one week passes, DFINITY will release them and they will appear as a new section on this post.
Please review my application and discuss! If you would like to submit an official review, then please use the links below to register, see the rubric, and submit a review.
I’m looking forward to everyone’s input!
Reviewer Registration | Rubric for Evaluating | Submit a Review
MY APPLICATION:
REVIEWS:
We are back with the IcpKit.Swift for iOS!
This time we will be enhancing it with a command line tool that can :
- Parse a Candid service description file (
.did
as described here : 2.4 Introduction to Candid | Internet Computer) - Generate Swift classes for each type in the file
- Generate Swift methods for each service function
- Generate Swift documentation for each class/method from the comments in the original .did file
The generated Swift classes can be directly used with the IcpKit.Candid implementation for interacting with a given canister without writing any of the encoding/serialisation code.
The generated Swift methods can be directly called in order to interact with the given canister.
This will further facilitate the writing of iOS mobile apps that can directly interact with any canister of the Internet Computer.
Here are some examples :
type Auth = variant { FreeRpc; PriorityRpc; RegisterProvider; Manage };
will generate a Auth.swift
file with these contents :
enum Auth {
case FreeRpc
case PriorityRpc
case RegisterProvider
case Manage
static var candidType: CandidType {
.keyedContainer(.variant, [
CandidKeyedItem("FreeRpc", .null),
CandidKeyedItem("PriorityRpc", .null),
CandidKeyedItem("RegisterProvider", .null),
CandidKeyedItem("Manage", .null),
])
}
var candidValue: CandidValue {
.variant(Self.candidType, self.rawValue)
}
}
The candidValue
and candidType
properties allow this to be easily serialised and encoded for sending to a canister.
Similarly, services
can be parsed :
service SomeService: {
authorize : (principal, Auth) -> (success : bool);
}
will generate this Swift code
struct AuthorizeResponse {
let success: Bool
}
class SomeService {
func authorize(CandidPrincipal, Auth) -> AuthorizeResponse {
...
}
}
We can simply call the SomeService.authorize(_,_)
method using the CandidPrincipal
(pre-built with IcpKit.Swift) and Auth
(generated from the .did
) structs. The implementation of this method makes the actual call/query to the canister and returns the decoded response in an easy to use AuthorizeResponse
struct.