diff --git a/.run/androidApp-cocoapods.run.xml b/.run/androidApp-cocoapods.run.xml deleted file mode 100644 index 5ca5075e2..000000000 --- a/.run/androidApp-cocoapods.run.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.run/iosApp-cocoapods.run.xml b/.run/iosApp-cocoapods.run.xml deleted file mode 100644 index a8eab2077..000000000 --- a/.run/iosApp-cocoapods.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Makefile b/Makefile index 71b5662a7..29efd62fa 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,9 @@ buildProject: # Build Apple Samples buildAppleSamples: ./gradlew build -p sentry-samples - cd ./sentry-samples/kmp-app-cocoapods/iosApp/iosApp && touch iosApp.xcconfig - # cd ./sentry-samples/kmp-app-mvvm-di/iosApp && touch iosApp.xcconfig + cd ./sentry-samples/kmp-app-spm/iosApp && touch iosApp.xcconfig sudo xcode-select --switch /Applications/Xcode.app && /usr/bin/xcodebuild -version - ./gradlew ":sentry-samples:kmp-app-cocoapods:shared:podInstall" - cd ./sentry-samples/kmp-app-cocoapods/iosApp; pod update; - xcodebuild -workspace ./sentry-samples/kmp-app-cocoapods/iosApp/iosApp.xcworkspace -scheme iosApp -configuration Debug -sdk iphonesimulator -arch arm64 - # xcodebuild -project ./sentry-samples/kmp-app-mvvm-di/iosApp.xcodeproj -scheme iosApp -configuration Debug -sdk iphonesimulator -arch arm64 + xcodebuild -project ./sentry-samples/kmp-app-spm/iosApp.xcodeproj -scheme iosApp -configuration Debug -sdk iphonesimulator -arch arm64 # Build all targets, run tests and checks api diff --git a/build.gradle.kts b/build.gradle.kts index 806c63087..7ce024a29 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,6 @@ plugins { id(Config.QualityPlugins.detekt).version(Config.QualityPlugins.detektVersion) id(Config.dokka).version(Config.dokkaVersion) kotlin(Config.multiplatform).version(Config.kotlinVersion).apply(false) - kotlin(Config.cocoapods).version(Config.kotlinVersion).apply(false) id(Config.spmForKmp).version(Config.spmForKmpVersion).apply(false) id(Config.jetpackCompose).version(Config.composePluginVersion).apply(false) id(Config.kotlinCompose).version(Config.kotlinVersion).apply(false) diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 8abb7f575..048882536 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -5,7 +5,6 @@ object Config { val gradleMavenPublishPluginVersion = "0.30.0" val multiplatform = "multiplatform" - val cocoapods = "native.cocoapods" val spmForKmp = "io.github.frankois944.spmForKmp" val spmForKmpVersion = "1.9.3" val jetpackCompose = "org.jetbrains.compose" diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index d7d839707..59e6812f5 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -19,19 +19,17 @@ VERSION_NAME_PATTERN="versionName" perl -pi -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $GRADLE_FILEPATH perl -pi -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $PLUGIN_GRADLE_FILEPATH -PODSPEC_FILEPATH='sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec' -PODSPEC_CONTENT=$(cat $PODSPEC_FILEPATH) +CONFIG_FILEPATH='buildSrc/src/main/java/Config.kt' +CONFIG_CONTENT=$(cat $CONFIG_FILEPATH) -PODSPEC_REGEX="('Sentry', *)'([0-9\.]+)'" +COCOA_VERSION_REGEX='sentryCocoaVersion *= *"([0-9\.]+)"' -if ! [[ $PODSPEC_CONTENT =~ $PODSPEC_REGEX ]]; then - echo "Failed to find the Cocoa version in $PODSPEC_FILEPATH" +if ! [[ $CONFIG_CONTENT =~ $COCOA_VERSION_REGEX ]]; then + echo "Failed to find the Cocoa version in $CONFIG_FILEPATH" exit 1 fi -PODSPEC_WHOLE_MATCH=${BASH_REMATCH[0]} -PODSPEC_VAR_NAME=${BASH_REMATCH[1]} -PODSPEC_VERSION=${BASH_REMATCH[2]} +PODSPEC_VERSION=${BASH_REMATCH[1]} # create a new table entry in readme with NEW_VERSION and PODSPEC_VERSION in the compatibility table # Find the line number of the last entry in the compatibility table and insert the new entry after it diff --git a/scripts/update-cocoa.sh b/scripts/update-cocoa.sh index da0db50d3..73e330ccc 100755 --- a/scripts/update-cocoa.sh +++ b/scripts/update-cocoa.sh @@ -3,19 +3,19 @@ cd $(dirname "$0")/../ config_file='buildSrc/src/main/java/Config.kt' -podspec_file='sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec' plugin_properties_file='sentry-kotlin-multiplatform-gradle-plugin/gradle.properties' -sample_podspec_file='sentry-samples/kmp-app-cocoapods/shared/shared.podspec' -sample_ios_app_dir='sentry-samples/kmp-app-cocoapods/iosApp' +spm_sample_pbxproj_file='sentry-samples/kmp-app-spm/iosApp.xcodeproj/project.pbxproj' +spm_sample_project='sentry-samples/kmp-app-spm/iosApp.xcodeproj' +spm_sample_scheme='iosApp' config_content=$(cat $config_file) -podspec_content=$(cat $podspec_file) plugin_properties_content=$(cat $plugin_properties_file) -sample_podspec_content=$(cat $sample_podspec_file) +pbxproj_content=$(cat $spm_sample_pbxproj_file) config_regex='(sentryCocoaVersion *= *)"([0-9\.]+)"' -podspec_regex="('Sentry', *)'([0-9\.]+)'" plugin_properties_regex='(sentryCocoaVersion *= *)([0-9\.]+)' +# Matches the sentry-cocoa SwiftPM pin in the SPM sample, e.g. `version = 8.58.2;` +pbxproj_regex='(version = )([0-9\.]+)(;)' if ! [[ $config_content =~ $config_regex ]]; then echo "Failed to find the Cocoa version in $config_file" @@ -26,14 +26,6 @@ config_whole_match=${BASH_REMATCH[0]} config_var_name=${BASH_REMATCH[1]} config_version=${BASH_REMATCH[2]} -if ! [[ $podspec_content =~ $podspec_regex ]]; then - echo "Failed to find the Cocoa version in $podspec_file" - exit 1 -fi - -podspec_whole_match=${BASH_REMATCH[0]} -podspec_var_name=${BASH_REMATCH[1]} - if ! [[ $plugin_properties_content =~ $plugin_properties_regex ]]; then echo "Failed to find the Cocoa version in $plugin_properties_file" exit 1 @@ -42,13 +34,12 @@ fi plugin_properties_whole_match=${BASH_REMATCH[0]} plugin_properties_var_name=${BASH_REMATCH[1]} -if ! [[ $sample_podspec_content =~ $podspec_regex ]]; then - echo "Failed to find the Cocoa version in $sample_podspec_file" +if ! [[ $pbxproj_content =~ $pbxproj_regex ]]; then + echo "Failed to find the sentry-cocoa SwiftPM version in $spm_sample_pbxproj_file" exit 1 fi -sample_podspec_whole_match=${BASH_REMATCH[0]} -sample_podspec_var_name=${BASH_REMATCH[1]} +pbxproj_whole_match=${BASH_REMATCH[0]} case $1 in get-version) @@ -63,28 +54,21 @@ set-version) newValue="${config_var_name}\"$2"\" echo "${config_content/${config_whole_match}/$newValue}" >$config_file - # Update the version in the podspec file - newValue="${podspec_var_name}'$2'" - echo "${podspec_content/${podspec_whole_match}/$newValue}" >$podspec_file - # Update the version in the plugin properties file newValue="${plugin_properties_var_name}$2" echo "${plugin_properties_content/${plugin_properties_whole_match}/$newValue}" >$plugin_properties_file - # Update the version in the sample podspec file - newValue="${sample_podspec_var_name}'$2'" - echo "${sample_podspec_content/${sample_podspec_whole_match}/$newValue}" >$sample_podspec_file - - # Generate dummy framework first (required for pod update to work) - echo "Generating dummy framework for shared module..." - ./gradlew :sentry-samples:kmp-app-cocoapods:shared:generateDummyFramework + # Update the sentry-cocoa SwiftPM pin in the SPM sample Xcode project + newValue="version = $2;" + echo "${pbxproj_content/${pbxproj_whole_match}/$newValue}" >$spm_sample_pbxproj_file - # Run pod update in the sample iOS app directory to update Podfile.lock - echo "Running pod update in $sample_ios_app_dir..." - (cd $sample_ios_app_dir && pod update) + # Refresh the SPM sample lockfiles (Package.resolved) so the pinned revision + # matches the new version. + echo "Resolving SwiftPM dependencies for the SPM sample..." + xcodebuild -resolvePackageDependencies -project $spm_sample_project -scheme $spm_sample_scheme ;; *) echo "Unknown argument $1" exit 1 ;; -esac \ No newline at end of file +esac diff --git a/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec b/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec deleted file mode 100644 index 251872b27..000000000 --- a/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec +++ /dev/null @@ -1,57 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'sentry_kotlin_multiplatform' - spec.version = '0.0.1' - spec.homepage = 'https://github.com/getsentry/sentry-kotlin-multiplatform' - spec.source = { :http=> ''} - spec.authors = '' - spec.license = '' - spec.summary = 'Official Sentry SDK Kotlin Multiplatform' - spec.vendored_frameworks = 'build/cocoapods/framework/sentry_kotlin_multiplatform.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '11.0' - spec.osx.deployment_target = '10.13' - spec.tvos.deployment_target = '11.0' - spec.watchos.deployment_target = '4.0' - spec.dependency 'Sentry', '8.58.2' - - if !Dir.exist?('build/cocoapods/framework/sentry_kotlin_multiplatform.framework') || Dir.empty?('build/cocoapods/framework/sentry_kotlin_multiplatform.framework') - raise " - - Kotlin framework 'sentry_kotlin_multiplatform' doesn't exist yet, so a proper Xcode project can't be generated. - 'pod install' should be executed after running ':generateDummyFramework' Gradle task: - - ./gradlew :sentry-kotlin-multiplatform:generateDummyFramework - - Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" - end - - spec.xcconfig = { - 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', - } - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':sentry-kotlin-multiplatform', - 'PRODUCT_MODULE_NAME' => 'sentry_kotlin_multiplatform', - } - - spec.script_phases = [ - { - :name => 'Build sentry_kotlin_multiplatform', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end diff --git a/sentry-samples/kmp-app-cocoapods/androidApp/build.gradle.kts b/sentry-samples/kmp-app-cocoapods/androidApp/build.gradle.kts deleted file mode 100644 index 3b28133e5..000000000 --- a/sentry-samples/kmp-app-cocoapods/androidApp/build.gradle.kts +++ /dev/null @@ -1,73 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -plugins { - id("com.android.application") - kotlin("android") - id("io.sentry.android.gradle") version "4.0.0" -} - -android { - namespace = "sample.kmp.app.android" - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - compileSdk = Config.Android.compileSdkVersion - defaultConfig { - applicationId = "sample.kmp.app.android" - minSdk = Config.Android.minSdkVersion - targetSdk = Config.Android.targetSdkVersion - versionCode = 1 - versionName = "1.0" - } - signingConfigs { - create("release") { - storeFile = file("sentry.keystore") - storePassword = "sentry" - keyAlias = "Sentry Android Key" - keyPassword = "sentry" - } - } - buildTypes { - getByName("release") { - isDefault = true - isMinifyEnabled = true - proguardFiles.add(getDefaultProguardFile("proguard-android-optimize.txt")) - signingConfig = signingConfigs.getByName("release") - } - } -} - -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - -kotlin { - compilerOptions { - jvmTarget = JvmTarget.JVM_11 - } -} - -dependencies { - implementation(rootProject.project(":sentry-samples:kmp-app-cocoapods:shared")) - implementation("com.google.android.material:material:1.6.1") - implementation("androidx.appcompat:appcompat:1.4.2") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") -} - -// Prevent Sentry from being included in the Android app through the AGP. -configurations { - compileOnly { - exclude(group = "io.sentry", module = "sentry") - exclude(group = "io.sentry", module = "sentry-android") - } -} - -sentry { - autoUploadProguardMapping.set(false) -} diff --git a/sentry-samples/kmp-app-cocoapods/androidApp/sentry.keystore b/sentry-samples/kmp-app-cocoapods/androidApp/sentry.keystore deleted file mode 100644 index 3d6ddc7c1..000000000 Binary files a/sentry-samples/kmp-app-cocoapods/androidApp/sentry.keystore and /dev/null differ diff --git a/sentry-samples/kmp-app-cocoapods/androidApp/src/main/AndroidManifest.xml b/sentry-samples/kmp-app-cocoapods/androidApp/src/main/AndroidManifest.xml deleted file mode 100644 index 9e4b74b77..000000000 --- a/sentry-samples/kmp-app-cocoapods/androidApp/src/main/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/sentry-samples/kmp-app-cocoapods/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt b/sentry-samples/kmp-app-cocoapods/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt deleted file mode 100644 index 388efb17a..000000000 --- a/sentry-samples/kmp-app-cocoapods/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt +++ /dev/null @@ -1,76 +0,0 @@ -package sample.kmp.app.android - -import android.app.Application -import android.os.Bundle -import android.widget.Button -import androidx.appcompat.app.AppCompatActivity -import io.sentry.kotlin.multiplatform.Attachment -import io.sentry.kotlin.multiplatform.Sentry -import io.sentry.kotlin.multiplatform.protocol.Breadcrumb -import sample.kmp.app.LoginImpl -import sample.kmp.app.Platform -import sample.kmp.app.configureSentryScope -import sample.kmp.app.initializeSentry -import java.io.FileOutputStream -import java.io.IOException - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val captureMessageBtn: Button = findViewById(R.id.captureMessageBtn) - val captureExceptionBtn: Button = findViewById(R.id.captureExceptionBtn) - val captureHardCrashBtn: Button = findViewById(R.id.captureHardCrash) - - captureMessageBtn.setOnClickListener { - Sentry.captureMessage("From KMP Sample App: " + Platform().platform) - } - - captureExceptionBtn.setOnClickListener { - LoginImpl.login("MyUsername") - } - - captureHardCrashBtn.setOnClickListener { - LoginImpl.login() - } - } -} - -class SentryApplication : Application() { - override fun onCreate() { - super.onCreate() - - // Initialize Sentry using shared code - initializeSentry() - - // Shared scope across all platforms - configureSentryScope() - - val imageFile = applicationContext.getFileStreamPath("sentry.png") - try { - applicationContext.resources.openRawResource(R.raw.sentry).use { inputStream -> - FileOutputStream(imageFile).use { outputStream -> - val bytes = ByteArray(1024) - while (inputStream.read(bytes) !== -1) { - // To keep the sample code simple this happens on the main thread. Don't do this in a - // real app. - outputStream.write(bytes) - } - outputStream.flush() - } - } - } catch (e: IOException) { - Sentry.captureException(e) - } - - val imageAttachment = Attachment(imageFile.getAbsolutePath(), "sentry.png", "image/png") - - // Add platform specific scope in addition to the shared scope - Sentry.configureScope { - it.setContext("Android Context", mapOf("context1" to 12, "context2" to false)) - it.addBreadcrumb(Breadcrumb.debug("initialized Sentry on Android")) - it.addAttachment(imageAttachment) - } - } -} diff --git a/sentry-samples/kmp-app-cocoapods/androidApp/src/main/res/layout/activity_main.xml b/sentry-samples/kmp-app-cocoapods/androidApp/src/main/res/layout/activity_main.xml deleted file mode 100644 index 024e73437..000000000 --- a/sentry-samples/kmp-app-cocoapods/androidApp/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - -