Skip to content

Commit 5b6bc02

Browse files
committed
Merge branch 'trunk' into tooling/migrate-from-appcenter-to-fad
# Conflicts: # Gemfile # Gemfile.lock # WordPress/WordPress-Internal-Info.plist # WordPress/Wordpress-Alpha-Info.plist
2 parents 9b73d24 + 25aac40 commit 5b6bc02

File tree

500 files changed

+2405
-24241
lines changed

Some content is hidden

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

500 files changed

+2405
-24241
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
root = true
2+
13
# Apply to all files
24
[*]
5+
indent_style = space
6+
indent_size = 2
37
end_of_line = lf
48
insert_final_newline = true
9+
charset = utf-8
510
trim_trailing_whitespace = true
611

12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[*.swift]
16+
indent_size = 4
17+
18+
[{*.h,*.m}]
19+
indent_size = 4
20+
721
# Ruby specific rules
822
[{*.rb,Fastfile,Gemfile}]
923
indent_style = space

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ gem 'dotenv'
88
#
99
# See failures like https://buildkite.com/automattic/wordpress-ios/builds/24053#019234f2-80a5-40f6-b55e-2f420e6483a8/3840-3915
1010
# and https://github.com/fastlane/fastlane/pull/22256
11-
gem 'fastlane', '~> 2.226'
11+
gem 'fastlane', '~> 2.227'
1212
gem 'fastlane-plugin-firebase_app_distribution', '~> 0.10'
1313
gem 'fastlane-plugin-sentry'
1414
# This comment avoids typing to switch to a development version for testing.
1515
#
1616
# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref: ''
1717
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 13.0'
1818
gem 'rake'
19-
gem 'rubocop', '~> 1.72'
19+
gem 'rubocop', '~> 1.74'
2020
gem 'rubocop-rake', '~> 0.7'
2121
gem 'xcpretty-travis-formatter'
2222

Gemfile.lock

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ GEM
2323
artifactory (3.0.17)
2424
ast (2.4.2)
2525
atomos (0.1.3)
26-
aws-eventstream (1.3.1)
27-
aws-partitions (1.1054.0)
28-
aws-sdk-core (3.219.0)
26+
aws-eventstream (1.3.2)
27+
aws-partitions (1.1068.0)
28+
aws-sdk-core (3.220.1)
2929
aws-eventstream (~> 1, >= 1.3.0)
3030
aws-partitions (~> 1, >= 1.992.0)
3131
aws-sigv4 (~> 1.9)
@@ -124,7 +124,7 @@ GEM
124124
faraday_middleware (1.2.1)
125125
faraday (~> 1.0)
126126
fastimage (2.4.0)
127-
fastlane (2.226.0)
127+
fastlane (2.227.0)
128128
CFPropertyList (>= 2.3, < 4.0.0)
129129
addressable (>= 2.8, < 3.0.0)
130130
artifactory (~> 3.0)
@@ -214,12 +214,12 @@ GEM
214214
google-apis-core (>= 0.11.0, < 2.a)
215215
google-apis-storage_v1 (0.31.0)
216216
google-apis-core (>= 0.11.0, < 2.a)
217-
google-cloud-core (1.7.1)
217+
google-cloud-core (1.8.0)
218218
google-cloud-env (>= 1.0, < 3.a)
219219
google-cloud-errors (~> 1.0)
220220
google-cloud-env (1.6.0)
221221
faraday (>= 0.17.3, < 3.0)
222-
google-cloud-errors (1.4.0)
222+
google-cloud-errors (1.5.0)
223223
google-cloud-storage (1.47.0)
224224
addressable (~> 2.8)
225225
digest-crc (~> 0.4)
@@ -243,7 +243,7 @@ GEM
243243
concurrent-ruby (~> 1.0)
244244
java-properties (0.3.0)
245245
jmespath (1.6.2)
246-
json (2.10.1)
246+
json (2.10.2)
247247
jwt (2.10.1)
248248
base64
249249
kramdown (2.5.1)
@@ -303,7 +303,7 @@ GEM
303303
observer (~> 0.1)
304304
pkg-config (~> 1.4)
305305
rouge (3.28.0)
306-
rubocop (1.72.2)
306+
rubocop (1.74.0)
307307
json (~> 2.3)
308308
language_server-protocol (~> 3.17.0.2)
309309
lint_roller (~> 1.1.0)
@@ -314,7 +314,7 @@ GEM
314314
rubocop-ast (>= 1.38.0, < 2.0)
315315
ruby-progressbar (~> 1.7)
316316
unicode-display_width (>= 2.4.0, < 4.0)
317-
rubocop-ast (1.38.0)
317+
rubocop-ast (1.39.0)
318318
parser (>= 3.3.1.0)
319319
rubocop-rake (0.7.1)
320320
lint_roller (~> 1.1)
@@ -368,13 +368,13 @@ PLATFORMS
368368
DEPENDENCIES
369369
danger-dangermattic (~> 1.2)
370370
dotenv
371-
fastlane (~> 2.226)
371+
fastlane (~> 2.227)
372372
fastlane-plugin-firebase_app_distribution (~> 0.10)
373373
fastlane-plugin-sentry
374374
fastlane-plugin-wpmreleasetoolkit (~> 13.0)
375375
rake
376376
rmagick (~> 6.1.1)
377-
rubocop (~> 1.72)
377+
rubocop (~> 1.74)
378378
rubocop-rake (~> 0.7)
379379
xcpretty-travis-formatter
380380

Modules/Package.swift

+28-5
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,24 @@ let package = Package(
5959
.product(name: "Collections", package: "swift-collections"),
6060
.product(name: "Gifu", package: "Gifu"),
6161
]),
62-
.target(name: "DesignSystem", swiftSettings: [.swiftLanguageMode(.v5)]),
62+
.target(name: "BuildSettingsKit"),
63+
.target(
64+
name: "DesignSystem",
65+
dependencies: [
66+
"BuildSettingsKit",
67+
.product(name: "ColorStudio", package: "color-studio"),
68+
],
69+
resources: [.process("Resources")],
70+
swiftSettings: [.swiftLanguageMode(.v5)]
71+
),
6372
.target(name: "JetpackStatsWidgetsCore", swiftSettings: [.swiftLanguageMode(.v5)]),
6473
// SFHFKeychainUtils is an old Objective-C keychain wrapper.
6574
// The implementatoin predates ARC, hence the dedicated target with ARC disabled, for the time being.
6675
.target(
6776
name: "SFHFKeychainUtils",
6877
cSettings: [.unsafeFlags(["-fno-objc-arc"])]
6978
),
79+
.target(name: "TextBundle"),
7080
.target(name: "UITestsFoundation", dependencies: [
7181
.product(name: "ScreenObject", package: "ScreenObject"),
7282
.product(name: "XCUITestHelpers", package: "ScreenObject"),
@@ -82,11 +92,19 @@ let package = Package(
8292
.target(name: "WordPressFlux", swiftSettings: [.swiftLanguageMode(.v5)]),
8393
.target(name: "WordPressCore", dependencies: [.target(name: "WordPressShared"), .product(name: "WordPressAPI", package: "wordpress-rs")]),
8494
.target(name: "WordPressSharedObjC", resources: [.process("Resources")], swiftSettings: [.swiftLanguageMode(.v5)]),
85-
.target(name: "WordPressShared", dependencies: [.target(name: "WordPressSharedObjC")], resources: [.process("Resources")], swiftSettings: [.swiftLanguageMode(.v5)]),
95+
.target(
96+
name: "WordPressShared",
97+
dependencies: [
98+
.target(name: "SFHFKeychainUtils"),
99+
.target(name: "WordPressSharedObjC"),
100+
],
101+
resources: [.process("Resources")],
102+
swiftSettings: [.swiftLanguageMode(.v5)]
103+
),
86104
.target(name: "WordPressTesting", resources: [.process("Resources")]),
87105
.target(
88106
name: "WordPressUI",
89-
dependencies: ["AsyncImageKit", "WordPressShared"],
107+
dependencies: ["AsyncImageKit", "DesignSystem", "WordPressShared"],
90108
resources: [.process("Resources")],
91109
swiftSettings: [.swiftLanguageMode(.v5)]
92110
),
@@ -142,6 +160,7 @@ enum XcodeSupport {
142160

143161
static var targets: [Target] {
144162
let wordPresAuthentificatorDependencies: [Target.Dependency] = [
163+
"BuildSettingsKit",
145164
"WordPressShared",
146165
"WordPressUI",
147166
.product(name: "Gridicons", package: "Gridicons-iOS"),
@@ -153,16 +172,17 @@ enum XcodeSupport {
153172
]
154173

155174
let shareAndDraftExtensionsDependencies: [Target.Dependency] = [
175+
"BuildSettingsKit",
156176
"SFHFKeychainUtils",
157177
"WordPressShared",
158178
"WordPressUI",
179+
"TextBundle",
159180
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
160181
.product(name: "Down", package: "Down"),
161182
.product(name: "Gridicons", package: "Gridicons-iOS"),
162183
.product(name: "Reachability", package: "Reachability"),
163184
.product(name: "SVProgressHUD", package: "SVProgressHUD"),
164185
.product(name: "ZIPFoundation", package: "ZIPFoundation"),
165-
.product(name: "ColorStudio", package: "color-studio"),
166186
.product(name: "Aztec", package: "AztecEditor-iOS"),
167187
.product(name: "WordPressEditor", package: "AztecEditor-iOS"),
168188
]
@@ -175,6 +195,7 @@ enum XcodeSupport {
175195
return [
176196
.xcodeTarget("XcodeTarget_App", dependencies: [
177197
"DesignSystem",
198+
"BuildSettingsKit",
178199
"JetpackStatsWidgetsCore",
179200
"SFHFKeychainUtils",
180201
"WordPressData",
@@ -228,17 +249,19 @@ enum XcodeSupport {
228249
.xcodeTarget("XcodeTarget_NotificationServiceExtension", dependencies: [
229250
"SFHFKeychainUtils",
230251
"WordPressShared",
252+
"BuildSettingsKit",
231253
]),
232254
.xcodeTarget("XcodeTarget_StatsWidget", dependencies: [
255+
"BuildSettingsKit",
233256
"JetpackStatsWidgetsCore",
234257
"SFHFKeychainUtils",
235258
"WordPressShared",
236259
"WordPressUI",
237260
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
238261
.product(name: "WordPressAPI", package: "wordpress-rs"),
239-
.product(name: "ColorStudio", package: "color-studio"),
240262
]),
241263
.xcodeTarget("XcodeTarget_Intents", dependencies: [
264+
"BuildSettingsKit",
242265
"JetpackStatsWidgetsCore",
243266
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
244267
]),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Foundation
2+
3+
extension BuildSettings {
4+
static let live = BuildSettings(bundle: .app)
5+
6+
init(bundle: Bundle) {
7+
brand = AppBrand(rawValue: bundle.infoValue(forKey: "WPAppBrand"))!
8+
pushNotificationAppID = bundle.infoValue(forKey: "WPPushNotificationAppID")
9+
appGroupName = bundle.infoValue(forKey: "WPAppGroupName")
10+
appKeychainAccessGroup = bundle.infoValue(forKey: "WPAppKeychainAccessGroup")
11+
eventNamePrefix = bundle.infoValue(forKey: "WPEventNamePrefix")
12+
explatPlatform = bundle.infoValue(forKey: "WPExplatPlatform")
13+
}
14+
}
15+
16+
private extension Bundle {
17+
func infoValue<T>(forKey key: String) -> T where T: LosslessStringConvertible {
18+
guard let object = object(forInfoDictionaryKey: key) else {
19+
fatalError("missing value for key: \(key)")
20+
}
21+
switch object {
22+
case let value as T:
23+
return value
24+
case let string as String:
25+
guard let value = T(string) else { fallthrough }
26+
return value
27+
default:
28+
fatalError("unexpected value: \(object) for key: \(key)")
29+
}
30+
}
31+
}
32+
33+
private extension Bundle {
34+
/// Returns the `Bundle` for the host `.app`.
35+
///
36+
/// - If this is called from code already located in the main app's bundle or from a Pod/Framework,
37+
/// this will return the same as `Bundle.main`, aka the bundle of the app itself.
38+
/// - If this is called from an App Extension (Widget, ShareExtension, etc), this will return the bundle of the
39+
/// main app hosting said App Extension (while `Bundle.main` would return the App Extension itself)
40+
static let app: Bundle = {
41+
var url = Bundle.main.bundleURL
42+
while url.pathExtension != "app" && url.lastPathComponent != "/" {
43+
url.deleteLastPathComponent()
44+
}
45+
guard let appBundle = Bundle(url: url) else { fatalError("Unable to find the parent app bundle") }
46+
return appBundle
47+
}()
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Foundation
2+
3+
/// The container for Xcode previews.
4+
extension BuildSettings {
5+
nonisolated(unsafe) static var preview = BuildSettings(
6+
brand: .jetpack,
7+
pushNotificationAppID: "xcpreview_push_notification_id",
8+
appGroupName: "xcpreview_app_group_name",
9+
appKeychainAccessGroup: "xcpreview_app_keychain_access_group",
10+
eventNamePrefix: "xcpreview",
11+
explatPlatform: "xcpreview"
12+
)
13+
}
14+
15+
extension BuildSettings {
16+
/// Updates the preview settings for the lifetime of the given closure.
17+
/// Reverts to the original settings when done.
18+
@MainActor
19+
public static func withSettings<T>(_ configure: (inout BuildSettings) -> Void, perform closure: () -> T) -> T {
20+
var container = BuildSettings.preview
21+
let original = container
22+
configure(&container)
23+
BuildSettings.preview = container
24+
let value = closure()
25+
BuildSettings.preview = original
26+
return value
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Foundation
2+
3+
/// Manages global build settings.
4+
///
5+
/// The build settings work differently depending on the environment:
6+
///
7+
/// - **Live** – the code runs as part of an app or app extensions with build
8+
/// settings configured using the `Info.plist` file.
9+
/// - **Preview** – the code runs as part of the SwiftPM or Xcode target. In this
10+
/// environment, the build settings have predefined values that can also be
11+
/// changed at runtime.
12+
/// - **Test** – `BuildSettings` are not available when running unit tests as
13+
/// they are incompatible with parallelized tests and are generally not recommended.
14+
public struct BuildSettings: Sendable {
15+
public var brand: AppBrand
16+
public var pushNotificationAppID: String
17+
public var appGroupName: String
18+
public var appKeychainAccessGroup: String
19+
public var eventNamePrefix: String
20+
public var explatPlatform: String
21+
22+
public static var current: BuildSettings {
23+
switch BuildSettingsEnvironment.current {
24+
case .live:
25+
return .live
26+
case .preview:
27+
return .preview
28+
case .test:
29+
fatalError("BuildSettings are unavailable when running unit tests. Make sure to inject the values manually in system under test.")
30+
}
31+
}
32+
}
33+
34+
public enum AppBrand: String, Sendable {
35+
case wordpress
36+
case jetpack
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Foundation
2+
3+
public enum BuildSettingsEnvironment: Sendable {
4+
case live
5+
case preview
6+
case test
7+
8+
public static let current: BuildSettingsEnvironment = {
9+
#if DEBUG
10+
let processInfo = ProcessInfo.processInfo
11+
if processInfo.isXcodePreview {
12+
return .preview
13+
}
14+
if processInfo.isTesting {
15+
return .test
16+
}
17+
#endif
18+
return .live
19+
}()
20+
}
21+
22+
private extension ProcessInfo {
23+
var isXcodePreview: Bool {
24+
environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
25+
}
26+
27+
var isTesting: Bool {
28+
if environment.keys.contains("XCTestBundlePath") { return true }
29+
if environment.keys.contains("XCTestConfigurationFilePath") { return true }
30+
if environment.keys.contains("XCTestSessionIdentifier") { return true }
31+
32+
return arguments.contains { argument in
33+
let path = URL(fileURLWithPath: argument)
34+
return path.lastPathComponent == "swiftpm-testing-helper"
35+
|| argument == "--testing-library"
36+
|| path.lastPathComponent == "xctest"
37+
|| path.pathExtension == "xctest"
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)