Skip to content

Commit f9f77af

Browse files
authored
iOS example (#7)
1 parent d5300bd commit f9f77af

File tree

19 files changed

+379
-159
lines changed

19 files changed

+379
-159
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true
7+
8+
[*.md]
9+
trim_trailing_whitespace = false
10+
11+
[*.sh]
12+
end_of_line = lf
13+
[*.{cmd, bat, ps1}]
14+
end_of_line = crlf
15+
16+
[*.{kt,kts}]
17+
indent_size=2

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,24 @@ jobs:
8080
echo Score too low!
8181
exit 1
8282
fi
83+
pod-lint:
84+
runs-on: macos-latest
85+
steps:
86+
- uses: actions/checkout@v2
87+
# https://github.com/CocoaPods/CocoaPods/issues/5275#issuecomment-315461879
88+
- run: pod lib lint ios/sentry_flutter.podspec --skip-import-validation
89+
swift-lint:
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v2
93+
- uses: norio-nomura/[email protected]
94+
ktlint:
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v2
98+
- run: brew install ktlint
99+
- name: run ktlint
100+
run: ktlint --reporter=checkstyle,output=build/ktlint-report.xml || true
101+
- uses: yutailang0119/[email protected]
102+
with:
103+
xml_path: build/ktlint-report.xml

.vscode/launch.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": "Flutter",
5+
"name": "Tests",
6+
"type": "dart",
67
"request": "launch",
7-
"type": "dart"
8+
"program": "./test/"
9+
},
10+
{
11+
"name": "Example",
12+
"request": "launch",
13+
"type": "dart",
14+
"program": "example/lib/main.dart"
815
}
916
]
1017
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Sentry SDK for Flutter
1111
[![build](https://github.com/getsentry/sentry-flutter/workflows/build/badge.svg?branch=main)](https://github.com/getsentry/sentry-flutter/actions?query=branch%3Amain)
1212

1313
This is a work in progress.
14-
A lot still to be done on [the base SDK](http://github.com/getsentry/sentry-dart) before the proper Flutter support is shipped.
14+
A lot still to be done on [the base SDK](https://github.com/getsentry/sentry-dart) before the proper Flutter support is shipped.
1515

1616
## Contributing
1717

@@ -31,5 +31,5 @@ We also run CI against the Flutter `stable` and `beta` channels so you should be
3131
* [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/platforms/dotnet/)
3232
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
3333
* [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
34-
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)
35-
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
34+
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry)
35+
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)

android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package io.sentry.flutter
22

3-
import androidx.annotation.NonNull;
4-
3+
import androidx.annotation.NonNull
54
import io.flutter.embedding.engine.plugins.FlutterPlugin
65
import io.flutter.plugin.common.MethodCall
76
import io.flutter.plugin.common.MethodChannel
87
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
98
import io.flutter.plugin.common.MethodChannel.Result
109
import io.flutter.plugin.common.PluginRegistry.Registrar
1110

12-
public class SentryFlutterPlugin: FlutterPlugin, MethodCallHandler {
13-
private lateinit var channel : MethodChannel
11+
public class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler {
12+
private lateinit var channel: MethodChannel
1413

1514
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
1615
channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "sentry_flutter")
17-
channel.setMethodCallHandler(this);
16+
channel.setMethodCallHandler(this)
1817
}
1918

2019
// Required by Flutter Android projects v1.12 and older

example/android/app/src/main/kotlin/io/sentry/flutter/example/MainActivity.kt

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package io.sentry.flutter.example
22

33
import android.content.Context
44
import androidx.annotation.NonNull
5-
import androidx.work.*
5+
import androidx.work.OneTimeWorkRequestBuilder
6+
import androidx.work.WorkManager
7+
import androidx.work.Worker
8+
import androidx.work.WorkerParameters
69
import io.flutter.embedding.android.FlutterActivity
710
import io.flutter.embedding.engine.FlutterEngine
811
import io.flutter.plugin.common.MethodChannel
912
import io.sentry.core.Sentry
1013

11-
class MainActivity: FlutterActivity() {
14+
class MainActivity : FlutterActivity() {
1215
private val _channel = "example.flutter.sentry.io"
1316

1417
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
@@ -17,33 +20,35 @@ class MainActivity: FlutterActivity() {
1720
call, result ->
1821
// Note: this method is invoked on the main thread.
1922
when (call.method) {
20-
"throw" -> {
21-
throw Exception("Thrown from Kotlin!")
22-
}
23-
"background" -> {
24-
WorkManager.getInstance(this)
25-
.enqueue(OneTimeWorkRequestBuilder<BrokenWorker>()
26-
.build())
27-
}
28-
"anr" -> {
29-
Thread.sleep(6_000)
30-
}
31-
"capture" -> {
32-
try {
33-
throw RuntimeException("Catch this exception!")
34-
} catch (e: Exception) {
35-
Sentry.captureException(e);
36-
}
37-
}
38-
"crash" -> {
39-
crash();
40-
}
41-
"native_capture_message" -> {
42-
message();
43-
}
44-
else -> {
45-
result.notImplemented()
23+
"throw" -> {
24+
throw Exception("Thrown from Kotlin!")
25+
}
26+
"background" -> {
27+
WorkManager.getInstance(this)
28+
.enqueue(
29+
OneTimeWorkRequestBuilder<BrokenWorker>()
30+
.build()
31+
)
32+
}
33+
"anr" -> {
34+
Thread.sleep(6_000)
35+
}
36+
"capture" -> {
37+
try {
38+
throw RuntimeException("Catch this exception!")
39+
} catch (e: Exception) {
40+
Sentry.captureException(e)
4641
}
42+
}
43+
"crash" -> {
44+
crash()
45+
}
46+
"cpp_capture_message" -> {
47+
message()
48+
}
49+
else -> {
50+
result.notImplemented()
51+
}
4752
}
4853
}
4954
}
@@ -57,10 +62,8 @@ class MainActivity: FlutterActivity() {
5762
}
5863
}
5964

60-
class BrokenWorker(appContext: Context, workerParams: WorkerParameters): Worker(appContext, workerParams)
61-
{
62-
override fun doWork(): Result
63-
{
65+
class BrokenWorker(appContext: Context, workerParams: WorkerParameters) : Worker(appContext, workerParams) {
66+
override fun doWork(): Result {
6467
throw RuntimeException("Kotlin background task")
6568
return Result.success()
6669
}

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>8.0</string>
24+
<string>9.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
PODS:
22
- Flutter (1.0.0)
3+
- Sentry (6.0.0-alpha.0):
4+
- Sentry/Core (= 6.0.0-alpha.0)
5+
- Sentry/Core (6.0.0-alpha.0)
36
- sentry_flutter (0.0.1):
47
- Flutter
8+
- Sentry (~> 6.0.0-alpha.0)
59

610
DEPENDENCIES:
711
- Flutter (from `Flutter`)
812
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
913

14+
SPEC REPOS:
15+
trunk:
16+
- Sentry
17+
1018
EXTERNAL SOURCES:
1119
Flutter:
1220
:path: Flutter
@@ -15,7 +23,8 @@ EXTERNAL SOURCES:
1523

1624
SPEC CHECKSUMS:
1725
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
18-
sentry_flutter: c52e6d52e8ea68cce219928ad98d176154c100dd
26+
Sentry: 7092bb6ed680769a1213cbd2ae37f43342dbd680
27+
sentry_flutter: 56fa44bdf7f77bbd77b8de55b10d8da993c14a85
1928

2029
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
2130

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 50;
77
objects = {
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11+
15A74CDF250075770078F130 /* Buggy.m in Sources */ = {isa = PBXBuildFile; fileRef = 15A74CDE250075770078F130 /* Buggy.m */; };
1112
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1213
4DFA0D3B754F0E702B3CB4B1 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B1A3E5A486E474A287B9BF /* Pods_Runner.framework */; };
1314
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
@@ -32,6 +33,8 @@
3233
/* Begin PBXFileReference section */
3334
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
3435
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
36+
15A74CDD250075770078F130 /* Buggy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Buggy.h; sourceTree = "<group>"; };
37+
15A74CDE250075770078F130 /* Buggy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Buggy.m; sourceTree = "<group>"; };
3538
38199AEAF0F80C193173BC10 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
3639
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3740
4F22DC026405C7E7F57CEBA6 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
@@ -68,7 +71,6 @@
6871
4F22DC026405C7E7F57CEBA6 /* Pods-Runner.release.xcconfig */,
6972
768362D06CA53D13052997C4 /* Pods-Runner.profile.xcconfig */,
7073
);
71-
name = Pods;
7274
path = Pods;
7375
sourceTree = "<group>";
7476
};
@@ -105,6 +107,8 @@
105107
97C146F01CF9000F007C117D /* Runner */ = {
106108
isa = PBXGroup;
107109
children = (
110+
15A74CDD250075770078F130 /* Buggy.h */,
111+
15A74CDE250075770078F130 /* Buggy.m */,
108112
97C146FA1CF9000F007C117D /* Main.storyboard */,
109113
97C146FD1CF9000F007C117D /* Assets.xcassets */,
110114
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
@@ -239,15 +243,12 @@
239243
buildActionMask = 2147483647;
240244
files = (
241245
);
242-
inputPaths = (
243-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
244-
"${PODS_ROOT}/../Flutter/Flutter.framework",
245-
"${BUILT_PRODUCTS_DIR}/sentry_flutter/sentry_flutter.framework",
246+
inputFileListPaths = (
247+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
246248
);
247249
name = "[CP] Embed Pods Frameworks";
248-
outputPaths = (
249-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
250-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sentry_flutter.framework",
250+
outputFileListPaths = (
251+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
251252
);
252253
runOnlyForDeploymentPostprocessing = 0;
253254
shellPath = /bin/sh;
@@ -275,6 +276,7 @@
275276
isa = PBXSourcesBuildPhase;
276277
buildActionMask = 2147483647;
277278
files = (
279+
15A74CDF250075770078F130 /* Buggy.m in Sources */,
278280
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
279281
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
280282
);
@@ -343,7 +345,7 @@
343345
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
344346
GCC_WARN_UNUSED_FUNCTION = YES;
345347
GCC_WARN_UNUSED_VARIABLE = YES;
346-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
348+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
347349
MTL_ENABLE_DEBUG_INFO = NO;
348350
SDKROOT = iphoneos;
349351
SUPPORTED_PLATFORMS = iphoneos;
@@ -365,7 +367,10 @@
365367
"$(PROJECT_DIR)/Flutter",
366368
);
367369
INFOPLIST_FILE = Runner/Info.plist;
368-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
370+
LD_RUNPATH_SEARCH_PATHS = (
371+
"$(inherited)",
372+
"@executable_path/Frameworks",
373+
);
369374
LIBRARY_SEARCH_PATHS = (
370375
"$(inherited)",
371376
"$(PROJECT_DIR)/Flutter",
@@ -425,7 +430,7 @@
425430
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
426431
GCC_WARN_UNUSED_FUNCTION = YES;
427432
GCC_WARN_UNUSED_VARIABLE = YES;
428-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
433+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
429434
MTL_ENABLE_DEBUG_INFO = YES;
430435
ONLY_ACTIVE_ARCH = YES;
431436
SDKROOT = iphoneos;
@@ -474,11 +479,12 @@
474479
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
475480
GCC_WARN_UNUSED_FUNCTION = YES;
476481
GCC_WARN_UNUSED_VARIABLE = YES;
477-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
482+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
478483
MTL_ENABLE_DEBUG_INFO = NO;
479484
SDKROOT = iphoneos;
480485
SUPPORTED_PLATFORMS = iphoneos;
481-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
486+
SWIFT_COMPILATION_MODE = wholemodule;
487+
SWIFT_OPTIMIZATION_LEVEL = "-O";
482488
TARGETED_DEVICE_FAMILY = "1,2";
483489
VALIDATE_PRODUCT = YES;
484490
};
@@ -497,7 +503,10 @@
497503
"$(PROJECT_DIR)/Flutter",
498504
);
499505
INFOPLIST_FILE = Runner/Info.plist;
500-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
506+
LD_RUNPATH_SEARCH_PATHS = (
507+
"$(inherited)",
508+
"@executable_path/Frameworks",
509+
);
501510
LIBRARY_SEARCH_PATHS = (
502511
"$(inherited)",
503512
"$(PROJECT_DIR)/Flutter",
@@ -524,7 +533,10 @@
524533
"$(PROJECT_DIR)/Flutter",
525534
);
526535
INFOPLIST_FILE = Runner/Info.plist;
527-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
536+
LD_RUNPATH_SEARCH_PATHS = (
537+
"$(inherited)",
538+
"@executable_path/Frameworks",
539+
);
528540
LIBRARY_SEARCH_PATHS = (
529541
"$(inherited)",
530542
"$(PROJECT_DIR)/Flutter",

0 commit comments

Comments
 (0)