Skip to content

Commit 6849ca2

Browse files
Add support for pre-built XCFramework (#380)
1 parent ec18c34 commit 6849ca2

File tree

11 files changed

+189
-3
lines changed

11 files changed

+189
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Pods/
5757
Carthage/
5858
!Sample/Carthage/
5959

60+
# Ignore Products folder
61+
Products/
62+
6063
# fastlane
6164
#
6265
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
### ⚠️ Important
77

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.
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. This is due to our newest addition supporting Module Stable XCFramework, see more below in the "Added" section. If you encounter any SPM-related problems, be sure to reset the package caches.
99

1010
### ✅ Added
1111
- Add message preview with attachments in channel list
12+
- Add support for pre-built XCFramework
1213

1314
### 🐞 Fixed
1415
- Made some `ChannelList` and `MessageListView` parameters optional

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ GEM
183183
xcodeproj (>= 1.13.0, < 2.0.0)
184184
xcpretty (~> 0.3.0)
185185
xcpretty-travis-formatter (>= 0.0.3)
186+
fastlane-plugin-create_xcframework (1.1.2)
186187
fastlane-plugin-emerge (0.6.0)
187188
faraday (~> 1.1)
188189
fastlane-plugin-lizard (1.3.3)
@@ -405,6 +406,7 @@ DEPENDENCIES
405406
danger
406407
danger-commit_lint
407408
fastlane
409+
fastlane-plugin-create_xcframework
408410
fastlane-plugin-emerge
409411
fastlane-plugin-lizard
410412
fastlane-plugin-sonarcloud_metric_kit
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// Copyright © 2023 Stream.io Inc. All rights reserved.
3+
//
4+
// ⚠️ Generated file, please use `fastlane :bump_SDK_version or fastlane release major|minor|patch` lanes
5+
6+
import Foundation
7+
8+
enum SystemEnvironment {
9+
/// A Stream Chat version.
10+
public static let version: String = "4.39.0"
11+
}

StreamChatSwiftUI-XCFramework.podspec

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Pod::Spec.new do |spec|
2+
spec.name = "StreamChatSwiftUI-XCFramework"
3+
spec.version = "4.39.0"
4+
spec.summary = "StreamChat SwiftUI Chat Components"
5+
spec.description = "StreamChatSwiftUI SDK offers flexible SwiftUI components able to display data provided by StreamChat SDK."
6+
7+
spec.homepage = "https://getstream.io/chat/"
8+
spec.license = { :type => "BSD-3", :file => "LICENSE" }
9+
spec.author = { "getstream.io" => "[email protected]" }
10+
spec.social_media_url = "https://getstream.io"
11+
spec.swift_version = '5.2'
12+
spec.platform = :ios, "14.0"
13+
spec.requires_arc = true
14+
15+
spec.module_name = "StreamChatSwiftUI"
16+
spec.source = { :http => "https://github.com/GetStream/stream-chat-swiftui/releases/download/#{spec.version}/#{spec.module_name}.zip" }
17+
spec.vendored_frameworks = "#{spec.module_name}.xcframework"
18+
spec.preserve_paths = "#{spec.module_name}.xcframework/*"
19+
20+
spec.framework = "Foundation", "UIKit", "SwiftUI"
21+
22+
spec.dependency "StreamChat-XCFramework", "~> 4.39.0"
23+
24+
spec.cocoapods_version = ">= 1.11.0"
25+
end

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
82D64C1A2AD7E5B700C5C79E /* NukeCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D64BCA2AD7E5B700C5C79E /* NukeCache.swift */; };
109109
82D64C1B2AD7E5B700C5C79E /* ImageCaching.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D64BCB2AD7E5B700C5C79E /* ImageCaching.swift */; };
110110
82D64C1C2AD7E5B700C5C79E /* DataCaching.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D64BCC2AD7E5B700C5C79E /* DataCaching.swift */; };
111+
82FA42442AE67FF900C7390B /* SystemEnvironment+Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FA42432AE67FF900C7390B /* SystemEnvironment+Version.swift */; };
111112
8400A345282C05F60067D3A0 /* StreamChatWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8400A344282C05F60067D3A0 /* StreamChatWrapper.swift */; };
112113
8400A34A282C07D60067D3A0 /* InternetConnectionMonitor_Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8400A349282C07D60067D3A0 /* InternetConnectionMonitor_Mock.swift */; };
113114
8400A34C282C081E0067D3A0 /* OHHTTPStubs in Frameworks */ = {isa = PBXBuildFile; productRef = 8400A34B282C081E0067D3A0 /* OHHTTPStubs */; };
@@ -606,6 +607,7 @@
606607
82D64BCB2AD7E5B700C5C79E /* ImageCaching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCaching.swift; sourceTree = "<group>"; };
607608
82D64BCC2AD7E5B700C5C79E /* DataCaching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataCaching.swift; sourceTree = "<group>"; };
608609
82E8D79C2902B949008A8F78 /* StreamChatSwiftUITestsApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = StreamChatSwiftUITestsApp.entitlements; sourceTree = "<group>"; };
610+
82FA42432AE67FF900C7390B /* SystemEnvironment+Version.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SystemEnvironment+Version.swift"; sourceTree = "<group>"; };
609611
840008BA27E8D64A00282D88 /* MessageActions_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActions_Tests.swift; sourceTree = "<group>"; };
610612
8400A344282C05F60067D3A0 /* StreamChatWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamChatWrapper.swift; sourceTree = "<group>"; };
611613
8400A349282C07D60067D3A0 /* InternetConnectionMonitor_Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternetConnectionMonitor_Mock.swift; sourceTree = "<group>"; };
@@ -1473,6 +1475,7 @@
14731475
children = (
14741476
8465FCED2746A95600AF091E /* L10n.swift */,
14751477
8465FCEE2746A95600AF091E /* L10n_template.stencil */,
1478+
82FA42432AE67FF900C7390B /* SystemEnvironment+Version.swift */,
14761479
);
14771480
path = Generated;
14781481
sourceTree = "<group>";
@@ -2353,6 +2356,7 @@
23532356
8465FD9A2746A95700AF091E /* ReactionsHelperViews.swift in Sources */,
23542357
8465FDC02746A95700AF091E /* ChatChannelList.swift in Sources */,
23552358
82D64B682AD7E5AC00C5C79E /* ObjcAssociatedWeakObject.swift in Sources */,
2359+
82FA42442AE67FF900C7390B /* SystemEnvironment+Version.swift in Sources */,
23562360
82D64BE02AD7E5B700C5C79E /* LazyImage.swift in Sources */,
23572361
82D64C052AD7E5B700C5C79E /* Deprecated.swift in Sources */,
23582362
84DEC8EC27611CAE00172876 /* SendInChannelView.swift in Sources */,

