-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore old build process for v2 (#263)
The v2-specific automation updates from #203 didn't seem to work correctly when @nplasterer and I tested it, it seemed like the v3 and v2 releases (which publish to different repos) get mixed together, and we're not sure if this is because of user error or a genuine issue. I was going to go back and figure out what is wrong later, but as @neekolas needs this now, I'm reverting the build scripts to what they were in 7f78ade, which has been working for me. Later, we can revert this PR and debug the automation.
- Loading branch information
1 parent
82a007b
commit 8efd3b8
Showing
4 changed files
with
145 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
# This script copies the built XCFramework to a the xmtp_rust_swift repo, which is a Swift package | ||
# that encapsulates all of the good stuff here. | ||
|
||
# Look for an xmtp_rust_swift repo at the sibling layer of the top level of this repo so ../../ | ||
|
||
REPONAME="xmtp-rust-swift" | ||
REPOPATH="../../$REPONAME" | ||
# Now move the XMTPRustSwift.xcframework to the Swift package | ||
rm -rf "$REPOPATH/XMTPRustSwift.xcframework" | ||
cp -R "XMTPRustSwift.xcframework" "$REPOPATH" | ||
|
||
# Need to copy any Swift file in ./include/Generated to $REPOPATH/Sources/XMTPRust/* | ||
FILES=$(find ./Generated -name "*.swift") | ||
|
||
# HACK HACK HACK | ||
# Here's the ultra-hack, we need to inject "import XMTPRustSwift" into the top of the Swift files | ||
# before copying them over so they'll get the headers we moved to "include/Generated". | ||
# | ||
# Moreover, we inject the following lines to allow RustStrings to be interpreted as NSErrors and automatically | ||
# displayed in the debugger: | ||
# https://github.com/chinedufn/swift-bridge/issues/150 | ||
# | ||
# extension RustString: @unchecked Sendable {} | ||
# | ||
# extension RustString: LocalizedError { | ||
# public var errorDescription: String? { | ||
# return NSLocalizedString("XMTP Rust Error: \(self.as_str().toString())", comment: self.as_str().toString()) | ||
# } | ||
# } | ||
add_xmtprustswift_import() { | ||
echo "Injecting 'import XMTPRustSwift' text as first line into $1" | ||
sed -i '' '1s/^/import XMTPRustSwift\n\n/' "$1" | ||
} | ||
add_foundation_import() { | ||
echo "Injecting 'import Foundation' text as first line into $1" | ||
sed -i '' '1s/^/import Foundation\n\n/' "$1" | ||
} | ||
add_nserror_helpers() { | ||
sed -i '' '1s/^/extension RustString: @unchecked Sendable {}\nextension RustString: LocalizedError {\n public var errorDescription: String? {\n return NSLocalizedString("XMTP Rust Error: \\(self.as_str().toString())", comment: self.as_str().toString())\n }\n}\n\n/' "$1" | ||
} | ||
for f in $FILES | ||
do | ||
# If it's a xmtp_rust_swift.swift file, then do the injection | ||
if [[ $f == *"xmtp_rust_swift.swift" ]]; then | ||
add_nserror_helpers "$f" | ||
# Only the xmtp_rust_swift.swift file needs Foundation | ||
add_foundation_import "$f" | ||
fi | ||
# All files need "import XMTPRustSwift" | ||
add_xmtprustswift_import "$f" | ||
echo "Copying $f" | ||
mv "$f" "$REPOPATH/Sources/XMTPRust/" | ||
done | ||
|