Skip to content
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

Use XcodeGen files for app variants and setup Enterprise submodule. #2976

Merged
merged 11 commits into from
Jun 27, 2024
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Enterprise"]
path = Enterprise
url = git@github.com:element-hq/element-ios-enterprise
12 changes: 12 additions & 0 deletions ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@
B444F9C184A377C1B481F07F /* XCUIElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = E992D7B8BE54B2AB454613AF /* XCUIElement.swift */; };
B4A0C69370E6008A971463E7 /* BugReportScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C89820BB2B88D4EA28131C /* BugReportScreenViewModelProtocol.swift */; };
B4AAB3257A83B73F53FB2689 /* StateStoreViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F3DFE5B444F131648066F05 /* StateStoreViewModel.swift */; };
B50C95B6D1EABFE1CEA50959 /* AppHooks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B048CB133239700CD890F5D /* AppHooks.swift */; };
B5321A1F5B26A0F3EC54909E /* CollapsibleFlowLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC5F5209279A752D98AAC4B2 /* CollapsibleFlowLayoutTests.swift */; };
B53D292A5CA61E371C4CD785 /* GenericCallLinkCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514923AA9640C34F39E0500A /* GenericCallLinkCoordinator.swift */; };
B5479997ECC516C121E6625E /* LocationMarkerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFECCE59967018204876D0A5 /* LocationMarkerView.swift */; };
Expand Down Expand Up @@ -1325,6 +1326,7 @@
2AB2C848BB9A7A9B618B7B89 /* TextBasedRoomTimelineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBasedRoomTimelineTests.swift; sourceTree = "<group>"; };
2AE807361805463F5AEDD1CA /* VoiceMessagePreviewComposer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessagePreviewComposer.swift; sourceTree = "<group>"; };
2AF715D4FD4710EBB637D661 /* SettingsScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreenViewModelProtocol.swift; sourceTree = "<group>"; };
2B048CB133239700CD890F5D /* AppHooks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppHooks.swift; sourceTree = "<group>"; };
2BB385E148DE55C85C0A02D6 /* SoftLogoutScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoftLogoutScreenModels.swift; sourceTree = "<group>"; };
2BDB3E65A79779EDA5D33D8A /* AudioPlayerState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioPlayerState.swift; sourceTree = "<group>"; };
2BFDCA5A09EE70BC17F2EFA7 /* URLComponents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLComponents.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3710,6 +3712,14 @@
path = Items;
sourceTree = "<group>";
};
769D25068533684018BA0F82 /* Hooks */ = {
isa = PBXGroup;
children = (
2B048CB133239700CD890F5D /* AppHooks.swift */,
);
path = Hooks;
sourceTree = "<group>";
};
7803E03F759061C948D66B7E /* AppLock */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4973,6 +4983,7 @@
C0937E3B06A8F0E2DB7C8241 /* Other */,
2ECFF6B05DAA37EB10DBF7E8 /* UITests */,
337015ADFBA3AB96660DB3A6 /* Generated */,
769D25068533684018BA0F82 /* Hooks */,
31CE4DA53232AA534057F912 /* Mocks */,
4C826614718790C58C17117F /* UnitTests */,
);
Expand Down Expand Up @@ -5899,6 +5910,7 @@
A021827B528F1EDC9101CA58 /* AppCoordinatorProtocol.swift in Sources */,
4FF90E2242DBD596E1ED2E27 /* AppCoordinatorStateMachine.swift in Sources */,
9D9690D2FD4CD26FF670620F /* AppDelegate.swift in Sources */,
B50C95B6D1EABFE1CEA50959 /* AppHooks.swift in Sources */,
6851B077B4C913CC12DB6E77 /* AppLockFlowCoordinator.swift in Sources */,
06F8EDF52E33A2D36BCC1161 /* AppLockScreen.swift in Sources */,
9912F9EB2D6589141A2957B4 /* AppLockScreenCoordinator.swift in Sources */,
Expand Down
7 changes: 6 additions & 1 deletion ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
private let appMediator: AppMediator
private let appSettings: AppSettings
private let appDelegate: AppDelegate
private let appHooks: AppHooks
private let elementCallService: ElementCallServiceProtocol

