-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add preliminary support for Swift Package Manager #395
Conversation
@knothed Thanks for this proposal! While this method will also work if a resource gets updated, it won't work when entire resource files get added / removed. But as a workaround until Swift 5.3 arrives, this is still a great way to use SwiftMessages via SPM! 🎉 |
This is in 8.0.2. Sorry for taking so long. |
@knothed initial implementation of full SPM support is on the |
The script provided by @knothed fails for archive builds because the build directory structure is different. Here's an alternate script that should work universally. Just change if [[ "${BUILD_DIR}" =~ (^.*DerivedData\/[^\/]*\/) ]]
then
source="${BASH_REMATCH[1]}SourcePackages/checkouts/SwiftMessages/SwiftMessages/Resources"
else
echo "Unexpected build directory structure ${BUILD_DIR}"
exit 1
fi
destination="${PROJECT_DIR}/SwiftMessagesResources"
rsync -r "${source}" "${destination}/" |
Since SPM came around, people wanted SwiftMessages to be compatible with SPM (#330, #362, #387). Sadly, SPM currently has no support for resource bundling – however, with Swift 5.3, this will finally change.
This pull request accomplishes two things:
Package.swift
and fixing SPM build errors.How To Use SwiftMessages With SPM?
If you really want to include SwiftMessages via SPM and not via Carthage/CocoaPods, there is a simple way. Swift Package Manager can be used to include and build the Swift sources; then, the resources must manually be added to your main target – this works without any problems.
This solution is natural and has a similar feel to SPM as it handles resource updating automatically.
You can set it up in three steps:
8.0.2
release)destination
in below build script and add it as a build phase if you want resource auto-updating (i.e. when a new release of SwiftMessages changes some of the resources, they are also automatically updated in your project – no manual work for you!)Only change
Path_To_SwiftMessages_Resource_Folder
, the rest should stay as is.Thats the closest we can get to SPM until Swift 5.3 is released. Again, it does work.
I think this is worth a consideration for everyone who wants to use SwiftMessages with SPM now and not wait until Swift 5.3.