Skip to content

Commit

Permalink
Merge pull request #15 from tchapgouv/14-xcodegen-enhance-architectur…
Browse files Browse the repository at this point in the history
…e-to-facilitate-rebase

Enhance xcodegen project files
  • Loading branch information
NicolasBuquet authored Oct 10, 2024
2 parents 483806f + 8ed7de2 commit e6c0f3a
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 21 deletions.
32 changes: 32 additions & 0 deletions TchapX/SupportingFiles/UnitTests.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"configurations" : [
{
"id" : "991CB720-B4D2-4F1F-BB8A-A2C1A717F529",
"name" : "TchapX",
"options" : {

}
}
],
"defaultOptions" : {
"defaultTestExecutionTimeAllowance" : 60,
"environmentVariableEntries" : [
{
"key" : "IS_RUNNING_UNIT_TESTS",
"value" : "1"
}
],
"testExecutionOrdering" : "random",
"testTimeoutsEnabled" : true
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:TchapX.xcodeproj",
"identifier" : "E156D99C308BC583D03697F6",
"name" : "Tchap-Production"
}
}
],
"version" : 1
}
6 changes: 3 additions & 3 deletions TchapX/SupportingFiles/target-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ targets:

settings:
base:
PRODUCTION_APP_NAME: Tchap DEVELOPMENT
PRODUCTION_APP_NAME: TchapX DEVELOPMENT
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx.dev
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx.dev
APP_NAME: TchapX-development
APP_DISPLAY_NAME: TchapX-DEVELOPMENT
APP_NAME: TchapX-Development
APP_DISPLAY_NAME: TchapX Development
ASSETCATALOG_COMPILER_APPICON_NAME: TchapX-icon

PRODUCT_NAME: $(APP_NAME)
Expand Down
6 changes: 3 additions & 3 deletions TchapX/SupportingFiles/target-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ targets:

settings:
base:
PRODUCTION_APP_NAME: Tchap PRODUCTION
PRODUCTION_APP_NAME: TchapX PRODUCTION
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx
APP_NAME: TchapX-production
APP_DISPLAY_NAME: TchapX-PRODUCTION
APP_NAME: TchapX-Production
APP_DISPLAY_NAME: TchapX Production

PRODUCT_NAME: $(APP_NAME)
PRODUCT_BUNDLE_IDENTIFIER: $(BASE_BUNDLE_IDENTIFIER)
Expand Down
6 changes: 3 additions & 3 deletions TchapX/SupportingFiles/target-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ targets:

settings:
base:
PRODUCTION_APP_NAME: Tchap STAGING
PRODUCTION_APP_NAME: TchapX STAGING
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx.staging
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx.staging
APP_NAME: TchapX-staging
APP_DISPLAY_NAME: TchapX-STAGING
APP_NAME: TchapX-Staging
APP_DISPLAY_NAME: TchapX Staging

PRODUCT_NAME: $(APP_NAME)
PRODUCT_BUNDLE_IDENTIFIER: $(BASE_BUNDLE_IDENTIFIER)
Expand Down
49 changes: 49 additions & 0 deletions TchapX/SupportingFiles/target-unitTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: TchapX-UnitTests

schemes:
UnitTests:
analyze:
config: Debug
archive:
config: Release
build:
targets:
TchapX-UnitTests: all
profile:
config: Release
run:
config: Debug
disableMainThreadChecker: false
test:
config: Debug
disableMainThreadChecker: false
gatherCoverageData: true
coverageTargets:
- TchapX-Development
testPlans:
- path: UnitTests.xctestplan
# Don't set it as defaultPlan to avoid conflict with ElementX defaultPlan.
defaultPlan: false

targets:
TchapX-UnitTests:
type: bundle.unit-test
platform: iOS

dependencies:
- target: TchapX-Development

info:
path: ../development/SupportingFiles/Info.plist

