Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6447] swift build from command line fails #4912

Closed
swift-ci opened this issue Nov 21, 2017 · 1 comment
Closed

[SR-6447] swift build from command line fails #4912

swift-ci opened this issue Nov 21, 2017 · 1 comment
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-6447
Radar None
Original Reporter fishpesce (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 23dd1cf8e45237f5f3ecaacdb27e97e8

Issue Description:

swift build (Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13502)) fails on macos High Sierra from the command line with the following error:

Compile Swift Module 'EnergyFinanceAnalysis' (1 sources)
Compile Swift Module 'OffshoreWindAnalysis' (2 sources)
/Users/greg/Dropbox/common_files/Programming/Swift/commercial/EnergyAnalysis/OffshoreWindAnalysis/Sources/OffshoreWindAnalysis/OffshoreWindAnalysis.swift:32:25: error: use of undeclared type 'EnergyFinanceAnalysis'
var energyAnalysis: EnergyFinanceAnalysis
^
/Users/greg/Dropbox/common_files/Programming/Swift/commercial/EnergyAnalysis/OffshoreWindAnalysis/Sources/OffshoreWindAnalysis/OffshoreWindAnalysis.swift:32:25: note: cannot use module 'EnergyFinanceAnalysis' as a type
var energyAnalysis: EnergyFinanceAnalysis
^
(with more of a similar nature)

I have a main project OffshoreWindAnalysis which depends on EnergyFinanceAnalysis, a library module. Swift appears to find and compile that module located in a parallel directory, but then swift does not appear to use it.

I have the Package.swift for the main project:

// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "OffshoreWindAnalysis",
products: [
.executable(name: "OffshoreWindAnalysis",
targets: ["OffshoreWindAnalysis"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "../EnergyFinanceAnalysis", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "OffshoreWindAnalysis",
dependencies: ["EnergyFinanceAnalysis"]),
.testTarget(
name: "OffshoreWindAnalysisTests",
dependencies: ["OffshoreWindAnalysis"]),
]
)

I have the following Package.swift for the library module:

// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "EnergyFinanceAnalysis",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "EnergyFinanceAnalysis",
targets: ["EnergyFinanceAnalysis"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "../CIRRCalc", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "EnergyFinanceAnalysis",
dependencies: ["CIRRCalc"]),
.testTarget(
name: "EnergyFinanceAnalysisTests",
dependencies: ["EnergyFinanceAnalysis"]),
]
)

I import EnergyFinanceAnalysis in the appropriate source file for the main project where it is used.

If I do swift package generate-xcodeproj and then try to compile it also fails. In xcode I can remedy it by having the included dependency source file for EnergyFinanceAnalysis added to the target for OffshoreWindAnalysis. But I should be able to do this from the command line completely.

@swift-ci
Copy link
Contributor Author

Comment by Greg Jaczko (JIRA)

I just recognized the problem. I was not declaring the relevant classes, structures etc as public. I did not realize the default was for internal.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant