hey folks! i'm new to swift (but not to programming). i'm going through the hacking with macos book (appkit edition). i'm deeply unsatisfied with xcode as an ide and an editor, so i decided to go a familiar route of using vim and building projects on the command line. i created a new command line swift project in xcode (because i don't know how to create them on the command line yet), then edited the ./lel/main.swift (lel is the name of my project) to make it look like this
//
// main.swift
// lel
//
// Created by Based THO on 5/16/23.
//
import Foundation
class Album {
var name: String
init(name: String) {
self.name = name
}
func getPerformance() -> String {
return "The album \(name) sold lots"
}
}
class StudioAlbum: Album {
var studio: String
init(name: String, studio: String) {
self.studio = studio
super.init(name: name)
}
override func getPerformance() -> String {
return "The studio album \(name) sold lots"
}
}
class LiveAlbum: Album {
var location: String
init(name: String, location: String) {
self.location = location
super.init(name: name)
}
override func getPerformance() -> String {
return "The live album \(name) sold lots"
}
}
func main() {
var taylorSwift = StudioAlbum(name: "Taylor Swift", studio: "The Castles Studios")
var fearless = StudioAlbum(name: "Speak Now", studio: "Aimeeland Studio")
var iTunesLive = LiveAlbum(name: "iTunes Live from Soho", location: "New York")
var allAlbums: [Album] = [taylorSwift, fearless, iTunesLive]
for album in allAlbums {
print(album.getPerformance())
}
print("lelele")
}
then i issue xcodebuild
from the root project folder, it spits out a bunch of text along with "build succeeded" at the end, and then i do ./build/Release/lel
and my problem is that it doesn't output anything! what gives?
p.s.: i just discovered that the same code doesn't even work in a playground, what am i doing wrong??