Skip to content

Add dedicated secrets file for Reader #24463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .configure
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"project_name": "WordPress-iOS",
"branch": "trunk",
"pinned_hash": "96b8f38f614556658c0cf5eb86a61027d48fd1de",
"pinned_hash": "671341de5698d1ef34d0dd6f36bf526d578b22c7",
"files_to_copy": [
{
"file": "iOS/WPiOS/project.env",
Expand Down Expand Up @@ -32,9 +32,12 @@
"file": "iOS/JPiOS/Jetpack-Secrets.swift",
"destination": "~/.configure/wordpress-ios/secrets/Jetpack-Secrets.swift",
"encrypt": true
},
{
"file": "iOS/Reader/Reader-Secrets.swift",
Copy link
Contributor Author

@mokagio mokagio Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something not obvious to me was that the source file cannot be called Secrets.swift, even though the Reader prefix seems redundant in a folder called Reader.

The reason for that is that when configure encrypts the files locally, it uses the file name. And given we already have a source file called Secrets.swift we cannot name this new one that.

"destination": "~/.configure/wordpress-ios/secrets/Reader-Secrets.swift",
"encrypt": true
}
],
"file_dependencies": [

]
"file_dependencies": []
}
Binary file modified .configure-files/Jetpack-Secrets.swift.enc
Binary file not shown.
Binary file added .configure-files/Reader-Secrets.swift.enc
Binary file not shown.
Binary file modified .configure-files/Secrets-Alpha.swift.enc
Binary file not shown.
Binary file modified .configure-files/Secrets-Internal.swift.enc
Binary file not shown.
Binary file modified .configure-files/Secrets.swift.enc
Binary file not shown.
5 changes: 1 addition & 4 deletions Scripts/BuildPhases/GenerateCredentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ ensure_is_in_input_files_list $WORDPRESS_SECRETS_FILE
JETPACK_SECRETS_FILE="${SECRETS_ROOT}/Jetpack-Secrets.swift"
ensure_is_in_input_files_list $JETPACK_SECRETS_FILE

# TODO: We'll need a dedicated one for Reader...
# READER_SECRETS_FILE="${SECRETS_ROOT}/Reader-Secrets.swift"
# ...using WordPress-Secrets.swift for now.
READER_SECRETS_FILE="${SECRETS_ROOT}/WordPress-Secrets.swift"
READER_SECRETS_FILE="${SECRETS_ROOT}/Reader-Secrets.swift"
ensure_is_in_input_files_list $READER_SECRETS_FILE

LOCAL_SECRETS_FILE="${SRCROOT}/Credentials/Secrets.swift"
Expand Down
1 change: 1 addition & 0 deletions Scripts/BuildPhases/GenerateCredentials.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ${HOME}/.configure/wordpress-ios/secrets/WordPress-Secrets.swift
${HOME}/.configure/wordpress-ios/secrets/WordPress-Secrets-Internal.swift
${HOME}/.configure/wordpress-ios/secrets/WordPress-Secrets-Alpha.swift
${HOME}/.configure/wordpress-ios/secrets/Jetpack-Secrets.swift
${HOME}/.configure/wordpress-ios/secrets/Reader-Secrets.swift

# Local Secrets file that external contributors can use to specify their own
# ClientID and Secrets. This file is created by the Rakefile when external
Expand Down
4 changes: 1 addition & 3 deletions Sources/Reader/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import WordPress
// This is because `BuildSettings` are not propagated through the app via chain injection but accessed via a `static` `current` property for convenience.
// Also for convenience, we assume the secrets not to be nil at runtime, to avoid unwrapping values that we know must be there.
// Therefore, we need to make the secrets available to `BuildSettings` before the app starts.
// FIXME: Sort ot Reader having its own ApiCredentials (soon to be BuildSecrets) instance
//BuildSettings.configure(secrets: ApiCredentials.toSecrets())
BuildSettings.configure(secrets: BuildSecrets.dummy)
BuildSettings.configure(secrets: ApiCredentials.toSecrets())

UIApplicationMain(
CommandLine.argc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ final class ReaderTabViewController: UITabBarController, UITabBarControllerDeleg
}

private func makeNotificationsViewController() -> UIViewController {
let notificationsVC = UIStoryboard(name: "Notifications", bundle: nil)
let notificationsVC = UIStoryboard(name: "Notifications", bundle: Bundle(for: Self.self))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to avoid a crash due to the storyboard in Reader being part of Keystone, not the app bundle

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#24464 follows up to this and addresses all such accesses for the notifications storyboard.

.instantiateInitialViewController() as! NotificationsViewController
notificationsVC.tabBarItem = UITabBarItem(
title: Strings.notifications,
Expand Down
4 changes: 2 additions & 2 deletions WordPress/Classes/Utility/ViewLoading/NibLoadable.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit

/// A protocol for views that can be loaded from nibs.
public protocol NibLoadable {
public protocol NibLoadable: AnyObject {

/// Default nib name.
static var defaultNibName: String { get }
Expand All @@ -20,7 +20,7 @@ public extension NibLoadable {
}

static var defaultBundle: Bundle {
return Bundle.main
return Bundle(for: Self.self)
}

static var defaultNib: UINib {
Expand Down
2 changes: 1 addition & 1 deletion config/Reader.alpha.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

WP_PUSH_NOTIFICATION_APP_ID = TBD
WP_BUILD_CONFIGURATION = alpha
WP_APP_URL_SCHEME = TBD
WP_APP_URL_SCHEME = wpreader
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value could also be specialized by build configuration, e.g.:

WP_APP_URL_SCHEME = wpdebug

WP_APP_URL_SCHEME = wordpress

but I'm not sure if we need to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WP_APP_URL_SCHEME should be one for each app identifier. If I'm not mistaken, debug and release builds share the same app identifier, but alpha builds use a different one.

4 changes: 2 additions & 2 deletions config/Reader.debug.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Version.public.xcconfig"

WP_PUSH_NOTIFICATION_APP_ID = TBD
WP_BUILD_CONFIGURATION = alpha
WP_APP_URL_SCHEME = TBD
WP_BUILD_CONFIGURATION = debug
WP_APP_URL_SCHEME = wpreader

PROVISIONING_PROFILE_SPECIFIER = Reader Development
4 changes: 2 additions & 2 deletions config/Reader.release.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Version.public.xcconfig"

WP_PUSH_NOTIFICATION_APP_ID = TBD
WP_BUILD_CONFIGURATION = alpha
WP_APP_URL_SCHEME = TBD
WP_BUILD_CONFIGURATION = release
WP_APP_URL_SCHEME = wpreader

PROVISIONING_PROFILE_SPECIFIER = match AppStore ${PRODUCT_BUNDLE_IDENTIFIER}