settings:
base:
PRODUCT_NAME: TchapX-UnitTests
PRODUCT_BUNDLE_IDENTIFIER: ${BASE_BUNDLE_IDENTIFIER}.unit.tests
debug:
release:

sources:
# - path: ../../ElementX/Sources/Other/InfoPlistReader.swift
# - path: ../../Tools/Scripts/Templates/SimpleScreenExample/Tests/Unit
- path: ../main/UnitTests/Sources
9 changes: 5 additions & 4 deletions TchapX/development/SupportingFiles/NSE/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ targets:

settings:
base:
PRODUCTION_APP_NAME: TchapX-NSE DEVELOPMENT
PRODUCTION_APP_NAME: TchapX-NSE Development
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx.dev
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx.dev
APP_NAME: TchapX-NSE-development
APP_DISPLAY_NAME: TchapX-NSE-DEVELOPMENT
APP_NAME: TchapX-NSE-Development
APP_DISPLAY_NAME: TchapX-NSE Development

PRODUCT_NAME: TchapX-NSE-Development
PRODUCT_DISPLAY_NAME: $(APP_DISPLAY_NAME)
Expand Down Expand Up @@ -116,4 +116,5 @@ targets:
- path: ../../../../ElementX/Sources/Application/AppSettings.swift
- path: ../../../../ElementX/Sources/AppHooks/AppHooks.swift
- path: ../../../../ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift
- path: ../PrivacyInfo.xcprivacy
- path: ../PrivacyInfo.xcprivacy
# - path: ../../../main/Sources/Other/Helpers/TchapX-String.swift
91 changes: 91 additions & 0 deletions TchapX/main/Sources/Other/Helpers/MatrixIdFromString.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* MIT License
*
* Copyright (c) 2024. DINUM
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/

//
// MatrixIdFromString.swift
// Tchap X
//
// Created by Nicolas Buquet on 03/10/2024.
// Copyright © 2024 Tchap. All rights reserved.
//

import Foundation

struct MatrixIdFromString {
private var mxIdString: String

init(_ mxIdString: String) {
self.mxIdString = mxIdString
}

/// Get the homeserver name of a matrix identifier.
///
/// - Returns: the homeserver name, if any, `nil` otherwise.
///
/// The identifier type may be any matrix identifier type: user id, room id, ...
///
/// For example in case of "@jean-philippe.martin-modernisation.fr:matrix.test.org", this will return "matrix.test.org".
///
/// In case of "!AAAAAAA:matrix.test.org", this will return "matrix.test.org".
///
var homeServerName: Substring {
guard let splitIndex = mxIdString.firstIndex(of: ":") else {
return ""
}
return mxIdString[mxIdString.index(after: splitIndex)...]
}

/// Get the Tchap display name of the homeserver mentioned in a matrix identifier.
///
/// - Returns: the Tchap display name of the homeserver.
///
/// The identifier type may be any matrix identifier type: user id, room id, ...
///
/// The returned name is capitalized.
///
/// The Tchap HS display name is the component mentioned before the suffix "tchap.gouv.fr"
///
/// For example in case of "@jean-philippe.martin-modernisation.fr:name1.tchap.gouv.fr", this will return "Name1".
/// in case of "@jean-philippe.martin-modernisation.fr:agent.name2.tchap.gouv.fr", this will return "Name2".

var homeServerDisplayName: Substring {
var homeserverName = homeServerName
if homeserverName.hasSuffix("tchap.gouv.fr") {
let homeserverNameComponents = homeserverName.split(separator: ".")
if homeserverNameComponents.count >= 4 {
homeserverName = homeserverNameComponents[homeserverNameComponents.count - 4]
}
}
return homeserverName.prefix(1).localizedCapitalized + homeserverName.localizedLowercase.dropFirst()
}

/// Tells whether a homeserver name corresponds to an external server or not.
///
/// - Returns: true if external.

var isExternalTchapServer: Bool {
mxIdString.isEmpty || mxIdString.hasPrefix("e.") || mxIdString.hasPrefix("agent.externe.")
}

}
9 changes: 9 additions & 0 deletions TchapX/main/Sources/Other/Helpers/UserDisplayName.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// UserDisplayName.swift
// TchapX
//
// Created by Nicolas Buquet on 09/10/2024.
// Copyright © 2024 Tchap. All rights reserved.
//

