CreateAPI icon indicating copy to clipboard operation
CreateAPI copied to clipboard

Please allow for local packages to be specified for dependencies.

Open catshow opened this issue 2 years ago • 3 comments

We do not allow network access during builds so we must sometimes use local package dependencies in the Packages.swift file.

These can be added like this in the Packages.swift file .package(name: "my-api-client", path: "../my-api-client")

This could be accomplished by using a file url, then just using the lastPathComponent as the name, and the url.path for the path.

The version requirement would then be excluded.

catshow avatar Oct 11 '22 22:10 catshow

Thanks, yep this certainly would be a great addition. The one question that I still had was around how relative file paths in the configuration file should be handled.

If you define a local package in the config, how should the resolution work? Or should the string value defined in the config just be passed directly into the generated Package.swift?

liamnichols avatar Oct 12 '22 09:10 liamnichols

I looked into file URLs and I believe that they don't allow relative file paths due to security concerns.

The following is how I would like to specify it. I would think that you would just include the path as it is defined in the config, since the user knows where they are going to locate the generated code. I am not a yaml expert so I am not sure if quoting is required.

# this would map out to: .package(path: "../my-api-client")
package:
  dependencies:
  - path: ../my-api-client
    products:
    - MyApiClient

# or if an optional name is specified
# this would map out to: .package(name: "my-api-client-name", path: "../my-api-client")
package:
  dependencies:
  - path: ../my-api-client
  - name: my-api-client-name
    products:
    - MyApiClient

catshow avatar Oct 12 '22 16:10 catshow

Would require a bit of refactoring the existing PackageDeclaration but should be pretty straightforward.

LePips avatar Oct 12 '22 17:10 LePips