How to import library from same Source Layout?


(Volodymyr Boichentsov) #1

I have next Source Layout

../Sources/Executable/main.swift
../Sources/Executable/classA.swift
../Sources/liba/some1.swift
../Sources/liba/some2.swift

How to include liba to Executable main.swift?

It’s not clear from this file
https://github.com/apple/swift-package-manager/blob/master/Documentation/SourceLayouts.md

I’ve tried just simple import. Does not work.

P.S.: I know how to make dependency lib, but I don’t want it for my current situation.

Best Regards,
Volodymyr Boichentsov


(Volodymyr Boichentsov) #2

I found how. By targets in Package.swift file.

But I have a problem that I have 2 libs and one executable.

../Sources/Executable/main.swift
../Sources/Executable/classA.swift
../Sources/libA/some1.swift
../Sources/libA/some2.swift
../Sources/libB/some3.swift
../Sources/libB/some4.swift

libB should be imported in libA and Executable. But libA can’t see libB.

let package = Package(
    name: "example",
    targets: [ Target( name: "Executable", dependencies: [.Target(name: "libB"), .Target(name: "libA")]),
        Target( name: "libA", dependencies: [.Target(name: "libB")]),
        Target( name: "libB")
    ]
)

Best Regards,
Volodymyr Boichentsov

···

On 29 Dec 2015, at 11:20, Volodymyr Boichentsov <sakristx@gmail.com> wrote:

I have next Source Layout

../Sources/Executable/main.swift
../Sources/Executable/classA.swift
../Sources/liba/some1.swift
../Sources/liba/some2.swift

How to include liba to Executable main.swift?

It’s not clear from this file
https://github.com/apple/swift-package-manager/blob/master/Documentation/SourceLayouts.md

I’ve tried just simple import. Does not work.

P.S.: I know how to make dependency lib, but I don’t want it for my current situation.

Best Regards,
Volodymyr Boichentsov


(Volodymyr Boichentsov) #3

Ok, :slight_smile:

everything works. Just forget add public in front of class/function declaration.

Best Regards,
Volodymyr Boichentsov

···

On 29 Dec 2015, at 12:13, Volodymyr Boichentsov <sakristx@gmail.com> wrote:

I found how. By targets in Package.swift file.

But I have a problem that I have 2 libs and one executable.

../Sources/Executable/main.swift
../Sources/Executable/classA.swift
../Sources/libA/some1.swift
../Sources/libA/some2.swift
../Sources/libB/some3.swift
../Sources/libB/some4.swift

libB should be imported in libA and Executable. But libA can’t see libB.

let package = Package(
    name: "example",
    targets: [ Target( name: "Executable", dependencies: [.Target(name: "libB"), .Target(name: "libA")]),
        Target( name: "libA", dependencies: [.Target(name: "libB")]),
        Target( name: "libB")
    ]
)

Best Regards,
Volodymyr Boichentsov

On 29 Dec 2015, at 11:20, Volodymyr Boichentsov <sakristx@gmail.com <mailto:sakristx@gmail.com>> wrote:

I have next Source Layout

../Sources/Executable/main.swift
../Sources/Executable/classA.swift
../Sources/liba/some1.swift
../Sources/liba/some2.swift

How to include liba to Executable main.swift?

It’s not clear from this file
https://github.com/apple/swift-package-manager/blob/master/Documentation/SourceLayouts.md

I’ve tried just simple import. Does not work.

P.S.: I know how to make dependency lib, but I don’t want it for my current situation.

Best Regards,
Volodymyr Boichentsov