swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.7k stars 1.33k forks source link

make ~/.swiftpm configable #7104

Open Mfk-Xkj opened 10 months ago

Mfk-Xkj commented 10 months ago

Motivation

I compile Swift projects in the Android system using genrule and a shell script. However, in Android T, there are restrictions imposed on genrule, prohibiting access to the ~/ directory when it is executed in a sandbox. On the other hand, during swift build, ~/.swiftpm is a fixed directory that cannot be configured. The combination of these two cases leads to an inability to compile.

Solution

make ~/.swiftpm dir configable

Alternatives considered

AnthonyLatsis commented 10 months ago

@shahmishal Please transfer this to swiftpm.

neonichu commented 10 months ago

I believe this can be done today with --config-path

MaxDesiatov commented 10 months ago

Hi @Mfk-Xkj, would you be able to confirm that the proposed solution is sufficient for this issue to be closed? Thanks!

Mfk-Xkj commented 9 months ago

@MaxDesiatov @neonichu I first delete the ~/.swiftpm directory, and then use the latest version of swiftpm (the latest main branch) to compile the project and add the --config-path parameter. The instructions I use are as follows: swift build --config-path ~/.config_swiftpm_path . After the above instructions are compiled, .swiftpm and .config_swiftpm_path will be created in the ~/ directory. The expectation is to create only the .config_swiftpm_path directory and not the .swiftpm directory. (For the convenience of testing here, in actual use, .config_swiftpm_path will be configured as the path that the androidT sandbox mechanism has access rights to)