Menu
CoddyTech
Course

GDScript for Swift Developers

Move from Swift to Godot 4 GDScript through 48 multi-file tasks: typing, value and reference semantics, Unicode, script classes, signals and failure contracts. Build a stock depot and port two Swift programs.

Swift and GDScript side by side

The same program in Swift and in GDScript, from the lessons of this course.

  1. Text and Comments

    Swift print separates arguments with spaces by default and appends a newline. GDScript print concatenates arguments without adding spaces. Supply explicit formatting when porting output. Swift uses braces and // comments; GDScript uses indentation and #. This…

    Swift
    1print("tag",7)2print("# data")
    GDScript
    1extends Node2
    3func _ready() -> void:4	print("tag", 7)5	print("# data")
  2. Branches and Values

    Swift uses braces and else if, with condition ? yes : no for ternary selection. GDScript uses indentation, elif and yes if condition else no. Both evaluate only the selected result. Swift conditions require Bool; keep the intended predicate explicit. Ordered…

    Swift
    1let n = -22print(n<0 ? "west" : "east")
    GDScript
    1extends Node2
    3func _ready() -> void:4	var n: int = -25	print("west" if n < 0 else "east")
  3. Array Operations

    Swift Array is a value type with generic element storage, while GDScript Array is a shared mutable container. Both use zero-based indices, but only GDScript directly accepts negative offsets from the end. Swift popLast returns an Optional for empty handling.…

    Swift
    1var items=[3]2items.append(8)3let removed=items.popLast()!4print(removed,items.count)
    GDScript
    1extends Node2
    3func _ready() -> void:4	var items: Array = [3]5	items.append(8)6	var removed = items.pop_back()7	print("%d %d" % [removed,items.size()])
  4. String Operations

    Swift String has value semantics. Foundation replacingOccurrences returns a new string, and GDScript String.replace also returns a new value. Assign the result when it should replace the original binding. Literal replacement and regular-expression matching…

    Swift
    1import Foundation2let s="a-b-a"3let t=s.replacingOccurrences(of:"-",with:"/")4print(s,t)
    GDScript
    1extends Node2
    3func _ready() -> void:4	var s: String = "a-b-a"5	var t: String = s.replace("-","/")6	print(s," ",t)
  5. Scripts as Classes

    Swift classes have reference semantics while structs have value semantics. GDScript script instances behave like shared objects, so choose the Swift comparison type intentionally. class_name registers a script type and new constructs its instance. Each named…

    Swift
    1final class Token { var text="blue" }
    GDScript
    1class_name DemoToken2extends RefCounted3var text: String = "blue"
  6. Inheritance and Super

    Swift classes inherit from one superclass and can conform to multiple protocols; structs do not inherit classes. GDScript scripts extend one base class, and super invokes inherited behavior. Swift requires override for an overridden method, while GDScript…

    Swift
    1class Base { func label()->String { "base" } }
    GDScript
    1class_name DemoBase2extends RefCounted3func label() -> String:4	return "base"

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Swift developers

Learn GDScript from another language

Frequently asked questions

Who is GDScript for Swift Developers for?

For people who already write Swift and want to learn GDScript. Each lesson starts from Swift you know and shows how GDScript does the same thing, so you skip the beginner basics.

Do I need to know GDScript already?

No. The course starts with your first GDScript program. You need Swift basics: variables, conditions, loops, functions and collections.

How many lessons does GDScript for Swift Developers have?

GDScript for Swift Developers contains 48 interactive lessons you can complete at your own pace.

What does GDScript for Swift Developers cover?

The course is organized into chapters covering: Scripts and Scalar Values, Flow and Functions, Collection Ownership, Text and Callable Values, and more.

Is GDScript for Swift Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start GDScript for Swift Developers for free

Get started