-
Notifications
You must be signed in to change notification settings - Fork 90
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
Embedding third-party dependencies #379
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b46e396
Embed third-party dependencies
testableapple 39ce8b8
Update spec files
testableapple 0678f33
Fix typos
testableapple 5e16004
Fix Cancellable issue
testableapple e019067
Resolve UnsafeRawPointer warning
testableapple e056143
Fix one more warning
testableapple 1ebe09b
Update changelog
testableapple 6d61b52
Resolve linting issue
testableapple 1d9d51e
Fix demo app linting issues
testableapple 01e3528
Update changelog
testableapple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,21 @@ | ||
MAKEFLAGS += --silent | ||
|
||
update_dependencies: | ||
echo "👉 Updating Nuke" | ||
make update_nuke version=11.3.1 | ||
echo "👉 Updating SwiftyGif" | ||
make update_swiftygif version=5.4.2 | ||
|
||
update_nuke: check_version_parameter | ||
./Scripts/updateDependency.sh $(version) Dependencies/Nuke Sources/StreamChatSwiftUI/StreamNuke Sources | ||
./Scripts/removePublicDeclarations.sh Sources/StreamChatSwiftUI/StreamNuke | ||
|
||
update_swiftygif: check_version_parameter | ||
./Scripts/updateDependency.sh $(version) Dependencies/SwiftyGif Sources/StreamChatSwiftUI/StreamSwiftyGif SwiftyGif | ||
./Scripts/removePublicDeclarations.sh Sources/StreamChatSwiftUI/StreamSwiftyGif | ||
|
||
check_version_parameter: | ||
@if [ "$(version)" = "" ]; then\ | ||
echo "❌ Missing version parameter"; \ | ||
exit 1;\ | ||
fi |
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,66 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Usage: ./removePublicDeclarations.sh Sources/StreamNuke | ||
# | ||
# This script would iterate over the files on a particular directory, and perform basic replacement operations. | ||
# It heavily relies on 'sed': | ||
# sed -i '<backup-file-extension>' -e 's/<original-string>/<replacement>/g' <file> | ||
# ^ | ||
# Passing empty string prevents the creation of backup files | ||
|
||
args=("$@") | ||
directory=$1 | ||
|
||
replaceDeclaration() { | ||
original=$1 | ||
replacement=$2 | ||
file=$3 | ||
`sed -i '' -e "s/$original/$replacement/g" $file` | ||
} | ||
|
||
files=`find $directory -name "*.swift"` | ||
for f in $files | ||
do | ||
replaceDeclaration 'public internal(set) ' '' $f | ||
replaceDeclaration 'open ' '' $f | ||
replaceDeclaration 'public ' '' $f | ||
|
||
# Nuke | ||
if [[ $directory == *"Nuke"* ]]; then | ||
replaceDeclaration 'var log' 'var nukeLog' $f | ||
replaceDeclaration 'log =' 'nukeLog =' $f | ||
replaceDeclaration 'log: log' 'log: nukeLog' $f | ||
replaceDeclaration 'signpost(log' 'signpost(nukeLog' $f | ||
replaceDeclaration ' Cache(' ' NukeCache(' $f | ||
replaceDeclaration ' Cache<' ' NukeCache<' $f | ||
replaceDeclaration ' Image?' ' NukeImage?' $f | ||
replaceDeclaration ' Image(' ' NukeImage(' $f | ||
replaceDeclaration 'struct Image:' 'struct NukeImage:' $f | ||
replaceDeclaration 'extension Image {' 'extension NukeImage {' $f | ||
replaceDeclaration 'Content == Image' 'Content == NukeImage' $f | ||
replaceDeclaration ' VideoPlayerView' ' NukeVideoPlayerView' $f | ||
replaceDeclaration 'typealias Color' 'typealias NukeColor' $f | ||
replaceDeclaration 'extension Color' 'extension NukeColor' $f | ||
replaceDeclaration 'AssetType' 'NukeAssetType' $f | ||
replaceDeclaration 'typealias ImageRequest = Nuke.ImageRequest' '' $f | ||
replaceDeclaration 'typealias ImageResponse = Nuke.ImageResponse' '' $f | ||
replaceDeclaration 'typealias ImagePipeline = Nuke.ImagePipeline' '' $f | ||
replaceDeclaration 'typealias ImageContainer = Nuke.ImageContainer' '' $f | ||
replaceDeclaration 'open class ' '' $f | ||
replaceDeclaration 'import Nuke' '' $f | ||
|
||
# Remove Cancellable interface duplicate | ||
if [[ $f == *"DataLoader"* && `head -10 $f` == *"protocol Cancellable"* ]]; then | ||
`sed -i '' -e '7,11d' $f` | ||
fi | ||
|
||
# Rename files | ||
if [[ $f == *"Caching/Cache.swift" ]]; then | ||
new_f="${f/Cache.swift/NukeCache.swift}" | ||
mv "$f" "$new_f" | ||
elif [[ $f == *"NukeUI/VideoPlayerView.swift" ]]; then | ||
new_f="${f/VideoPlayerView.swift/NukeVideoPlayerView.swift}" | ||
mv "$f" "$new_f" | ||
fi | ||
fi | ||
done |
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,51 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Usage: ./removeUnneededSymbols.sh StreamChatSwiftUI ./Products | ||
# | ||
# Creating an xcframework for StreamChatSwiftUI generates a .bcsymbolmap file for itself, and one for | ||
# each of its dependencies too (eg. StreamChat). That means that we will end up having something like: | ||
# | ||
# -> StreamChatSwiftUI/BCSymbolMaps/ | ||
# <UUID-StreamChatSwiftUI>.bcsymbolmap | ||
# <UUID-StreamChat>.bcsymbolmap | ||
# | ||
# When adding both StreamChat and StreamChatSwiftUI to an app, it will throw an error when trying to compile | ||
# saying that there are multiple executions producing the same file (<UUID-StreamChat>.bcsymbolmap). | ||
# | ||
# This script will remove duplicated .bcsymbolmap in the generated xcframeworks. | ||
# If we countinue with the same example, it will leave it as follows: | ||
# | ||
# -> StreamChatSwiftUI/BCSymbolMaps/ | ||
# <UUID-StreamChatSwiftUI>.bcsymbolmap | ||
# | ||
# Each xcframework only contains its symbols now. | ||
|
||
args=("$@") | ||
library=$1 | ||
output_directory=$2 | ||
|
||
function removeUnneededSymbols() { | ||
arch=$1 | ||
path="$output_directory/$library.xcframework/$arch/BCSymbolMaps" | ||
cd $path | ||
|
||
# Looking for [...]/DerivedSources/[LIBRARY-NAME]_vers.c | ||
regex="(\/DerivedSources\/)([a-zA-Z_]*)(_vers.c)" | ||
files="*.bcsymbolmap" | ||
for f in $files | ||
do | ||
text=`head -10 $f` | ||
[[ $text =~ $regex ]] | ||
library_match="${BASH_REMATCH[2]}" | ||
if [[ $library_match != $library ]] | ||
then | ||
echo "→ Removing uneeded 'bcsymbolmap' from $library-$arch: $library_match - $f" | ||
rm $f | ||
fi | ||
done | ||
|
||
cd - >/dev/null | ||
} | ||
|
||
removeUnneededSymbols "ios-arm64" | ||
removeUnneededSymbols "ios-arm64_x86_64-simulator" |
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,60 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Usage: ./updateDependency.sh 10.3.3 Dependencies/Nuke Sources/StreamNuke Sources | ||
# | ||
# This script gets the source code of a dependency of a given library, and copies it to our codebase | ||
|
||
ensure_clean_git () { | ||
if !(git diff-index --quiet HEAD) | ||
then | ||
echo "→ Seems like git is not clean in $dependency_directory. Please make sure it is clean, and run it again" | ||
exit 1 | ||
fi | ||
} | ||
|
||
args=("$@") | ||
version=$1 | ||
dependency_directory=$2 | ||
output_directory=$3 | ||
sources_directory=$4 | ||
|
||
dependency_url="" | ||
|
||
if [[ $dependency_directory == *"Nuke"* ]]; then | ||
dependency_url="[email protected]:kean/Nuke.git" | ||
elif [[ $dependency_directory == *"SwiftyGif"* ]]; then | ||
dependency_url="[email protected]:kirualex/SwiftyGif.git" | ||
else | ||
echo "→ Unknown dependency at $dependency_directory" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ -d "$dependency_directory" ]]; then | ||
echo "→ $dependency_directory does not exist in your filesystem. Cloning the repo" | ||
git clone $dependency_url $dependency_directory | ||
fi | ||
|
||
cd $dependency_directory | ||
|
||
ensure_clean_git | ||
|
||
git fetch --tags | ||
git checkout $version | ||
|
||
ensure_clean_git | ||
|
||
cd - | ||
|
||
echo "→ Copying source files" | ||
rm -rf $output_directory | ||
mkdir $output_directory | ||
cp -r "$dependency_directory/$sources_directory/." $output_directory | ||
|
||
|
||
for f in `find $output_directory -type f \( -iname \*.h -o -iname \*.plist \)` | ||
do | ||
echo "→ Removing $f" | ||
rm $f | ||
done | ||
|
||
rm -rf $dependency_directory |
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
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 |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
// | ||
|
||
import AVKit | ||
import Nuke | ||
import NukeUI | ||
import StreamChat | ||
import SwiftUI | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see Difference, Swifter and the tools. Can we also get rid of those? (not in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those come from StreamChat. They will be gone as soon as #376 is merged