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

chore: update ios flavor and build #29

Merged
merged 6 commits into from
Jul 31, 2024
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: 6 additions & 5 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
strategy:
matrix:
type: [Debug, Release]
organization: [ooni, dw]

steps:
- uses: actions/checkout@v4
Expand All @@ -21,10 +22,10 @@ jobs:
uses: ./.github/actions/setup

- name: Build Android
run: ./gradlew assemble${{ matrix.type }}
run: ./gradlew copyBrandingToCommonResources assemble${{ matrix.type }} -Porganization=${{ matrix.organization }}

- name: Build iOS
run: ./gradlew link${{ matrix.type }}FrameworkIosSimulatorArm64
- name: Build iOS Framework
run: ./gradlew link${{ matrix.type }}FrameworkIosSimulatorArm64 -Porganization=${{ matrix.organization }}

android-lint:
name: Android Lint
Expand All @@ -38,7 +39,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run lint
run: ./gradlew lint
run: ./gradlew copyBrandingToCommonResources lint

- name: Uploads test reports
uses: actions/upload-artifact@v4
Expand All @@ -59,7 +60,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run lint
run: ./gradlew ktlintCheck
run: ./gradlew copyBrandingToCommonResources ktlintCheck

- name: Uploads test reports
uses: actions/upload-artifact@v4
Expand Down
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Multiplatform (Android and iOS currently) version of the Probe app.
- `commonMain` is for code that’s common for all targets.
- `androidMain` Android-specific code
- `iosMain` iOS-specific code written in Kotlin
- `dwMain` News Media Scan specific Branding and customization
- `ooniMain` OONI Probe specific Branding and customization

* `iosApp` contains the iOS application configuration and the engine integration written in Swift

Expand Down Expand Up @@ -40,3 +42,51 @@ besides platform-specific code that we can’t avoid, such as the loading our pr
* `shared` classes and methods shared across the whole app
* `data` data layer code (database, preferences, network...)
* `ui` UI layer code, organized into features/screens



### Build, Install, and Run

To build, install, and run your application, use the following commands:

- For OONI Probe:
```
./gradlew runDebug -Porganization=ooni
```

- For News Media Scan:
```
./gradlew runDebug -Porganization=dw
```

There is a custom gradle task(`copyBrandingToCommonResources`) that is used to copy brand specific resources to the common resources folder. This task is called before the `preBuild` task.

### Creating Run Configurations in Android Studio

Configure run configurations for easy execution within Android Studio:

#### OONI Probe Android Configuration

1. Click the **Plus (+)** sign in the top left corner of the "Run/Debug Configurations" dialog.
2. Choose 'Gradle'.
3. Configure with the following:
- **Name:** OONI_Probe
- **Run:** :composeApp:runDebug -Porganization=ooni

#### News Media Scan Android Configuration

1. Repeat the steps for creating a new configuration.
2. Configure with the following:
- **Name:** News_Media_Scan
- **Run:** :composeApp:runDebug -Porganization=dw

#### OONI Probe iOS Configuration

The "Run/Debug Configurations" already has the proper configuration and you just need to select the XCode Project Scheme `OONIProbe` and run it.

#### News Media Scan iOS Configuration
The "Run/Debug Configurations" already has the proper configuration and you just need to select the XCode Project Scheme `NewsMediaScan` and run it.