import Foundation
19 changes: 19 additions & 0 deletions TchapX/main/UnitTests/Sources/UserDisplayNameTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// UserDisplayNaneTests.swift
// IntegrationTests
//
// Created by Nicolas Buquet on 09/10/2024.
// Copyright © 2024 Tchap. All rights reserved.
//

import XCTest

@testable import TchapX_Development

final class UserDisplayNaneTests: XCTestCase {
func testUserName() {
XCTAssertEqual(MatrixIdFromString("@jean-philippe.martin-modernisation.fr:matrix.test.org").homeServerName, "matrix.test.org")

}

}
9 changes: 5 additions & 4 deletions TchapX/production/SupportingFiles/NSE/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ targets:

settings:
base:
PRODUCTION_APP_NAME: TchapX-NSE PRODUCTION
PRODUCTION_APP_NAME: TchapX-NSE Production
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx
APP_NAME: TchapX-NSE-staging
APP_DISPLAY_NAME: TchapX-NSE-PRODUCTION
APP_NAME: TchapX-NSE-Production
APP_DISPLAY_NAME: TchapX-NSE Production

PRODUCT_NAME: TchapX-NSE-Production
PRODUCT_DISPLAY_NAME: $(APP_DISPLAY_NAME)
Expand Down Expand Up @@ -116,4 +116,5 @@ targets:
- path: ../../../../ElementX/Sources/Application/AppSettings.swift
- path: ../../../../ElementX/Sources/AppHooks/AppHooks.swift
- path: ../../../../ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift
- path: ../PrivacyInfo.xcprivacy
- path: ../PrivacyInfo.xcprivacy
# - path: ../../../main/Sources/Other/Helpers/TchapX-String.swift
9 changes: 5 additions & 4 deletions TchapX/staging/SupportingFiles/NSE/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ targets:

settings:
base:
PRODUCTION_APP_NAME: TchapX-NSE STAGING
PRODUCTION_APP_NAME: TchapX-NSE Staging
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx.staging
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx.staging
APP_NAME: TchapX-NSE-staging
APP_DISPLAY_NAME: TchapX-NSE-STAGING
APP_NAME: TchapX-NSE-Staging
APP_DISPLAY_NAME: TchapX-NSE Staging

PRODUCT_NAME: TchapX-NSE-Staging
PRODUCT_DISPLAY_NAME: $(APP_DISPLAY_NAME)
Expand Down Expand Up @@ -116,4 +116,5 @@ targets:
- path: ../../../../ElementX/Sources/Application/AppSettings.swift
- path: ../../../../ElementX/Sources/AppHooks/AppHooks.swift
- path: ../../../../ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift
- path: ../PrivacyInfo.xcprivacy
- path: ../PrivacyInfo.xcprivacy
# - path: ../../../main/Sources/Other/Helpers/TchapX-String.swift
36 changes: 36 additions & 0 deletions TchapX/staging/UnitTests/Sources/String.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// String.swift
// UnitTests
//
// Created by Nicolas Buquet on 03/10/2024.
// Copyright © 2024 Tchap. All rights reserved.
//

import XCTest

final class String: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
2 changes: 2 additions & 0 deletions project-tchap-x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ options:
- pattern: TchapX
order:
- Sources
- UnitTests
- Resources
- SupportingFiles

Expand All @@ -34,3 +35,4 @@ include:
- path: TchapX/staging/SupportingFiles/NSE/target.yml
- path: TchapX/SupportingFiles/target-development.yml
- path: TchapX/development/SupportingFiles/NSE/target.yml
- path: TchapX/SupportingFiles/target-unitTests.yml

0 comments on commit e6c0f3a

Please sign in to comment.