Closed knothed closed 4 years ago
@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 work/xcode12
branch
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 destination
as described above.
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 (https://github.com/SwiftKickMobile/SwiftMessages/issues/330, https://github.com/SwiftKickMobile/SwiftMessages/issues/362, https://github.com/SwiftKickMobile/SwiftMessages/issues/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.