R.swift
R.swift copied to clipboard
Readme: suggest SPM as default install method
This PR adds install instructions for using R.Swift with SPM. This is preferable for those starting new projects and wanting to avoid cocoapods given the now-widespread support for SPM.
I changed it to be the recommended method, however opinions may differ... Please feel free to just add it as another option if that's preferable 😄
Thanks for this PR!
I haven't tried this yet, but reading the PR, it seems interesting to use SPM in this way. It does seem like quite a few steps to get everything working, but it's nice to not depend on CocoaPods anymore.
I'll have a more detailed look later on.
I opted to keep the instructions very verbose assuming it’s all new to people, but it boils down to very quick steps:
- Create a Package.swift file
- Make Run Script
- Add R.swift.Library and generated file to target
Interesting to use SPM in this way, think we need to write it in a bit more compact way and not make it the default yet.
Also when we add this option think the readme needs a bit of restructuring or foldable parts to keep it readable.
Lets fix those points then merge this.
@mac-cain13 I am not sure where to ask this.. important R.swift with SPM is fine, some people wrote about how to then use it in your Xcodeproj. However, I don't seem to find anyone who's written of using R.swift "outside an Xcode project". I am developing a swift package "Kit" that internally uses R.swift but I don't have a way to run R.swift for its sources without generating the Xcode project and adding a script phase. Is there any way I could do so without generating the Xcode project ?
I don't like the BuildTools step. It is annoying to create folders on root project. This build script may be better.
cd $TEMP_DIR
mkdir RSwiftBinary
cd RSwiftBinary
echo `pwd`
echo "// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: \"RSwiftBinary\",
platforms: [.macOS(.v10_11)],
dependencies: [
.package(url: \"https://github.com/mac-cain13/R.swift\", from: \"5.4.0\"),
]
)
" > Package.swift
/usr/bin/xcrun --sdk macosx swift run -c release rswift generate "$SRCROOT/R.generated.swift"
Another option is that. Content of the Package.swift can be put on a folder on the library project. And we can run the script below. This method allows us to use always use correct R.swift and R.swift.Library library together.
cd "${BUILD_DIR%Build/*}/SourcePackages/checkouts/R.swift.Library/BuildTools/"
/usr/bin/xcrun --sdk macosx swift run -c release rswift generate "$SRCROOT/R.generated.swift"