5

I'm facing problems while importing a library I created.

This is the Package.swift of my executable:

import PackageDescription

let package = Package(
  name: "PayBackCodingChallenge",
  dependencies: [
    .package(url: "../NumberChecker", from: "1.0.0"),
  ],
  targets: [
    .target(
      name: "PayBackCodingChallenge",
      dependencies: []),
  ]
)

When I try to import NumberChecker in my main.swift I get the following message: No such module 'NumberChecker':

import NumberChecker

let arguments = CommandLine.arguments

if arguments.count != 3 {
  print("USAGE: PayBackCodingChallenge [data] [target]")
  print("  data: File containing list of numbers ")
  print("  target: Target number")
} else {
  let data = arguments[1]
  let target = arguments[2]
  print(data + " " + target)
}

My NumberChecker library is located in a directory at the same level as PayBackCodingChallenge and compiles correctly. What could be the problem?

Thanks in advance!

1 Answer 1

3
+50

You should add NumberChecker as a dependency to PayBackCodingChallenge:

... targets: [ .target( name: "PayBackCodingChallenge", dependencies: ["NumberChecker"]), ] ...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.