I am trying to create a simple makefile to compile swift code.
Here is my Makefile:
NAME = computor
DIRS = ComputorV1/
LIST = Parser.swift
main.swift
SOURCE = $(addprefix $(DIRS), $(LIST))
OBJ = $(patsubst %.swift,%.o,$(SOURCE))
all:
@make $(NAME)
%.o: %.swift
@swiftc -c $< -o $@
$(NAME): $(OBJ)
@swiftc $(OBJ) -o $(NAME)
clean:
@rm -f $(OBJ)
fclean: clean
@rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re debug test
But when I am trying to make it, I always get an error
"ComputorV1/main.swift:10:14: error: cannot find 'Parser' in scope
let parser = Parser()"
main.swift and Parser.swift code are simply
import Foundation
let parser = Parser()
and
final class Parser {
init() {
print("privet")
}
}
Where I did wrong? Maybe there is a some flag option for swiftc to ling one *.swift file with another, but I can't find that
question from:
https://stackoverflow.com/questions/65935672/swift-makefile-with-swiftc 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…