From 4d933dcf8dd3415532a6af9d2d283630bc3bdcc2 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Wed, 21 Feb 2024 08:17:55 +0100 Subject: [PATCH] Hide the following holder from Swift SPM: src, tests, scripts, examples by using empty dummy Package.swift hack. --- BuildProcess.md | 23 ----------------------- examples/Package.swift | 13 +++++++++++++ scripts/Package.swift | 13 +++++++++++++ src/Package.swift | 13 +++++++++++++ tests/Package.swift | 13 +++++++++++++ 5 files changed, 52 insertions(+), 23 deletions(-) delete mode 100644 BuildProcess.md create mode 100644 examples/Package.swift create mode 100644 scripts/Package.swift create mode 100644 src/Package.swift create mode 100644 tests/Package.swift diff --git a/BuildProcess.md b/BuildProcess.md deleted file mode 100644 index 65954093d..000000000 --- a/BuildProcess.md +++ /dev/null @@ -1,23 +0,0 @@ -# Swift - -## Build script -Ah nevermind the build script in [uniffi-starter/../build-ios.sh](https://github.com/ianthetechie/uniffi-starter/blob/main/rust/build-ios.sh) already contained code to update checksum. - -[Blog post about automating checksum update in Package.swift](https://blog.eidinger.info/distribute-binary-frameworks-in-swift-packages-and-how-to-automate-the-process) and here is a [Github Gist which looks nice](https://gist.github.com/litoarias/23bca22bb6161625484b4fb8cd245fe8) - -This would allow for us to use a similar pattern like [`ferrostar`'s `Package.swift`](https://github.com/stadiamaps/ferrostar/blob/main/Package.swift) which has a nice `useLocalFramework` setup, and when NOT local uses SPM's setup: - -```swift -let releaseTag = "0.1.0" -let releaseChecksum = "deadbeefdeadbeef..." -.binaryTarget( - name: "SargonCoreRS", - url: "https://github.com/radixdlt/sargon/releases/download/\(releaseTag)/libsargon-rs.xcframework.zip", - checksum: releaseChecksum -) -``` - -The advantage of this over what we are [doing today in Swift-Engine-Toolkit](https://github.com/radixdlt/swift-engine-toolkit/blob/main/Package.swift#L23C3-L23C78) is that the .xcframework files need not be part of Git! They can be put in Github! This will allow for much much faster git clone! - -# Android -[See `uniffi-starter`](https://github.com/ianthetechie/uniffi-starter) (also contains Swift, but `@IanTheTech` has also created `ferrostar` which contains more advanced Swift setup). \ No newline at end of file diff --git a/examples/Package.swift b/examples/Package.swift new file mode 100644 index 000000000..9a7fcd3ba --- /dev/null +++ b/examples/Package.swift @@ -0,0 +1,13 @@ +// swift-tools-version:5.9 + +// This is a HACKY workaround the fact that SPM does not allow for Package level exclusion +// of files/folders. SPM actually HAD support for it but it was removed in 2017, in PR +// https://github.com/apple/swift-package-manager/commit/cb69accf41da55386f9703308958aa49ca2a4c5f +// +// So instead we have to add an empty dummy Package.swift to each folder we wanna hide, as per: +// See: https://github.com/apple/swift-package-manager/issues/4460#issuecomment-1475025748 +// And: https://stackoverflow.com/questions/69382302/swift-package-how-to-exclude-files-in-root-git-directory-from-the-actual-swift/70990534#70990534 +// And: https://github.com/tuist/tuist/pull/2058 +import PackageDescription + +let package = Package() \ No newline at end of file diff --git a/scripts/Package.swift b/scripts/Package.swift new file mode 100644 index 000000000..9a7fcd3ba --- /dev/null +++ b/scripts/Package.swift @@ -0,0 +1,13 @@ +// swift-tools-version:5.9 + +// This is a HACKY workaround the fact that SPM does not allow for Package level exclusion +// of files/folders. SPM actually HAD support for it but it was removed in 2017, in PR +// https://github.com/apple/swift-package-manager/commit/cb69accf41da55386f9703308958aa49ca2a4c5f +// +// So instead we have to add an empty dummy Package.swift to each folder we wanna hide, as per: +// See: https://github.com/apple/swift-package-manager/issues/4460#issuecomment-1475025748 +// And: https://stackoverflow.com/questions/69382302/swift-package-how-to-exclude-files-in-root-git-directory-from-the-actual-swift/70990534#70990534 +// And: https://github.com/tuist/tuist/pull/2058 +import PackageDescription + +let package = Package() \ No newline at end of file diff --git a/src/Package.swift b/src/Package.swift new file mode 100644 index 000000000..9a7fcd3ba --- /dev/null +++ b/src/Package.swift @@ -0,0 +1,13 @@ +// swift-tools-version:5.9 + +// This is a HACKY workaround the fact that SPM does not allow for Package level exclusion +// of files/folders. SPM actually HAD support for it but it was removed in 2017, in PR +// https://github.com/apple/swift-package-manager/commit/cb69accf41da55386f9703308958aa49ca2a4c5f +// +// So instead we have to add an empty dummy Package.swift to each folder we wanna hide, as per: +// See: https://github.com/apple/swift-package-manager/issues/4460#issuecomment-1475025748 +// And: https://stackoverflow.com/questions/69382302/swift-package-how-to-exclude-files-in-root-git-directory-from-the-actual-swift/70990534#70990534 +// And: https://github.com/tuist/tuist/pull/2058 +import PackageDescription + +let package = Package() \ No newline at end of file diff --git a/tests/Package.swift b/tests/Package.swift new file mode 100644 index 000000000..9a7fcd3ba --- /dev/null +++ b/tests/Package.swift @@ -0,0 +1,13 @@ +// swift-tools-version:5.9 + +// This is a HACKY workaround the fact that SPM does not allow for Package level exclusion +// of files/folders. SPM actually HAD support for it but it was removed in 2017, in PR +// https://github.com/apple/swift-package-manager/commit/cb69accf41da55386f9703308958aa49ca2a4c5f +// +// So instead we have to add an empty dummy Package.swift to each folder we wanna hide, as per: +// See: https://github.com/apple/swift-package-manager/issues/4460#issuecomment-1475025748 +// And: https://stackoverflow.com/questions/69382302/swift-package-how-to-exclude-files-in-root-git-directory-from-the-actual-swift/70990534#70990534 +// And: https://github.com/tuist/tuist/pull/2058 +import PackageDescription + +let package = Package() \ No newline at end of file