StreamChatSwiftUIArtifacts.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

docusaurus/docs/iOS/basics/integration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ You can learn more about [our Module Stable XCFrameworks here](#xcframeworks)
3636
- `https://github.com/getstream/stream-chat-swift-spm`
3737
- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use:
3838
- `https://github.com/getstream/stream-chat-swift-spm`
39+
- For the SwiftUI components (**StreamChatSwiftUI**, which depends on **StreamChat**) use:
40+
- `https://github.com/getstream/stream-chat-swiftui-spm`
3941

4042
</p>
4143
</details>

fastlane/Fastfile

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,71 @@ after_all do |lane|
3030
stop_sinatra if lane == :test_e2e_mock
3131
end
3232

33+
lane :build_xcframeworks do
34+
match_me
35+
output_directory = "#{Dir.pwd}/../Products"
36+
team_id = File.read('Matchfile').match(/team_id\("(.*)"\)/)[1]
37+
codesign = ["codesign --timestamp -v --sign 'Apple Distribution: Stream.io Inc (#{team_id})'"]
38+
sdk_names.each do |sdk|
39+
create_xcframework(
40+
project: xcode_project,
41+
scheme: sdk,
42+
destinations: ['iOS'],
43+
include_BCSymbolMaps: true,
44+
include_debug_symbols: true,
45+
xcframework_output_directory: output_directory,
46+
remove_xcarchives: true
47+
)
48+
sh('../Scripts/removeUnneededSymbols.sh', sdk, output_directory)
49+
codesign << lane_context[SharedValues::XCFRAMEWORK_OUTPUT_PATH]
50+
end
51+
sh(codesign.join(' ')) # We need to sign all frameworks at once
52+
end
53+
3354
desc 'Release a new version'
3455
lane :release do |options|
56+
previous_version_number = last_git_tag
57+
artifacts_path = File.absolute_path('../StreamChatSwiftUIArtifacts.json')
58+
swift_environment_path = File.absolute_path('../Sources/StreamChatSwiftUI/Generated/SystemEnvironment+Version.swift')
59+
extra_changes = lambda do |release_version|
60+
# Set the framework version on the artifacts
61+
artifacts = JSON.parse(File.read(artifacts_path))
62+
artifacts[release_version.to_s] = "https://github.com/#{github_repo}/releases/download/#{release_version}/StreamChatSwiftUI.zip"
63+
File.write(artifacts_path, JSON.dump(artifacts))
64+
65+
# Set the framework version in SystemEnvironment+Version.swift
66+
new_content = File.read(swift_environment_path).gsub!(previous_version_number, release_version)
67+
File.open(swift_environment_path, 'w') { |f| f.puts(new_content) }
68+
end
69+
3570
pod_lint
3671
version_number = release_ios_sdk(
3772
version: options[:version],
3873
bump_type: options[:type],
3974
sdk_names: sdk_names,
40-
github_repo: github_repo
75+
podspec_names: ['StreamChatSwiftUI', 'StreamChatSwiftUI-XCFramework'],
76+
github_repo: github_repo,
77+
extra_changes: extra_changes
4178
)
4279
publish_release(version: version_number)
4380
end
4481

4582
desc "Publish a new release to GitHub and CocoaPods"
4683
lane :publish_release do |options|
84+
clean_products
85+
build_xcframeworks
86+
compress_frameworks
87+
clean_products
88+
4789
publish_ios_sdk(
4890
version: options[:version],
4991
sdk_names: sdk_names,
50-
github_repo: github_repo
92+
podspec_names: ['StreamChatSwiftUI', 'StreamChatSwiftUI-XCFramework'],
93+
github_repo: github_repo,
94+
upload_assets: ['Products/StreamChatSwiftUI.zip']
5195
)
96+
97+
update_spm(version: options[:version])
5298
end
5399

54100
private_lane :appstore_api_key do
@@ -180,6 +226,91 @@ lane :build_demo do |options|
180226
)
181227
end
182228

