@@ -71,6 +71,8 @@ struct Init: SwiftlyCommand {
7171
7272 // Give the user the prompt and the choice to abort at this point.
7373 if !assumeYes {
74+ let toolchainsDir = Swiftly . currentPlatform. swiftlyToolchainsDir ( ctx)
75+
7476 var msg = """
7577 Welcome to swiftly, the Swift toolchain manager for Linux and macOS!
7678
@@ -82,12 +84,20 @@ struct Init: SwiftlyCommand {
8284
8385 \( Swiftly . currentPlatform. swiftlyHomeDir ( ctx) ) - Directory for configuration files
8486 \( Swiftly . currentPlatform. swiftlyBinDir ( ctx) ) - Links to the binaries of the active toolchain
85- \( Swiftly . currentPlatform . swiftlyToolchainsDir ( ctx ) ) - Directory hosting installed toolchains
87+ \( toolchainsDir ) - Directory hosting installed toolchains
8688
8789 These locations can be changed by setting the environment variables
88- SWIFTLY_HOME_DIR and SWIFTLY_BIN_DIR before running 'swiftly init' again.
90+ SWIFTLY_HOME_DIR, SWIFTLY_BIN_DIR, and SWIFTLY_TOOLCHAINS_DIR before running 'swiftly init' again.
8991
9092 """
93+ #if os(macOS)
94+ if toolchainsDir != homeDir / " Library/Developer/Toolchains " {
95+ msg += """
96+
97+ NOTE: The toolchains are not being installed in a standard macOS location, so Xcode may not be able to find them.
98+ """
99+ }
100+ #endif
91101 if !skipInstall {
92102 msg += """
93103
@@ -189,6 +199,7 @@ struct Init: SwiftlyCommand {
189199 env = """
190200 set -x SWIFTLY_HOME_DIR " \( Swiftly . currentPlatform. swiftlyHomeDir ( ctx) ) "
191201 set -x SWIFTLY_BIN_DIR " \( Swiftly . currentPlatform. swiftlyBinDir ( ctx) ) "
202+ set -x SWIFTLY_TOOLCHAINS_DIR " \( Swiftly . currentPlatform. swiftlyToolchainsDir ( ctx) ) "
192203 if not contains " $SWIFTLY_BIN_DIR " $PATH
193204 set -x PATH " $SWIFTLY_BIN_DIR " $PATH
194205 end
@@ -198,6 +209,7 @@ struct Init: SwiftlyCommand {
198209 env = """
199210 export SWIFTLY_HOME_DIR= " \( Swiftly . currentPlatform. swiftlyHomeDir ( ctx) ) "
200211 export SWIFTLY_BIN_DIR= " \( Swiftly . currentPlatform. swiftlyBinDir ( ctx) ) "
212+ export SWIFTLY_TOOLCHAINS_DIR= " \( Swiftly . currentPlatform. swiftlyToolchainsDir ( ctx) ) "
201213 if [[ " :$PATH: " != * " :$SWIFTLY_BIN_DIR: " * ]]; then
202214 export PATH= " $SWIFTLY_BIN_DIR:$PATH "
203215 fi
@@ -249,50 +261,50 @@ struct Init: SwiftlyCommand {
249261 addEnvToProfile = true
250262 }
251263
252- var postInstall : String ?
253- var pathChanged = false
254-
255- if !skipInstall {
256- let latestVersion = try await Install . resolve ( ctx, config: config, selector: ToolchainSelector . latest)
257- ( postInstall, pathChanged) = try await Install . execute ( ctx, version: latestVersion, & config, useInstalledToolchain: true , verifySignature: true , verbose: verbose, assumeYes: assumeYes)
258- }
259-
260264 if addEnvToProfile {
261265 try Data ( sourceLine. utf8) . append ( to: profileHome)
266+ }
267+ }
262268
263- if !quietShellFollowup {
264- await ctx. print ( """
265- To begin using installed swiftly from your current shell, first run the following command:
266- \( sourceLine)
269+ var postInstall : String ?
270+ var pathChanged = false
267271
268- """ )
269- }
270- }
272+ if !skipInstall {
273+ let latestVersion = try await Install . resolve ( ctx, config: config, selector: ToolchainSelector . latest)
274+ ( postInstall, pathChanged) = try await Install . execute ( ctx, version: latestVersion, & config, useInstalledToolchain: true , verifySignature: true , verbose: verbose, assumeYes: assumeYes)
275+ }
276+
277+ if !quietShellFollowup {
278+ await ctx. print ( """
279+ To begin using installed swiftly from your current shell, first run the following command:
280+ \( sourceLine)
271281
272- // Fish doesn't have path caching, so this might only be needed for bash/zsh
273- if pathChanged && !quietShellFollowup && !shell. hasSuffix ( " fish " ) {
274- await ctx. print ( """
275- Your shell caches items on your path for better performance. Swiftly has added
276- items to your path that may not get picked up right away. You can update your
277- shell's environment by running
282+ """ )
283+ }
278284
279- hash -r
285+ // Fish doesn't have path caching, so this might only be needed for bash/zsh
286+ if pathChanged && !quietShellFollowup && !shell. hasSuffix ( " fish " ) {
287+ await ctx. print ( """
288+ Your shell caches items on your path for better performance. Swiftly has added
289+ items to your path that may not get picked up right away. You can update your
290+ shell's environment by running
280291
281- or restarting your shell.
292+ hash -r
282293
283- """ )
284- }
294+ or restarting your shell.
285295
286- if let postInstall {
287- await ctx. print ( """
288- There are some dependencies that should be installed before using this toolchain.
289- You can run the following script as the system administrator (e.g. root) to prepare
290- your system:
296+ """ )
297+ }
291298
292- \( postInstall)
299+ if let postInstall {
300+ await ctx. print ( """
301+ There are some dependencies that should be installed before using this toolchain.
302+ You can run the following script as the system administrator (e.g. root) to prepare
303+ your system:
293304
294- """ )
295- }
305+ \( postInstall)
306+
307+ """ )
296308 }
297309 }
298310}
0 commit comments