Wednesday, January 3, 2018

Swift Package Manager (SPM): Error importing library

Leave a Comment

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 Answers

Answers 1

You should add NumberChecker as a dependency to PayBackCodingChallenge:

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

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment