Skip to content

Commit de09f0f

Browse files
persidskiypjleonard37
authored andcommitted
Publish Examples apps in CD (#4222)
Co-authored-by: Patrick Leonard <[email protected]> GitOrigin-RevId: b7e72d31238d0f55ee4a094f0e25dc8959b5378b
1 parent 4aaef06 commit de09f0f

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed

.fastlane/Fastfile

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,29 @@
1010
# https://docs.fastlane.tools/plugins/available-plugins
1111
#
1212

13+
require 'json'
14+
1315
default_platform(:ios)
1416

1517
ENV["FASTLANE_SKIP_UPDATE_CHECK"] = "1"
1618
ENV["SPACESHIP_SKIP_2FA_UPGRADE"] = "1"
1719

20+
project_path = ENV["PROJECT_PATH"] || "Examples.xcodeproj"
21+
entitlement_path = "../Sources/Examples/Examples_CarPlay.entitlements"
22+
entitlement_absolute_path = File.absolute_path(entitlement_path)
23+
24+
def read_json file_path, key
25+
JSON.parse(File.read(file_path))[key]
26+
end
27+
28+
def examples_changelog
29+
maps = read_json(File.absolute_path('../Sources/MapboxMaps/MapboxMaps.json'), 'version')
30+
"Bump MapboxMaps version to #{maps}"
31+
end
32+
33+
puts "Project Path: #{project_path}"
34+
puts "Entitlement Path: #{entitlement_absolute_path}"
35+
1836
platform :ios do
1937

2038
lane :setup_distribution_cert do
@@ -39,22 +57,22 @@ platform :ios do
3957
sync_code_signing
4058
update_code_signing_settings(
4159
use_automatic_signing: false,
42-
path: "Examples.xcodeproj",
60+
path: project_path,
4361
team_id: "GJZR2MEM28", # Developer Portal Team ID,
4462
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["mapbox.ExamplesUITests.xctrunner"],
4563
targets: ["ExamplesUITests"],
4664
code_sign_identity: "Apple Development: Created via API",
4765
)
4866
update_code_signing_settings(
4967
use_automatic_signing: false,
50-
path: "Examples.xcodeproj",
68+
path: project_path,
5169
team_id: "GJZR2MEM28", # Developer Portal Team ID,
5270
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["com.mapbox.examples"],
5371
targets: ["Examples"],
5472
code_sign_identity: "Apple Development: Created via API",
5573
)
5674
run_tests(
57-
project: 'Examples.xcodeproj',
75+
project: project_path,
5876
scheme: 'Examples', # XCTest scheme
5977
clean: true, # Recommended: This would ensure the build would not include unnecessary files
6078
# Use the Debug mode here to avoid the compiler crash
@@ -97,10 +115,18 @@ platform :ios do
97115

98116
lane :beta do
99117
api_key_if_needed # Generate API Token
118+
new_build_number = latest_testflight_build_number + 1
100119
increment_build_number(
101-
build_number: latest_testflight_build_number + 1,
102-
xcodeproj: 'Examples.xcodeproj'
120+
build_number: new_build_number,
121+
xcodeproj: project_path
103122
)
123+
124+
if ENV['GITHUB_OUTPUT']
125+
File.open(ENV['GITHUB_OUTPUT'], 'a') do |file|
126+
file.puts("build_number=#{new_build_number}")
127+
end
128+
end
129+
104130
build_and_submit
105131
end
106132

@@ -111,24 +137,28 @@ platform :ios do
111137
sync_code_signing(type: "development")
112138
update_code_signing_settings(
113139
use_automatic_signing: false,
114-
path: "Examples.xcodeproj",
140+
path: project_path,
115141
team_id: "GJZR2MEM28", # Developer Portal Team ID,
116142
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["com.mapbox.examples"],
117143
targets: ["Examples"],
118144
code_sign_identity: "Apple Development: Created via API",
119-
entitlements_file_path: "Sources/Examples/Examples_CarPlay.entitlements"
145+
entitlements_file_path: entitlement_absolute_path
120146
)
121147
sync_code_signing(type: "appstore")
122148
build_app(
123149
scheme: "Examples",
124-
project: "Examples.xcodeproj",
150+
project: project_path,
151+
export_method: "app-store",
125152
xcargs: "SWIFT_TREAT_WARNINGS_AS_ERRORS=NO COMPILER_INDEX_STORE_ENABLE=NO" # Disable to bypass Deprecated error on OfflineManager example
126153
)
127154
upload_to_testflight(
128155
beta_app_feedback_email: "[email protected]",
129156
beta_app_description: "Examples app test build.",
130157
demo_account_required: false,
131-
skip_waiting_for_build_processing: true
158+
skip_waiting_for_build_processing: false,
159+
distribute_external: true,
160+
groups: ["Mobot", "Mapbox Testers"],
161+
changelog: examples_changelog
132162
)
133163
end
134164

Sources/Examples/Controllers/ExampleTableViewController.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import UIKit
22
import ObjectiveC
33
import os
4+
@_spi(Internal) import MapboxMaps
45

56
final class ExampleTableViewController: UITableViewController {
67
let startingExampleTitleKey = "com.mapbox.startingExampleTitle"
@@ -21,6 +22,15 @@ final class ExampleTableViewController: UITableViewController {
2122
navigationItem.searchController = searchController
2223
navigationItem.hidesSearchBarWhenScrolling = false
2324
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "SwiftUI", style: .plain, target: self, action: #selector(openSwiftUI))
25+
26+
var version = Bundle.mapboxMapsMetadata.version
27+
if version.count > 12 {
28+
version = version.prefix(12) + "..."
29+
}
30+
let versionButton = UIBarButtonItem(title: version, image: nil, target: self, action: #selector(openVersion))
31+
navigationItem.rightBarButtonItem = versionButton
32+
33+
2434
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "reuseIdentifier")
2535

2636
navigationController?.delegate = self
@@ -52,6 +62,13 @@ final class ExampleTableViewController: UITableViewController {
5262
@objc func openSwiftUI() {
5363
present(createSwiftUIExamplesController(), animated: true)
5464
}
65+
66+
@objc func openVersion() {
67+
let str = "MapboxMaps: \(Bundle.mapboxMapsMetadata.version)"
68+
let vc = UIAlertController(title: "Version", message: str, preferredStyle: .alert)
69+
vc.addAction(UIAlertAction(title: "OK", style: .default))
70+
present(vc, animated: true)
71+
}
5572

5673
override func viewWillAppear(_ animated: Bool) {
5774
super.viewWillAppear(animated)

Sources/MapboxMaps/Foundation/Extensions/Bundle+MapboxMaps.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import Foundation
22

33
private class BundleLocator {}
44

5-
internal struct MapboxMapsMetadata: Codable {
6-
var version: String
5+
@_spi(Internal)
6+
public struct MapboxMapsMetadata: Codable {
7+
public var version: String
78
}
89

910
extension Bundle {
@@ -24,7 +25,8 @@ extension Bundle {
2425
#endif
2526
}
2627

27-
static var mapboxMapsMetadata: MapboxMapsMetadata = {
28+
@_spi(Internal)
29+
public static var mapboxMapsMetadata: MapboxMapsMetadata = {
2830
guard let metadataPath = Bundle.mapboxMaps.url(forResource: "MapboxMaps", withExtension: "json") else {
2931
return MapboxMapsMetadata(version: "unknown.ios-metatadata-failure")
3032
}

Tests/MapboxMapsTests/Style/AttributionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import XCTest
2-
@testable import MapboxMaps
2+
@_spi(Internal) @testable import MapboxMaps
33
import Foundation
44
import UIKit
55

0 commit comments

Comments
 (0)