#### Switching between OONI Probe and News Media Scan
- Ensure you can run clean and build the project successfully.
- Run `pod install` in the `iosApp` directory.
35 changes: 20 additions & 15 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ kotlin {
iosSimulatorArm64()

cocoapods {
ios.deploymentTarget = "9.0"
ios.deploymentTarget = "12.0"

version = "1.0"
summary = "Compose App"
Expand Down Expand Up @@ -98,13 +98,6 @@ kotlin {
}
}

compose.resources {
customDirectory(
sourceSetName = "commonMain",
directoryProvider = provider { layout.projectDirectory.dir(config.resRoot) },
)
}

android {
namespace = "org.ooni.probe"
compileSdk = libs.versions.android.compileSdk.get().toInt()
Expand Down Expand Up @@ -157,13 +150,13 @@ ktlint {
additionalEditorconfig.put("ktlint_function_naming_ignore_when_annotated_with", "Composable")
}

tasks.register("copyCommonResourcesToFlavor") {
tasks.register("copyBrandingToCommonResources") {
doLast {
val projectDir = project.projectDir.absolutePath

val sourceFile = File(projectDir, "src/commonMain/composeResources")
val destinationFile = File(projectDir, "src/commonMain/composeResources")

val destinationFile = File(projectDir, config.resRoot)
val sourceFile = File(projectDir, config.resRoot)

copyRecursive(sourceFile, destinationFile)
}
Expand All @@ -173,7 +166,7 @@ tasks.register("cleanCopiedCommonResourcesToFlavor") {
doLast {
val projectDir = project.projectDir.absolutePath

val destinationFile = File(projectDir, config.resRoot)
val destinationFile = File(projectDir, "src/commonMain/composeResources")
destinationFile.listFiles()?.forEach { folder ->
folder.listFiles()?.forEach { file ->
if (file.name == ".gitignore") {
Expand All @@ -192,17 +185,17 @@ tasks.register("cleanCopiedCommonResourcesToFlavor") {
}

/**
* Configure the prepareComposeResourcesTaskForCommonMain task to depend on the copyCommonResourcesToFlavor task.
* Configure the prepareComposeResourcesTaskForCommonMain task to depend on the copyBrandingToCommonResources task.
* This will ensure that the common resources are copied to the correct location before the task is executed.
*
* NOTE: Current limitation is that multiple resources directories are not supported.
*/
tasks.named("preBuild").configure {
dependsOn("copyCommonResourcesToFlavor")
dependsOn("copyBrandingToCommonResources")
}

tasks.named("clean").configure {
dependsOn("copyCommonResourcesToFlavor")
dependsOn("copyBrandingToCommonResources")
}

tasks.named("clean").configure {
Expand Down Expand Up @@ -279,3 +272,15 @@ fun copyRecursive(
}
}
}

tasks.register("runDebug", Exec::class) {
dependsOn("clean", "uninstallDebug", "installDebug")
commandLine(
"adb",
"shell",
"am",
"start",
"-n",
"${config.appId}.debug/org.ooni.probe.MainActivity",
)
}
2 changes: 1 addition & 1 deletion composeApp/composeApp.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |spec|
spec.summary = 'Compose App'
spec.vendored_frameworks = 'build/cocoapods/framework/composeApp.framework'
spec.libraries = 'c++'
spec.ios.deployment_target = '9.0'
spec.ios.deployment_target = '12.0'


if !Dir.exist?('build/cocoapods/framework/composeApp.framework') || Dir.empty?('build/cocoapods/framework/composeApp.framework')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

logo.xml
2 changes: 2 additions & 0 deletions composeApp/src/commonMain/composeResources/values/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

strings-organization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.ui.Modifier
import ooniprobe.composeapp.generated.resources.Res
import ooniprobe.composeapp.generated.resources.app_name
import ooniprobe.composeapp.generated.resources.logo
import ooniprobe.composeapp.generated.resources.run_tests
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -47,8 +48,7 @@ fun DashboardScreen(
onClick = { onEvent(DashboardViewModel.Event.StartClick) },
enabled = !state.isRunning,
) {
// Text(stringResource(Res.string.run_tests))
Text("Run Tests")
Text(stringResource(Res.string.run_tests))
}

Image(
Expand Down
10 changes: 5 additions & 5 deletions composeApp/src/dwMain/kotlin/Config.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.ooni.probe.config

object Config {
object Config {
const val OONI_API_BASE_URL: String = "https://api.prod.ooni.io"
const val OONI_RUN_DASHBOARD_URL: String = "https://run-v2.ooni.org"
const val BASE_SOFTWARE_NAME: String = "news-media-scan"
}
const val OONI_API_BASE_URL: String = "https://api.prod.ooni.io"
const val OONI_RUN_DASHBOARD_URL: String = "https://run-v2.ooni.org"
const val BASE_SOFTWARE_NAME: String = "news-media-scan"
}
2 changes: 0 additions & 2 deletions composeApp/src/dwMain/resources/drawable/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions composeApp/src/dwMain/resources/values/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions composeApp/src/ooniMain/resources/drawable/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions composeApp/src/ooniMain/resources/values/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"

compose-plugin = "1.7.0-alpha02"
compose-plugin = "1.6.11"
kotlin = "2.0.0"

[plugins]
Expand Down
29 changes: 25 additions & 4 deletions iosApp/Podfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
platform :ios, '12.0'
use_frameworks!

target 'iosApp' do

ooni_version = "v3.22.0"
ooni_pods_location = "https://github.com/ooni/probe-cli/releases/download/#{ooni_version}"

target 'OONIProbe' do
pod 'composeApp', :path => '../composeApp'

ooni_version = "v3.22.0"
ooni_pods_location = "https://github.com/ooni/probe-cli/releases/download/#{ooni_version}"
pod "libcrypto", :podspec => "#{ooni_pods_location}/libcrypto.podspec"
pod "libevent", :podspec => "#{ooni_pods_location}/libevent.podspec"
pod "libssl", :podspec => "#{ooni_pods_location}/libssl.podspec"
pod "libtor", :podspec => "#{ooni_pods_location}/libtor.podspec"
pod "libz", :podspec => "#{ooni_pods_location}/libz.podspec"
pod "oonimkall", :podspec => "#{ooni_pods_location}/oonimkall.podspec"
end

target 'NewsMediaScan' do
pod 'composeApp', :path => '../composeApp'

pod "libcrypto", :podspec => "#{ooni_pods_location}/libcrypto.podspec"
pod "libevent", :podspec => "#{ooni_pods_location}/libevent.podspec"
pod "libssl", :podspec => "#{ooni_pods_location}/libssl.podspec"
pod "libtor", :podspec => "#{ooni_pods_location}/libtor.podspec"
pod "libz", :podspec => "#{ooni_pods_location}/libz.podspec"
pod "oonimkall", :podspec => "#{ooni_pods_location}/oonimkall.podspec"
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
4 changes: 2 additions & 2 deletions iosApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ EXTERNAL SOURCES:
:podspec: https://github.com/ooni/probe-cli/releases/download/v3.22.0/oonimkall.podspec

SPEC CHECKSUMS:
composeApp: 3f1f4ca4e070c2c0aa528bb1eb838ffc3860f5c0
composeApp: be6187105a7697f3cb0799a21bbbfddc5e65b077
libcrypto: 1bb58600c586e28688f5578f4675f5ffa46c8eaf
libevent: 5c8502ca5cc38be31bb510ddade0f238bcc5f0dc
libssl: 170bebcaf567a0285e91a8850b9686137d07c3e1
libtor: c72b23da6a5d2e16173149784f11cf66156c35be
libz: 83658eb2a0db785623ffdf9ce13407e6b8b5c8f9
oonimkall: 9768ce9dad18265d45d2ea972c84fb0bd5237cc3

PODFILE CHECKSUM: 04b498ba1984c25e9816234b0551222184c25492
PODFILE CHECKSUM: 5bcb6ea084168cab14bd0cd0f6e4775194adbc48

COCOAPODS: 1.15.2
Loading