229+
desc 'Compresses the XCFrameworks into zip files'
230+
lane :compress_frameworks do
231+
Dir.chdir('..') do
232+
FileUtils.cp('LICENSE', 'Products/LICENSE')
233+
Dir.chdir('Products') do
234+
sdk_names.each do |framework|
235+
sh("zip -r #{framework} ./#{framework}.xcframework ./LICENSE")
236+
sh("swift package compute-checksum #{framework}.zip")
237+
end
238+
sh('zip -r "StreamChat-All" ./*.xcframework ./LICENSE') if sdk_names.size > 1
239+
end
240+
end
241+
end
242+
243+
desc 'Cleans Products and DerivedData folders'
244+
lane :clean_products do
245+
Dir.chdir('..') do
246+
['*.xcframework', '*.bundle', '*.BCSymbolMaps', '*.dSYMs', 'LICENSE'].each do |f|
247+
sh("rm -rf Products/#{f}")
248+
end
249+
end
250+
end
251+
252+
desc 'Update XCFrameworks and submit to the SPM repository'
253+
private_lane :update_spm do |options|
254+
version = options[:version] || ''
255+
UI.user_error!('You need to pass the version of the release you want to obtain the changelog from') unless version.length > 0
256+
257+
# Generate Checksums
258+
stream_chat_swiftui_checksum = sh('swift package compute-checksum ../Products/StreamChatSwiftUI.zip').strip
259+
260+
# Update SPM Repo
261+
spm_directory_name = 'StreamSPM'
262+
spm_directory = "../../#{spm_directory_name}"
263+
sh("git clone [email protected]:#{github_repo}-spm.git #{spm_directory}")
264+
265+
Dir.chdir(spm_directory) do
266+
result = sh('basename `git rev-parse --show-toplevel`').strip
267+
UI.error("Not using #{spm_directory_name} repo") unless result.to_s == spm_directory_name
268+
269+
file_lines = File.readlines('Package.swift')
270+
file_data = ''
271+
previous_module = ''
272+
273+
file_lines.each do |line|
274+
formatted_line =
275+
case previous_module
276+
when "StreamChatSwiftUI"
277+
line.gsub(/(checksum: ")[a-z0-9]+(")/, "\\1#{stream_chat_swiftui_checksum}\\2")
278+
else
279+
line
280+
end
281+
282+
url_pattern = %r{(releases/download/)[.0-9]+(/)}
283+
if line.match(url_pattern)
284+
formatted_line = line.gsub(url_pattern, "\\1#{version}\\2")
285+
previous_module = line.match(/([a-zA-Z]+).zip/).to_s.gsub(/.zip/, '')
286+
end
287+
288+
file_data << formatted_line
289+
end
290+
291+
# Write the new changes
292+
File.open('./Package.swift', 'w') { |file| file << file_data }
293+
294+
# Update the repo
295+
sh('git add -A')
296+
sh("git commit -m 'Bump #{version}'")
297+
sh('git push')
298+
299+
github_release = set_github_release(
300+
repository_name: "#{github_repo}-spm",
301+
api_token: ENV.fetch('GITHUB_TOKEN', nil),
302+
name: version,
303+
tag_name: version,
304+
commitish: 'main',
305+
description: "https://github.com/#{github_repo}/releases/tag/#{version}"
306+
)
307+
UI.success("New SPM release available: #{github_release['html_url']}")
308+
end
309+
310+
# Clean Up
311+
sh("rm -rf #{spm_directory}")
312+
end
313+
183314
private_lane :update_testplan_on_ci do |options|
184315
update_testplan(path: options[:path], env_vars: { key: 'CI', value: 'TRUE' }) if is_ci
185316
end

fastlane/Matchfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
git_url("[email protected]:GetStream/ios-certificates.git")
2+
3+
storage_mode("git")
4+
5+
team_id("EHV7XZLAHA")

0 commit comments

Comments
 (0)