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

Feat: Capacitor v7 support #831

Merged
merged 4 commits into from
Feb 6, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
> [migration guide](https://docs.sentry.io/platforms/javascript/guides/capacitor/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Features

- Added support for Capacitor V7 ([#831](https://github.com/getsentry/sentry-capacitor/pull/831))

## 1.1.0

### Features
Expand Down
14 changes: 9 additions & 5 deletions SentryCapacitor.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ Pod::Spec.new do |s|

if File.exist?('../../@capacitor/core/package.json') == false
# If Capacitor was not found (could happen when using Yarn PNP), fallback to the
# required minimum version of Capacitor 4.
miniOSVersion = '13.0'
# required minimum version of Capacitor 7.
miniOSVersion = '14.0'
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved
else
capacitorPackage = JSON.parse(File.read(File.join(__dir__, '../../@capacitor/core/package.json')))
capacitorVersion = capacitorPackage['version']
if capacitorVersion.start_with?("2.") or capacitorVersion.start_with?("3.")
miniOSVersion = '12.0'
majorVersion = capacitorVersion.split('.').first.to_i

if majorVersion <= 3
miniOSVersion = '12.0' # Capacitor 3, 2.
elsif majorVersion < 7
miniOSVersion = '13.0' # Capacitor 6 or older.
else
miniOSVersion = '13.0' # Required for Capacitor 4 and newer.
miniOSVersion = '14.0' # Capacitor 7 or higher.
Comment on lines -25 to +32
Copy link
Member

@krystofwoldrich krystofwoldrich Feb 4, 2025

Choose a reason for hiding this comment

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

Does the Capacitor V7 fail to build without the matching minimum target?

I would have expected that a library could specify an older target than the framework, but I see that they say to match the target when upgrading the plugins.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it did for me, the sdk was set with min iOS version 13 and it was complaining that the project required version 14.

end
end
s.ios.deployment_target = miniOSVersion
Expand Down
24 changes: 19 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ def getCapacitorCompileSdkVersion() {

def GetCapacitorVersion() {
def compileVersion = getCapacitorCompileSdkVersion()
if (compileVersion >= 34) {
if (compileVersion >= 35) {
return 7
}
if (compileVersion == 34) {
return 6
}
else if (compileVersion == 33) {
Expand All @@ -30,9 +33,19 @@ def GetCapacitorVersion() {
def capVersion = GetCapacitorVersion()

def defaultSdkVersion = getCapacitorCompileSdkVersion()
def targetJavaVersion = JavaVersion.VERSION_17
if (capVersion >= 5) {
println "Sentry Capacitor: Applying defaults for Capacitor 5 or higher"
def defaultMinAndroidVersion = 23
def targetJavaVersion = JavaVersion.VERSION_21
if (capVersion >= 7) {
println "Sentry Capacitor: Applying defaults for Capacitor 7 or higher"
ext {
androidxAppCompatVersion = safeExtGet('androidxAppCompatVersion', '1.7.0')
androidxEspressoCoreVersion = safeExtGet('androidxEspressoCoreVersion', '3.6.1')
}
}
else if (capVersion >= 5) {
println "Sentry Capacitor: Applying defaults for Capacitor 5 and 6"
targetJavaVersion = JavaVersion.VERSION_17
defaultMinAndroidVersion = 22
ext {
androidxAppCompatVersion = safeExtGet('androidxAppCompatVersion', '1.6.1')
androidxEspressoCoreVersion = safeExtGet('androidxEspressoCoreVersion', '3.5.1')
Expand All @@ -41,6 +54,7 @@ if (capVersion >= 5) {
else {
println "Sentry Capacitor: Applying defaults for Capacitor 4."
targetJavaVersion = JavaVersion.VERSION_11
defaultMinAndroidVersion = 22
ext {
androidxEspressoCoreVersion = safeExtGet('androidxEspressoCoreVersion', '3.2.0')
}
Expand All @@ -52,7 +66,7 @@ android {
namespace "io.sentry.capacitor"
compileSdkVersion safeExtGet('compileSdkVersion', defaultSdkVersion)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 22) // Same for Capacitor 6 or lower
minSdkVersion safeExtGet('minSdkVersion', defaultMinAndroidVersion) // Same for Capacitor 6 or lower
targetSdkVersion safeExtGet('targetSdkVersion', defaultSdkVersion)
versionCode 1
versionName "1.0"
Expand Down
4 changes: 2 additions & 2 deletions example/ionic-angular-v5/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- CapacitorCordova
- CapacitorCordova (5.5.1)
- Sentry/HybridSDK (8.36.0)
- SentryCapacitor (1.0.0-beta.1):
- "SentryCapacitor (1.1.0+353d390b)":
- Capacitor
- Sentry/HybridSDK (= 8.36.0)

Expand All @@ -28,7 +28,7 @@ SPEC CHECKSUMS:
Capacitor: 9da0a2415e3b6098511f8b5ffdb578d91ee79f8f
CapacitorCordova: e128cc7688c070ca0bfa439898a5f609da8dbcfe
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
SentryCapacitor: ab15688e690007c3793b646f50b028a02fa909ee
SentryCapacitor: cc4fb59913373742c2cefa08a7b03d0158a09f9c

PODFILE CHECKSUM: 618eb4d85f9b0c9e5a37fffa86a92d1569bd6800

Expand Down
4 changes: 2 additions & 2 deletions example/ionic-angular-v6/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- CapacitorCordova
- CapacitorCordova (6.0.0)
- Sentry/HybridSDK (8.36.0)
- SentryCapacitor (1.0.0-beta.1):
- "SentryCapacitor (1.1.0+353d390b)":
- Capacitor
- Sentry/HybridSDK (= 8.36.0)

Expand All @@ -28,7 +28,7 @@ SPEC CHECKSUMS:
Capacitor: 559d073c4ca6c27f8e7002c807eea94c3ba435a9
CapacitorCordova: 8c4bfdf69368512e85b1d8b724dd7546abeb30af
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
SentryCapacitor: ab15688e690007c3793b646f50b028a02fa909ee
SentryCapacitor: cc4fb59913373742c2cefa08a7b03d0158a09f9c

PODFILE CHECKSUM: 618eb4d85f9b0c9e5a37fffa86a92d1569bd6800

Expand Down
6 changes: 6 additions & 0 deletions example/ionic-angular-v7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode/
typings/


# Sentry Auth Token
.sentryclirc
35 changes: 35 additions & 0 deletions example/ionic-angular-v7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Instructions for using the example app

## Add the local SDK from yalc

On the Sentry Capacitor root folder
`yalc publish`

Then on the ionic-angular folder
`yalc add @sentry/capacitor`

## Install dependencies

`yarn install`

## Build for native

`ionic build`

## Sync resources

`npx cap sync`

## Running

### Android

`npx cap open android`

### iOS

`npx cap open ios`

### Web

`http-server ./www`
91 changes: 91 additions & 0 deletions example/ionic-angular-v7/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# NPM renames .gitignore to .npmignore
# In order to prevent that, we remove the initial "."
# And the CLI then renames it

# Using Android gitignore template: https://github.com/github/gitignore/blob/master/Android.gitignore

# Built application files
*.apk
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

# Cordova plugins for Capacitor
capacitor-cordova-android-plugins

# Copied web assets
app/src/main/assets/public
48 changes: 48 additions & 0 deletions example/ionic-angular-v7/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apply plugin: 'com.android.application'

android {

namespace 'io.ionic.starter'
compileSdk rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "io.ionic.starter"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}

apply from: 'capacitor.build.gradle'

try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
21 changes: 21 additions & 0 deletions example/ionic-angular-v7/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="io.ionic.starter.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/custom_url_scheme" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
</manifest>
Loading
Loading