lifecycle hooks/scripts in swift package manager


(Vadim Eisenberg) #1

Hello,

A question - are there any plans to support lifecycle hooks/scripts in
swift package manager ?

According to the community proposal:
https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageManagerCommunityProposal.md#support-for-other-build-systems

"We are considering supporting hooks for the Swift Package Manager to call
out to other build systems, and/or to invoke shell scripts."

This way, swift package manager will become a build automation tool,
similar to npm and maven. npm seems like the most similar tool to swift
package manager. It has "scripts" property -
https://docs.npmjs.com/misc/scripts:

"npm supports the "scripts" property of the package.json script, for the
following scripts: pre/post install, pre/post test. etc."

Using lifecycle scripts can facilitate build automation of swift projects,
for example it can enable code generation. LinuxMain.swift and allTests
fields can be generated automatically during the build process.

Before lifecycle scripts are supported, for build automation swift package
manager has to be used with some build automation tool like make, and the
build automation information is spread between Package.swift and Makefile
files.

Best Regards,
Vadim Eisenberg