/// Common background task to continue long-running tasks in the background.
Expand Down Expand Up @@ -65,10 +66,13 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
@Consumable private var storedAppRoute: AppRoute?

init(appDelegate: AppDelegate) {
let appHooks = AppHooks()
appHooks.configure()

windowManager = WindowManager(appDelegate: appDelegate)
appMediator = AppMediator(windowManager: windowManager)

let appSettings = AppSettings()
let appSettings = appHooks.runAppSettingsHook(AppSettings())

MXLog.configure(logLevel: appSettings.logLevel)

Expand All @@ -83,6 +87,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg

self.appDelegate = appDelegate
self.appSettings = appSettings
self.appHooks = appHooks
appRouteURLParser = AppRouteURLParser(appSettings: appSettings)

elementCallService = ElementCallService()
Expand Down
10 changes: 9 additions & 1 deletion ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ final class AppSettings {
store = userDefaults
}

// MARK: - Hooks

func override(defaultHomeserverAddress: String? = nil) {
if let defaultHomeserverAddress {
self.defaultHomeserverAddress = defaultHomeserverAddress
}
}

// MARK: - Application

/// Whether or not the app is a development build that isn't in production.
Expand All @@ -94,7 +102,7 @@ final class AppSettings {

/// The default homeserver address used. This is intentionally a string without a scheme
/// so that it can be passed to Rust as a ServerName for well-known discovery.
let defaultHomeserverAddress = "matrix.org"
private(set) var defaultHomeserverAddress = "matrix.org"

/// An override of the homeserver's Sliding Sync proxy URL. This allows development against servers
/// that don't yet have an officially trusted proxy configured in their well-known.
Expand Down
45 changes: 45 additions & 0 deletions ElementX/Sources/Hooks/AppHooks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Copyright 2024 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

// MARK: Registration

class AppHooks: AppHooksProtocol {
private(set) var appSettingsHook: AppSettingsHookProtocol?
func registerAppSettingsHook(_ hook: AppSettingsHookProtocol) {
appSettingsHook = hook
}

func runAppSettingsHook(_ appSettings: AppSettings) -> AppSettings {
guard let appSettingsHook else { return appSettings }
return appSettingsHook.run(appSettings: appSettings)
}
}

protocol AppHooksProtocol {
func configure()
}

extension AppHooksProtocol {
func configure() { }
}

// MARK: Protocols

protocol AppSettingsHookProtocol {
func run(appSettings: AppSettings) -> AppSettings
}
2 changes: 1 addition & 1 deletion ElementX/Sources/Mocks/PHGPostHogMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MockPostHogFactory: PostHogFactory {
self.mock = mock
}

func createPostHog(config: PostHogConfig) -> ElementX.PHGPostHogProtocol {
func createPostHog(config: PostHogConfig) -> PHGPostHogProtocol {
mock
}
}
1 change: 1 addition & 0 deletions ElementX/SupportingFiles/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ targets:
PRODUCT_BUNDLE_IDENTIFIER: $(BASE_BUNDLE_IDENTIFIER)
MARKETING_VERSION: $(MARKETING_VERSION)
CURRENT_PROJECT_VERSION: $(CURRENT_PROJECT_VERSION)
ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon
DEVELOPMENT_TEAM: $(DEVELOPMENT_TEAM)
CODE_SIGN_ENTITLEMENTS: ElementX/SupportingFiles/ElementX.entitlements
SWIFT_OBJC_BRIDGING_HEADER: ElementX/SupportingFiles/ElementX-Bridging-Header.h
Expand Down
1 change: 1 addition & 0 deletions Enterprise
Submodule Enterprise added at e03750
7 changes: 7 additions & 0 deletions app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
settings:
APP_DISPLAY_NAME: Element X
PRODUCTION_APP_NAME: Element
BASE_APP_GROUP_IDENTIFIER: io.element
BASE_BUNDLE_IDENTIFIER: io.element.elementx
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: "colors/accent-color"
DEVELOPMENT_TEAM: 7J4U792NQT
4 changes: 4 additions & 0 deletions ci_scripts/ci_post_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ install_xcode_cloud_brew_dependencies

if [ "$CI_WORKFLOW" = "Nightly" ]; then
bundle exec fastlane config_nightly build_number:"$CI_BUILD_NUMBER"
elif [ "$CI_WORKFLOW" = "Enterprise" ]; then
# Not sure what Xcode Cloud does, might need to also
# git submodule update --init --recursive
bundle exec fastlane config_enterprise
else
bundle exec fastlane config_production
fi
21 changes: 12 additions & 9 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require 'yaml'
require 'semantic'

enterprise = '../Enterprise/fastlane/Fastfile'
if File.exist?(enterprise)
import enterprise
end

before_all do
xcversion(version: "15.2")

Expand Down Expand Up @@ -146,14 +151,18 @@ lane :integration_tests do
)
end

lane :config_production do
config_secrets()
xcodegen(spec: "project.yml")
end

lane :config_nightly do |options|
build_number = options[:build_number]
UI.user_error!("Invalid build number.") unless !build_number.to_s.empty?

target_file_path = "../project.yml"
data = YAML.load_file target_file_path
data["settings"]["BASE_APP_GROUP_IDENTIFIER"] = "io.element.nightly"
data["settings"]["BASE_BUNDLE_IDENTIFIER"] = "io.element.elementx.nightly"
data["include"].append({ "path" => "fastlane/nightly.yml" })

config_secrets()

Expand All @@ -170,11 +179,6 @@ lane :config_nightly do |options|
update_app_icon(caption_text: "#{release_version}(#{build_number})", modulate: "100,20,100")
end

lane :config_production do
config_secrets()
xcodegen(spec: "project.yml")
end

$sentry_retry=0
lane :upload_dsyms_to_sentry do |options|
auth_token = ENV["SENTRY_AUTH_TOKEN"]
Expand Down Expand Up @@ -302,8 +306,7 @@ end
private_lane :config_xcodegen_alpha do
target_file_path = "../project.yml"
data = YAML.load_file target_file_path
data["settings"]["BASE_APP_GROUP_IDENTIFIER"] = "io.element.pr"
data["settings"]["BASE_BUNDLE_IDENTIFIER"] = "io.element.elementx.pr"
data["include"].append({ "path" => "fastlane/alpha.yml" })
File.open(target_file_path, 'w') { |f| YAML.dump(data, f) }

xcodegen(spec: "project.yml")
Expand Down
8 changes: 4 additions & 4 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do



### config_nightly
### config_production

```sh
[bundle exec] fastlane config_nightly
[bundle exec] fastlane config_production
```



### config_production
### config_nightly

```sh
[bundle exec] fastlane config_production
[bundle exec] fastlane config_nightly
```


Expand Down
3 changes: 3 additions & 0 deletions fastlane/alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
settings:
BASE_APP_GROUP_IDENTIFIER: io.element.pr
BASE_BUNDLE_IDENTIFIER: io.element.elementx.pr
3 changes: 3 additions & 0 deletions fastlane/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
settings:
BASE_APP_GROUP_IDENTIFIER: io.element.nightly
BASE_BUNDLE_IDENTIFIER: io.element.elementx.nightly
7 changes: 1 addition & 6 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,16 @@ options:

settings:
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED: YES
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: "colors/accent-color"
ENABLE_BITCODE: NO
BASE_APP_GROUP_IDENTIFIER: io.element
APP_GROUP_IDENTIFIER: group.$(BASE_APP_GROUP_IDENTIFIER)
BASE_BUNDLE_IDENTIFIER: io.element.elementx
APP_NAME: ElementX
APP_DISPLAY_NAME: Element X
PRODUCTION_APP_NAME: Element
KEYCHAIN_ACCESS_GROUP_IDENTIFIER: $(AppIdentifierPrefix)$(BASE_BUNDLE_IDENTIFIER)
MARKETING_VERSION: 1.6.13
CURRENT_PROJECT_VERSION: 1
DEVELOPMENT_TEAM: 7J4U792NQT
SUPPORTS_MACCATALYST: NO

include:
- path: app.yml
- path: ElementX/SupportingFiles/target.yml
- path: UnitTests/SupportingFiles/target.yml
- path: PreviewTests/SupportingFiles/target.yml
Expand Down
Loading