Skip to content

Commit 1073b21

Browse files
authored
Merge pull request #16 from getsentry/feature/podspec
Cocoapods support
2 parents e82496c + 292e389 commit 1073b21

File tree

5 files changed

+88
-4
lines changed

5 files changed

+88
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
*Requirements:*
1010

11-
* `react-native >= 0.41`
11+
* `react-native >= 0.38`
1212
* sentry-cli > 0.26 (`brew install getsentry/tools/sentry-cli`)
1313

1414
With this SDK, Sentry is now able to provide mixed stacktraces. This means that if a JavaScript call causes a crash in native code, you will see the last call from JavaScript before the crash. This also means that with the new SDK, native crashes are properly handled on iOS.

SentryReactNative.podspec

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'json'
2+
3+
Pod::Spec.new do |s|
4+
# NPM package specification
5+
package = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'package.json')))
6+
7+
s.name = 'SentryReactNative'
8+
s.version = package['version']
9+
s.license = 'MIT'
10+
s.summary = 'Official Sentry client for react-native'
11+
s.author = 'Sentry'
12+
s.homepage = "https://github.com/getsentry/react-native-sentry"
13+
s.source = { :git => 'https://github.com/getsentry/react-native-sentry.git', :tag => "#{s.version}"}
14+
15+
s.ios.deployment_target = "8.0"
16+
s.tvos.deployment_target = "9.0"
17+
18+
s.preserve_paths = '*.js'
19+
20+
s.dependency 'React'
21+
s.dependency 'Sentry', '~> 2.1.3'
22+
s.dependency 'RSSwizzle', '~> 0.1.0'
23+
24+
s.source_files = 'ios/RNSentry.{h,m}'
25+
s.public_header_files = 'ios/RNSentry.h'
26+
end

docs/index.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The `link` step will pull in the native dependency. If you are using
2727
Android or expo you don't have to (or can't) run that step. In that case
2828
we fall back automatically.
2929

30-
Note that we only support ``react-native >= 0.41`` at the moment and you
30+
Note that we only support ``react-native >= 0.38`` at the moment and you
3131
will have to make sure a recent version of :ref:`sentry-cli <sentry-cli>`
3232
installed.
3333

@@ -104,6 +104,52 @@ Example:
104104
--bundle-output android.main.bundle \
105105
--sourcemap-output android.main.bundle.map
106106
107+
Setup With Cocoapods
108+
--------------------
109+
110+
In order to use Sentry with cocoapods you have to install the packages with
111+
``npm`` or ``yarn`` and link them locally in your ``Podfile``.
112+
113+
.. code-block:: bash
114+
npm install --save react react-native react-native-sentry
115+
116+
After that change your ``Podfile`` to reference to the packages in your
117+
``node_modules`` folder.
118+
119+
.. code-block:: bash
120+
platform :ios, '8.0'
121+
use_frameworks!
122+
123+
node_modules_path = './node_modules'
124+
react_path = File.join(node_modules_path, 'react-native')
125+
yoga_path = File.join(react_path, 'ReactCommon/yoga')
126+
sentry_path = File.join(node_modules_path, 'react-native-sentry')
127+
128+
target 'YOUR-TARGET' do
129+
pod 'Yoga', :path => yoga_path
130+
pod 'React', :path => react_path, :subspecs => [
131+
'Core',
132+
'RCTImage',
133+
'RCTNetwork',
134+
'RCTText',
135+
'RCTWebSocket',
136+
# Add any other subspecs you want to use in your project
137+
]
138+
pod 'SentryReactNative', :path => sentry_path
139+
end
140+
141+
post_install do |installer|
142+
installer.pods_project.build_configurations.each do |config|
143+
config.build_settings['SWIFT_VERSION'] = '3.0'
144+
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
145+
end
146+
end
147+
148+
After that run ``pod install`` which then should link everything correctly.
149+
If you need more information about how to load the react view check out
150+
`this tutorial.
151+
<https://facebook.github.io/react-native/releases/0.23/docs/embedded-app-ios.html>`_
152+
107153
Client Configuration
108154
--------------------
109155

ios/RNSentry.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
#import <React/RCTBridgeModule.h>
1+
#if __has_include(<React/RCTBridge.h>)
2+
#import <React/RCTBridge.h>
3+
#else
4+
#import "RCTBridge.h"
5+
#endif
6+
#if __has_include(<React/RCTExceptionsManager.h>)
27
#import <React/RCTExceptionsManager.h>
8+
#else
9+
#import "RCTExceptionsManager.h"
10+
#endif
11+
#if __has_include(<React/RCTRootView.h>)
312
#import <React/RCTRootView.h>
13+
#else
14+
#import "RCTRootView.h"
15+
#endif
416

517
@interface RNSentry : NSObject <RCTBridgeModule, RCTExceptionsManagerDelegate>
618

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "Sentry",
1717
"license": "MIT",
1818
"peerDependencies": {
19-
"react-native": ">=0.41.0"
19+
"react-native": ">=0.38.0"
2020
},
2121
"dependencies": {
2222
"raven-js": "3.12.1"

0 commit comments

Comments
 (0)