Accessing types in a "parent" module


(Paul Young) #1

Given the following directory structure:

Sources/A.swift
Sources/B/B.swift

When running `swift build`, types defined in A.swift are considered to be undeclared in B.swift

Is there currently a way to resolve this without moving B.swift into the same directory as A.swift?


(Daniel Dunbar) #2

This layout should actually just be an error. We currently expect a layout like

  Sources/A/A.swift
  Sources/B/B.swift
  (two targets)

or

  Sources/A.swift
  Sources/B.swift
  (one target)

If you are trying to create a single target with multiple source files in a directory hierarchy, you should move to

  Sources/TargetName/A.swift
  Sources/TargetName/B/B.swift

Can you file a bug to diagnose this (and probably improve docs around it)?

- Daniel

···

On Dec 4, 2015, at 5:48 PM, Paul Young <paulyoungonline@gmail.com> wrote:

Given the following directory structure:

Sources/A.swift
Sources/B/B.swift

When running `swift build`, types defined in A.swift are considered to be undeclared in B.swift

Is there currently a way to resolve this without moving B.swift into the same directory as A.swift?

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev


(Max Howell) #3

We could support this layout. Though it may make it easy to violate the principle of least surprise when moving sources around later in a project's life. So indeed. Should either error or be supported, not half work.

···

On Dec 4, 2015, at 5:51 PM, Daniel Dunbar <daniel_dunbar@apple.com> wrote:

This layout should actually just be an error. We currently expect a layout like

  Sources/A/A.swift
  Sources/B/B.swift
  (two targets)

or

  Sources/A.swift
  Sources/B.swift
  (one target)

If you are trying to create a single target with multiple source files in a directory hierarchy, you should move to

  Sources/TargetName/A.swift
  Sources/TargetName/B/B.swift

Can you file a bug to diagnose this (and probably improve docs around it)?

- Daniel

On Dec 4, 2015, at 5:48 PM, Paul Young <paulyoungonline@gmail.com> wrote:

Given the following directory structure:

Sources/A.swift
Sources/B/B.swift

When running `swift build`, types defined in A.swift are considered to be undeclared in B.swift

Is there currently a way to resolve this without moving B.swift into the same directory as A.swift?

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev


(Paul Young) #4

I created https://bugs.swift.org/browse/SR-66.

Thanks for the help!

···

On Sat, Dec 5, 2015 at 2:09 AM, Max Howell <max.howell@apple.com> wrote:

We could support this layout. Though it may make it easy to violate the principle of least surprise when moving sources around later in a project's life. So indeed. Should either error or be supported, not half work.

On Dec 4, 2015, at 5:51 PM, Daniel Dunbar <daniel_dunbar@apple.com> wrote:

This layout should actually just be an error. We currently expect a layout like

  Sources/A/A.swift
  Sources/B/B.swift
  (two targets)

or

  Sources/A.swift
  Sources/B.swift
  (one target)

If you are trying to create a single target with multiple source files in a directory hierarchy, you should move to

  Sources/TargetName/A.swift
  Sources/TargetName/B/B.swift

Can you file a bug to diagnose this (and probably improve docs around it)?

- Daniel

On Dec 4, 2015, at 5:48 PM, Paul Young <paulyoungonline@gmail.com> wrote:

Given the following directory structure:

Sources/A.swift
Sources/B/B.swift

When running `swift build`, types defined in A.swift are considered to be undeclared in B.swift

Is there currently a way to resolve this without moving B.swift into the same directory as A.swift?

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev