Swift | File Inaccessible

Problem description:
I am unable to access files in the workspace that are in a Folder with swift

Used Code:

var mySpell: Spell? = nil

mySpell = Spell(Spell: { Targets, Params in
    return Params

print(type(of: mySpell!.spell))

Expected behavior:

  1. Create Spell optional with a nil value
  2. Set Create a configured Spell object
  3. Command Parsed Properly and “Spell” printed

Actual behavior:
Error Logs:

  main.swift:1:14: error: cannot find type 'Spell' in scope
var mySpell: Spell? = nil
main.swift:3:11: error: cannot find 'Spell' in scope
mySpell = Spell(Spell: { Targets, Params in
main.swift:7:1: error: type of expression is ambiguous without more context
print(type(of: mySpell!.spell))

Steps to reproduce:
get your main file then place another file with any code in a folder and then try and use said code in main

Bug appears at this link:

Currently Irrelevant to Bug
Reasonable Type: Program Environment Bug

Hey @MinerMinerMods!

It looks like this is an issue with your code. I believe you need to create DnDModCore as a module in order to import the Spell class from it. This is because “Spell” is in another file and when you attempt to use it in your main.swift file, Swift doesn’t know where “Spell” comes from.

1 Like

I fixed this by adding

compile = "swiftc -o main main.swift ./<my_module_folder>/*.swift"
run = "./main" 

to the .replitfile

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.