Skip to content

Commit 9f535cd

Browse files
committed
build(ios): Add Sentry snapshot upload lanes
Add dedicated fastlane lanes for SnapshotPreviews and Swift Snapshot Testing uploads to Sentry. Pin the newer sentry fastlane plugin version and check in the local Ruby version used for the iOS tooling setup.
1 parent 06a563d commit 9f535cd

4 files changed

Lines changed: 31 additions & 19 deletions

File tree

ios/.ruby-version

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

ios/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ GEM
124124
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
125125
fastlane-plugin-emerge (0.10.8)
126126
faraday (~> 1.1)
127-
fastlane-plugin-sentry (2.5.0)
127+
fastlane-plugin-sentry (2.5.1)
128128
os (~> 1.1, >= 1.1.4)
129129
fastlane-sirp (1.0.0)
130130
sysrandom (~> 1.0)
@@ -243,7 +243,7 @@ PLATFORMS
243243
DEPENDENCIES
244244
fastlane
245245
fastlane-plugin-emerge (= 0.10.8)
246-
fastlane-plugin-sentry (= 2.5.0)
246+
fastlane-plugin-sentry (>= 2.5.1, < 3.0.0)
247247
xcpretty
248248

249249
BUNDLED WITH

ios/fastlane/Fastfile

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,24 @@ platform :ios do
209209
lane :export_thinned_build do |options|
210210
xcarchive_path = lane_context[SharedValues::XCODEBUILD_ARCHIVE]
211211
UI.message("Using archive: #{xcarchive_path}")
212-
212+
213213
# Device type configuration for thinning, default is iPhone 16 Pro
214214
device_type = options[:device_type] || 'iPhone17,1'
215215
UI.message("Thinning for device type: #{device_type}")
216-
216+
217217
# Export options for thinning
218218
export_options = {
219219
method: 'ad-hoc',
220220
thinning: device_type, # This creates a thinned build for the specific device type
221221
team_id: ENV['APPLE_TEAM_ID']
222222
}
223-
223+
224224
# Add provisioning profiles if available
225225
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
226226
bundle_identifier = ENV['BUNDLE_ID'] || app_identifier
227227
profile_name = 'HackerNews AdHoc Distribution'
228228
widget_profile_name = 'HackerNews AdHoc HomeWidget'
229-
229+
230230
export_options[:provisioningProfiles] = {
231231
bundle_identifier => profile_name,
232232
'com.emergetools.hackernews.HackerNewsHomeWidget' => widget_profile_name
@@ -240,10 +240,10 @@ platform :ios do
240240
sh("#{xcsafe} -exportArchive -archivePath #{xcarchive_path} -exportOptionsPlist export_options.plist -exportPath ./build")
241241

242242
plist_data = Plist.parse_xml('./build/app-thinning.plist')
243-
243+
244244
# Find the variant matching our device and OS version
245245
target_ipa_path = nil
246-
246+
247247
if plist_data && plist_data['variants']
248248
plist_data['variants'].each do |variant|
249249
path = variant[0]
@@ -256,43 +256,54 @@ platform :ios do
256256
end
257257
end
258258
end
259-
259+
260260
ipa_path = File.join('../', target_ipa_path)
261261
UI.message("Using IPA: #{ipa_path}")
262-
262+
263263
temp_dir = './build/temp_extraction'
264264
FileUtils.rm_rf(temp_dir) if Dir.exist?(temp_dir)
265265
FileUtils.mkdir_p(temp_dir)
266-
266+
267267
# Extract the IPA
268268
sh("cd #{temp_dir} && unzip -q '#{ipa_path}'")
269269
payload_dir = File.join(temp_dir, 'Payload')
270270
app_files = Dir.glob(File.join(payload_dir, '*.app'))
271-
271+
272272
if app_files.empty?
273273
UI.error("No .app file found in extracted IPA")
274274
return
275275
end
276-
276+
277277
thinned_app_path = app_files.first
278278
# Find the original .app in the XCArchive
279279
original_app_pattern = File.join(xcarchive_path, 'Products', 'Applications', '*.app')
280280
original_app_files = Dir.glob(original_app_pattern)
281-
281+
282282
original_app_path = original_app_files.first
283-
283+
284284
FileUtils.rm_rf(original_app_path)
285285
FileUtils.cp_r(thinned_app_path, original_app_path)
286-
286+
287287
# Clean up temporary directory
288288
FileUtils.rm_rf(temp_dir)
289289
end
290-
290+
291291
UI.success("Successfully replaced app in XCArchive with thinned build for #{device_type}")
292292
end
293293

294+
desc 'Upload SnapshotPreviews snapshots to Sentry'
295+
lane :upload_sentry_snapshots do |options|
296+
sentry_upload_snapshots(
297+
path: options[:path],
298+
app_id: 'com.emergetools.hackernews',
299+
auth_token: ENV['SENTRY_SENTRY_AUTH_TOKEN'],
300+
org_slug: 'sentry',
301+
project_slug: 'hackernews-ios'
302+
)
303+
end
304+
294305
desc 'Upload swift-snapshot-testing snapshots to Sentry'
295-
lane :upload_sentry_snapshots do
306+
lane :upload_sentry_snapshots_swift_snapshot_testing do
296307
sentry_upload_snapshots(
297308
path: 'HackerNewsTests/__Snapshots__/SwiftSnapshotTest',
298309
app_id: 'com.emergetools.hackernews',

ios/fastlane/Pluginfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Ensure this file is checked in to source control!
44

55
gem 'fastlane-plugin-emerge', '0.10.8'
6-
gem 'fastlane-plugin-sentry', '2.5.0'
6+
gem 'fastlane-plugin-sentry', '>= 2.5.1', '< 3.0.0'

0 commit comments

Comments
 (0)