<div dir="ltr"><div><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;color:rgb(0,0,0);font-family:Helvetica,arial,sans-serif;font-size:14px;margin-top:0px!important">From what I understand, swiftpm will generate a module with structs of each dep with their version meta data, something like: </p><pre class="" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(45,45,45);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(204,204,204);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;word-wrap:normal"><code class="" style="margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;word-spacing:normal;word-wrap:normal;line-height:1.5"><span class="" style="color:rgb(153,153,153)">// Module PackageVersions</span>
<span class="" style="color:rgb(204,153,205)">public</span> <span class="" style="color:rgb(204,153,205)">struct</span> <span class="" style="color:rgb(204,153,205)">FirstDependency</span> <span class="" style="">{</span>
<span class="" style="color:rgb(153,153,153)">// meta data</span>
<span class="" style="">}</span>
<span class="" style="color:rgb(204,153,205)">public</span> <span class="" style="color:rgb(204,153,205)">struct</span> <span class="" style="color:rgb(204,153,205)">SecondDependency</span> <span class="" style="">{</span>
<span class="" style="color:rgb(153,153,153)">// meta data</span>
<span class="" style="">}</span>
<span class="" style="color:rgb(204,153,205)">public</span> <span class="" style="color:rgb(204,153,205)">struct</span> <span class="" style="color:rgb(204,153,205)">MyPackage</span> <span class="" style="">{</span>
<span class="" style="color:rgb(153,153,153)">// meta data</span>
<span class="" style="">}</span></code></pre><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,sans-serif;font-size:14px">And then somewhere in the package you can dump/use the version info like this:</p><pre class="" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(45,45,45);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(204,204,204);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;word-wrap:normal"><code class="" style="margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;word-spacing:normal;word-wrap:normal;line-height:1.5"><span class="" style="color:rgb(153,153,153)">// Somewhere in MyPackage</span>
<span class="" style="color:rgb(204,153,205)">import</span> <span class="" style="color:rgb(204,153,205)">PackageVersions</span>
<span class="" style="color:rgb(240,141,73)">print</span><span class="" style="">(</span><span class="" style="color:rgb(126,198,153)">"<span class="" style=""><span class="" style="">\(</span><span class="" style="color:rgb(204,153,205)">PackageVersions</span><span class="" style="color:rgb(204,204,204)">.</span><span class="" style="color:rgb(204,153,205)">FirstDependency</span><span class="" style="">)</span></span>"</span><span class="" style="">)</span></code></pre><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,sans-serif;font-size:14px"><br></p><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,sans-serif;font-size:14px">Sounds good but if its only generated for root package what happens when that root package is being used as a dependency somewhere?<br></p></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 4, 2016 at 9:32 PM, Kostiantyn Koval via swift-build-dev <span dir="ltr"><<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello Swift Package Manager contributors<div><br></div><div>We have been working on a <b>PackageVersions </b>feature and we would like to hear your feedback and ideas.</div><div><br></div><div><b>Idea:</b></div><div>We would like to generate Version information about package. The package would be able to import <b>PackageVersions </b>module and use that information.</div><div><br></div><div><b>Use case:</b></div><div>A web server product provides diagnostics when it fails to connect to its port, part of this diagnostics is a dump of the version information for the socket library it uses.<br></div><div>Real uses case - <a href="https://github.com/IBM-Swift/Kitura/pull/352/files" target="_blank">https://github.com/IBM-Swift/Kitura/pull/352/files</a></div><div><br></div><div><b>Format:</b></div><div>- url: a git origin of a package or local path if there is no git (package not published yet),</div><div>- package version</div><div>- version string representation</div><div>- SHA of of a commit made after checked <span style="font-family:Menlo;font-size:11px">version</span></div><div>- modified, are there any uncommitted changes to the package.</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(180,38,26)"><span style="color:#0433ff">public</span><span style="color:#000000"> </span><span style="color:#0433ff">let</span><span style="color:#000000"> url: </span><span style="color:#3495af">String</span><span style="color:#000000"> = </span>"<a href="https://github.com/apple/swift-package-manager.git" target="_blank">https://github.com/apple/swift-package-manager.git</a>"</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#0433ff">public</span><span> </span><span style="color:#0433ff">let</span><span> version: (major: </span><span style="color:#3495af">Int</span><span>, minor: </span><span style="color:#3495af">Int</span><span>, patch: </span><span style="color:#3495af">Int</span><span>, prereleaseIdentifiers: [</span><span style="color:#3495af">String</span><span>], buildMetadata: </span><span style="color:#3495af">String</span><span>?) = (0, 2, 2, [], </span><span style="color:#0433ff">nil</span><span>)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#0433ff">public</span><span> </span><span style="color:#0433ff">let</span><span> versionString: </span><span style="color:#3495af">String</span><span> = </span><span style="color:#b4261a">"0.2.2"</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#0433ff">public</span><span> </span><span style="color:#0433ff">let</span><span> sha: </span><span style="color:#3495af">String</span><span>? = </span><span style="color:#b4261a">"</span><span style="color:#b4261a">154cf23f74efa6c596bd25f4caa5a3bd20c78c4f"</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#0433ff">public</span><span> </span><span style="color:#0433ff">let</span><span> modified: </span><span style="color:#3495af">Bool</span><span> = </span><span style="color:#0433ff">true </span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div>Concerns and questions:</div><div><div>- "We think that this should only be generated for the root-package, the rationale here is that we don't want packages writing code like if<b> version.major > 2</b> as this should be a compile time language feature and Swift core are already on board with this idea.”</div></div><div>- Should a package have access to own dependencies VersionData information ?</div><div> </div><div>You can find more information here.</div><div><a href="https://github.com/apple/swift-package-manager/pull/122" target="_blank">https://github.com/apple/swift-package-manager/pull/122</a></div><div><a href="https://bugs.swift.org/browse/SR-473" target="_blank">https://bugs.swift.org/browse/SR-473</a></div><div><br></div><div>Looking forward for your feedback</div><span class="HOEnZb"><font color="#888888"><div>- Kostiantyn</div><div><br></div><div><br></div><div><br></div><div><br></div>
</font></span></div><br>_______________________________________________<br>
swift-build-dev mailing list<br>
<a href="mailto:swift-build-dev@swift.org">swift-build-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-build-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Ankit<br><br></div>
</div>