mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 13:35:19 +00:00
Fix iOS 13-14 concurrency backport
This commit is contained in:
parent
a4dce02329
commit
b03178483e
37
Swiftgram/FixConcurrencyBackport/BUILD
Normal file
37
Swiftgram/FixConcurrencyBackport/BUILD
Normal file
@ -0,0 +1,37 @@
|
||||
# Something changed in Telegram versions 11.8.1 -> 11.10
|
||||
# https://github.com/TelegramMessenger/Telegram-iOS/compare/release-11.8.1...TelegramMessenger:Telegram-iOS:release-11.10
|
||||
#
|
||||
# Since then, all binaries and libs are linked to the /usr/lib/swift/libswift_Concurrency.dylib instead of expected @rpath/libswift_Concurrency.dylib,
|
||||
# this makes swift-stdlib-tool to ignore libswift_Concurrency.dylib and not copy it to the app bundle.
|
||||
# This causes crash on every system that expects this backport (iOS 14 and below).
|
||||
# This script will remap the path to @rpath/libswift_Concurrency.dylib in all binaries of the App, it's only needed for iphoneos target in this project.
|
||||
# This is a temporary fix until minimum OS version will be bumped to iOS 15+ or Xcode version changed to 16.3 (with Swift 6.1 support)
|
||||
|
||||
# find "$1" -type f \( -perm +111 -o -name "*.dylib" \) | while read -r bin; do
|
||||
# if otool -L "$bin" | grep -q "/usr/lib/swift/libswift_Concurrency.dylib"; then
|
||||
# echo "Patching concurrency backport in: $bin"
|
||||
# install_name_tool -change /usr/lib/swift/libswift_Concurrency.dylib @rpath/libswift_Concurrency.dylib "$bin"
|
||||
# fi
|
||||
# done
|
||||
|
||||
# Refs:
|
||||
# https://stackoverflow.com/questions/79522371/when-building-the-project-with-xcode-16-2-the-app-crashes-due-to-an-incorrect-l
|
||||
# https://github.com/swiftlang/swift/issues/74303
|
||||
# https://github.com/bazelbuild/rules_apple/pull/1393
|
||||
|
||||
genrule(
|
||||
name = "CopyConcurrencyDylib",
|
||||
cmd_bash =
|
||||
"""
|
||||
echo 'ditto "$$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/iphoneos/libswift_Concurrency.dylib" "$$1/Payload/Swiftgram.app/Frameworks/libswift_Concurrency.dylib"' > $(location CopyConcurrencyDylib.sh)
|
||||
echo 'ditto "$$1/Payload/Swiftgram.app/Frameworks/libswift_Concurrency.dylib" "$$1/SwiftSupport/iphoneos/libswift_Concurrency.dylib"' >> $(location CopyConcurrencyDylib.sh)
|
||||
echo '' >> $(location CopyConcurrencyDylib.sh)
|
||||
""",
|
||||
outs = [
|
||||
"CopyConcurrencyDylib.sh",
|
||||
],
|
||||
executable = True,
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
]
|
||||
)
|
@ -1001,6 +1001,13 @@ genrule(
|
||||
cmd_bash =
|
||||
"""
|
||||
echo 'for f in $$1/*.framework; do binary_name=`echo $$(basename $$f) | sed -e "s/\\\\.framework//"`; strip -ST $$f/$$binary_name; done;' > $(location StripFramework.sh)
|
||||
# MARK: Swiftgram
|
||||
echo 'find "$$1" -type f \\( -perm +111 -o -name "*.dylib" \\) | while read -r bin; do \
|
||||
if otool -L "$$bin" | grep -q "/usr/lib/swift/libswift_Concurrency.dylib"; then \
|
||||
echo "Patching concurrency backport in: $$bin"; \
|
||||
install_name_tool -change /usr/lib/swift/libswift_Concurrency.dylib @rpath/libswift_Concurrency.dylib "$$bin"; \
|
||||
fi; \
|
||||
done;' >> $(location StripFramework.sh)
|
||||
echo '' >> $(location StripFramework.sh)
|
||||
""",
|
||||
outs = [
|
||||
@ -2038,7 +2045,7 @@ ios_application(
|
||||
alternate_icons = [
|
||||
":{}".format(name) for name in alternate_icon_folders
|
||||
],
|
||||
#ipa_post_processor = ":AddAlternateIcons",
|
||||
ipa_post_processor = "//Swiftgram/FixConcurrencyBackport:CopyConcurrencyDylib",
|
||||
resources = [
|
||||
":LaunchScreen",
|
||||
":DefaultAppIcon",
|
||||
|
@ -13,3 +13,11 @@ if [ "$version" == "14.0" ]; then
|
||||
binary_path="$f/$(basename $f | sed -e s/\.appex//g)"
|
||||
xcrun lipo "$binary_path" -remove armv7 -o "$binary_path" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# MARK: Swiftgram
|
||||
find "$1" -type f \( -perm +111 -o -name "*.dylib" \) | while read -r bin; do
|
||||
if otool -L "$bin" | grep -q "/usr/lib/swift/libswift_Concurrency.dylib"; then
|
||||
echo "Patching concurrency backport in: $bin"
|
||||
install_name_tool -change /usr/lib/swift/libswift_Concurrency.dylib @rpath/libswift_Concurrency.dylib "$bin"
|
||||
fi
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user