Skip to content

Commit ec18c34

Browse files
Embedding third-party dependencies (#379)
1 parent 40a5c07 commit ec18c34

File tree

114 files changed

+13388
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+13388
-47
lines changed

.github/workflows/cron-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
if: failure()
108108
run: |
109109
brew install chargepoint/xcparse/xcparse
110-
xcparse logs fastlane/test_output/StreamChatUITestsApp.xcresult fastlane/test_output/logs/
110+
xcparse logs fastlane/test_output/StreamChatSwiftUITestsApp.xcresult fastlane/test_output/logs/
111111
- uses: actions/upload-artifact@v3
112112
if: failure()
113113
with:

.github/workflows/smoke-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
if: failure()
153153
run: |
154154
brew install chargepoint/xcparse/xcparse
155-
xcparse logs fastlane/test_output/StreamChatUITestsApp.xcresult fastlane/test_output/logs/
155+
xcparse logs fastlane/test_output/StreamChatSwiftUITestsApp.xcresult fastlane/test_output/logs/
156156
- uses: actions/upload-artifact@v3
157157
if: failure()
158158
with:

.slather.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ ignore:
1010
- "**/*_Mock.swift"
1111
- "**/*_Vendor.swift"
1212
- "**/Generated/*.swift"
13+
- "Sources/StreamChatSwiftUI/StreamNuke"
14+
- "Sources/StreamChatSwiftUI/StreamSwiftyGif"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6+
### ⚠️ Important
7+
8+
- Dependencies are no longer exposed (this includes Nuke and SwiftyGif). If you were using those dependencies we were exposing, you would need to import them manually. If you encounter any SPM-related problems, be sure to reset the package caches.
9+
610
### ✅ Added
711
- Add message preview with attachments in channel list
812

DemoAppSwiftUI/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ class AppDelegate: NSObject, UIApplicationDelegate {
6868
streamChat = StreamChat(chatClient: chatClient, utils: utils)
6969

7070
let credentials = UnsecureRepository.shared.loadCurrentUser()
71-
if let credentials, let token = try? Token(rawValue: credentials.token) {
71+
if let credentials, let token = try? Token(rawValue: credentials.token) {
7272
chatClient.connectUser(
7373
userInfo: .init(
7474
id: credentials.id,
7575
name: credentials.name,
7676
imageURL: credentials.avatarURL
7777
),
78-
token: token
78+
token: token
7979
)
8080
}
8181

8282
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
8383
withAnimation {
84-
if AppState.shared.userState == .launchAnimation {
84+
if AppState.shared.userState == .launchAnimation {
8585
AppState.shared.userState = credentials == nil ? .notLoggedIn : .loggedIn
8686
}
8787
}

DemoAppSwiftUI/UserRepository.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Copyright © 2023 Stream.io Inc. All rights reserved.
33
//
44

5-
import StreamChat
65
import Foundation
6+
import StreamChat
77

88
protocol UserRepository {
99

@@ -14,7 +14,7 @@ protocol UserRepository {
1414
func removeCurrentUser()
1515
}
1616

17-
//NOTE: This is just for simplicity. User data shouldn't be kept in `UserDefaults`.
17+
// NOTE: This is just for simplicity. User data shouldn't be kept in `UserDefaults`.
1818
final class UnsecureRepository: UserRepository {
1919
enum Key: String, CaseIterable {
2020
case user = "stream.chat.user"

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MAKEFLAGS += --silent
2+
3+
update_dependencies:
4+
echo "👉 Updating Nuke"
5+
make update_nuke version=11.3.1
6+
echo "👉 Updating SwiftyGif"
7+
make update_swiftygif version=5.4.2
8+
9+
update_nuke: check_version_parameter
10+
./Scripts/updateDependency.sh $(version) Dependencies/Nuke Sources/StreamChatSwiftUI/StreamNuke Sources
11+
./Scripts/removePublicDeclarations.sh Sources/StreamChatSwiftUI/StreamNuke
12+
13+
update_swiftygif: check_version_parameter
14+
./Scripts/updateDependency.sh $(version) Dependencies/SwiftyGif Sources/StreamChatSwiftUI/StreamSwiftyGif SwiftyGif
15+
./Scripts/removePublicDeclarations.sh Sources/StreamChatSwiftUI/StreamSwiftyGif
16+
17+
check_version_parameter:
18+
@if [ "$(version)" = "" ]; then\
19+
echo "❌ Missing version parameter"; \
20+
exit 1;\
21+
fi

Package.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ let package = Package(
1717
)
1818
],
1919
dependencies: [
20-
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.39.0"),
21-
.package(url: "https://github.com/kean/Nuke.git", .exact("11.3.1"))
20+
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.39.0"),
2221
],
2322
targets: [
2423
.target(
2524
name: "StreamChatSwiftUI",
26-
dependencies: [.product(name: "StreamChat", package: "stream-chat-swift"), "Nuke", .product(name: "NukeUI", package: "Nuke")],
25+
dependencies: [.product(name: "StreamChat", package: "stream-chat-swift")],
2726
exclude: ["README.md", "Info.plist", "Generated/L10n_template.stencil"],
2827
resources: [.process("Resources")]
2928
)

Scripts/removePublicDeclarations.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage: ./removePublicDeclarations.sh Sources/StreamNuke
4+
#
5+
# This script would iterate over the files on a particular directory, and perform basic replacement operations.
6+
# It heavily relies on 'sed':
7+
# sed -i '<backup-file-extension>' -e 's/<original-string>/<replacement>/g' <file>
8+
# ^
9+
# Passing empty string prevents the creation of backup files
10+
11+
args=("$@")
12+
directory=$1
13+
14+
replaceDeclaration() {
15+
original=$1
16+
replacement=$2
17+
file=$3
18+
`sed -i '' -e "s/$original/$replacement/g" $file`
19+
}
20+
21+
files=`find $directory -name "*.swift"`
22+
for f in $files
23+
do
24+
replaceDeclaration 'public internal(set) ' '' $f
25+
replaceDeclaration 'open ' '' $f
26+
replaceDeclaration 'public ' '' $f
27+
28+
# Nuke
29+
if [[ $directory == *"Nuke"* ]]; then
30+
replaceDeclaration 'var log' 'var nukeLog' $f
31+
replaceDeclaration 'log =' 'nukeLog =' $f
32+
replaceDeclaration 'log: log' 'log: nukeLog' $f
33+
replaceDeclaration 'signpost(log' 'signpost(nukeLog' $f
34+
replaceDeclaration ' Cache(' ' NukeCache(' $f
35+
replaceDeclaration ' Cache<' ' NukeCache<' $f
36+
replaceDeclaration ' Image?' ' NukeImage?' $f
37+
replaceDeclaration ' Image(' ' NukeImage(' $f
38+
replaceDeclaration 'struct Image:' 'struct NukeImage:' $f
39+
replaceDeclaration 'extension Image {' 'extension NukeImage {' $f
40+
replaceDeclaration 'Content == Image' 'Content == NukeImage' $f
41+
replaceDeclaration ' VideoPlayerView' ' NukeVideoPlayerView' $f
42+
replaceDeclaration 'typealias Color' 'typealias NukeColor' $f
43+
replaceDeclaration 'extension Color' 'extension NukeColor' $f
44+
replaceDeclaration 'AssetType' 'NukeAssetType' $f
45+
replaceDeclaration 'typealias ImageRequest = Nuke.ImageRequest' '' $f
46+
replaceDeclaration 'typealias ImageResponse = Nuke.ImageResponse' '' $f
47+
replaceDeclaration 'typealias ImagePipeline = Nuke.ImagePipeline' '' $f
48+
replaceDeclaration 'typealias ImageContainer = Nuke.ImageContainer' '' $f
49+
replaceDeclaration 'open class ' '' $f
50+
replaceDeclaration 'import Nuke' '' $f
51+
52+
# Remove Cancellable interface duplicate
53+
if [[ $f == *"DataLoader"* && `head -10 $f` == *"protocol Cancellable"* ]]; then
54+
`sed -i '' -e '7,11d' $f`
55+
fi
56+
57+
# Rename files
58+
if [[ $f == *"Caching/Cache.swift" ]]; then
59+
new_f="${f/Cache.swift/NukeCache.swift}"
60+
mv "$f" "$new_f"
61+
elif [[ $f == *"NukeUI/VideoPlayerView.swift" ]]; then
62+
new_f="${f/VideoPlayerView.swift/NukeVideoPlayerView.swift}"
63+
mv "$f" "$new_f"
64+
fi
65+
fi
66+
done

Scripts/removeUnneededSymbols.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage: ./removeUnneededSymbols.sh StreamChatSwiftUI ./Products
4+
#
5+
# Creating an xcframework for StreamChatSwiftUI generates a .bcsymbolmap file for itself, and one for
6+
# each of its dependencies too (eg. StreamChat). That means that we will end up having something like:
7+
#
8+
# -> StreamChatSwiftUI/BCSymbolMaps/
9+
# <UUID-StreamChatSwiftUI>.bcsymbolmap
10+
# <UUID-StreamChat>.bcsymbolmap
11+
#
12+
# When adding both StreamChat and StreamChatSwiftUI to an app, it will throw an error when trying to compile
13+
# saying that there are multiple executions producing the same file (<UUID-StreamChat>.bcsymbolmap).
14+
#
15+
# This script will remove duplicated .bcsymbolmap in the generated xcframeworks.
16+
# If we countinue with the same example, it will leave it as follows:
17+
#
18+
# -> StreamChatSwiftUI/BCSymbolMaps/
19+
# <UUID-StreamChatSwiftUI>.bcsymbolmap
20+
#
21+
# Each xcframework only contains its symbols now.
22+
23+
args=("$@")
24+
library=$1
25+
output_directory=$2
26+
27+
function removeUnneededSymbols() {
28+
arch=$1
29+
path="$output_directory/$library.xcframework/$arch/BCSymbolMaps"
30+
cd $path
31+
32+
# Looking for [...]/DerivedSources/[LIBRARY-NAME]_vers.c
33+
regex="(\/DerivedSources\/)([a-zA-Z_]*)(_vers.c)"
34+
files="*.bcsymbolmap"
35+
for f in $files
36+
do
37+
text=`head -10 $f`
38+
[[ $text =~ $regex ]]
39+
library_match="${BASH_REMATCH[2]}"
40+
if [[ $library_match != $library ]]
41+
then
42+
echo "→ Removing uneeded 'bcsymbolmap' from $library-$arch: $library_match - $f"
43+
rm $f
44+
fi
45+
done
46+
47+
cd - >/dev/null
48+
}
49+
50+
removeUnneededSymbols "ios-arm64"
51+
removeUnneededSymbols "ios-arm64_x86_64-simulator"

0 commit comments

Comments
 (0)