Comments (32)
Managed to make it work (-:
I deleted main.m and appdelegate.{h,m} (not just commenting their content, although I think it didn't have any effect )
and did:
react-native unlink bugsnag-react-native
react-native link bugsnag-react-native
Thank you for your help, much appreciated!
from bugsnag-react-native.
I pushed a sample project to the swift-sample-project branch of the repository. Can you try checking it out and seeing if it runs for you? If so, maybe we can determine what setting is different from your project and causing the build error.
Steps to generate:
react-native init SturdyPants
cd SturdyPants
npm install bugsnag-react-native --save
react-native link
- Open Xcode, replace main.m, AppDelegate.{h,m} with AppDelegate.swift and Bridging-Header.h
- Add Bugsnag to bridging header, use from AppDelegate
from bugsnag-react-native.
Hello @yaronlevi, the bugsnag-react-native library already includes the bugsnag cocoa library as a dependency. You should not be using cocoapods to add it separately for react native projects. If you follow the react native setup instructions and configure the library from javascript, it will automatically catch exceptions from both javascript and swift environments.
from bugsnag-react-native.
I tried this, but errors from native code would not seem to be channeled to Bugsnag. For example, I tried this lines in my AppDelegate.swift, in the end of didFinishLaunchingWithOptions:
let arr = [2];
let n = arr[3];
return true
And the error would not apperar in my Bugsnag console
from bugsnag-react-native.
@yaronlevi Once the react native bugsnag library is installed, you can continue to use Bugsnag.start()
in your AppDelegate by importing "Bugsnag.h"
in your bridging header. There is also a podspec you can add to your Podfile using something like:
pod 'Bugsnag', :path => '../node_modules/bugsnag-react-native'
from bugsnag-react-native.
The only xcode project I have in my workspace is BugsnagReactNative.xcodeproj,
so I tried to import #import <BugsnagReactNative/BugsnagReactNative.h> but it won't let me use BugsnagReactNative.start()
But it let me call:
BugsnagReactNative.init()
Is it a viable option?
from bugsnag-react-native.
The only xcode project I have in my workspace is BugsnagReactNative.xcodeproj,
so I tried to import #import <BugsnagReactNative/BugsnagReactNative.h> but it won't let me use BugsnagReactNative.start()
If you expand the BugsnagReactNative
project in the Project pane of the sidebar, you’ll see that it contains a Libraries folder. Within libraries are its two dependencies, bugsnag-cocoa
and KSCrash
. These files reside in the bugsnag-react-native
directory in vendor/cocoa
. Its how it handles native exceptions under the hood. Instead of importing BugsnagReactNative.h, use Bugsnag.h, which is in the base library, and Bugsnag.start()
.
from bugsnag-react-native.
Ok, I am trying:
#import <BugsnagReactNative/Bugsnag.h>
#import <BugsnagReactNative/Bugsnag/Bugsnag.h>
#import <BugsnagReactNative/Libraries/Bugsnag/Bugsnag.h>
but for all of them I get file not found
from bugsnag-react-native.
Where did #import <BugsnagReactNative/Bugsnag.h>
come from? Try:
#import "Bugsnag.h"
from bugsnag-react-native.
They all sit inside myapp-Briding-Header.h . (attached an image)
from bugsnag-react-native.
and also this is the project structure:
from bugsnag-react-native.
Alright. Let's take a step back to figure out what's going on here. If I understand correctly, you have:
- successfully configured bugsnag-react-native using
npm
- are seeing JavaScript errors reported
- are not seeing some native errors being reported
Is that much correct?
from bugsnag-react-native.
correct.
I have bugsnag-react-native 2.0.2 installed.
Bugs from the js land are reported ok.
But now I want to import Bugsnag to my swift's appDelegate.
(and make it so that all unhandled expcetions in native code get reported as well)
from bugsnag-react-native.
Did you see a crash, but no report was generated on your project dashboard on bugsnag.com?
from bugsnag-react-native.
yes....I tried putting:
let arr = [2];
let n = arr[3];
inside appDelegate's didFinishLaunchingWithOptions.
no error was reported.
from bugsnag-react-native.
Got it. I've tested that importing "Bugsnag.h"
is working as expected from Objective-C, but there seems to be an issue with the umbrella header/module map when importing it from a bridging header for Swift. Investigating.
from bugsnag-react-native.
OK (and yes, I have changed my default react native project structure, so that instead of the regular generated AppDelegate.h and AppDelegate.m (which I've commented their entire content) I now have a AppDelegate.swift
(As you can see in the pictures I've uploaded)
from bugsnag-react-native.
What does the error message say when using #import "Bugsnag.h"
? I initially got a message indicating that the umbrella header could not be found, but after cleaning the project a few times, it works as expected and reported errors successfully after initializing with Bugsnag.start()
. Note that native crashes are not reported when a debugger is attached.
Test project
package.json
{
"name": "MyProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"bugsnag-react-native": "^2.1.0",
"react": "15.4.2",
"react-native": "0.42.0"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"react-test-renderer": "15.4.2"
},
"jest": {
"preset": "react-native"
}
}
MyProject-Bridging-Header.h
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "Bugsnag.h"
AppDelegate.swift
Uncomment the call to crashApp
to cause a crash, re-comment to stop crashing on launch and send reports.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Bugsnag.start(withApiKey: "YOUR-API-KEY-HERE")
let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index.ios", fallbackResource: nil)
let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "FancyPants", initialProperties: nil, launchOptions: launchOptions)
rootView?.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
window = UIWindow(frame: UIScreen.main.bounds)
let rootViewController = UIViewController()
rootViewController.view = rootView
window?.rootViewController = rootViewController
window?.makeKeyAndVisible()
// crashApp()
return true
}
func crashApp() {
let items = [2]
let item = items[34]
print("\(item) will never be printed")
}
}
from bugsnag-react-native.
Ok, will check this and report you in couple of hours.
from bugsnag-react-native.
Ok I tried clean and build several times but I still get the same result
Any other things I should check regarding xcode project references etc?
from bugsnag-react-native.
What does the error message say exactly when using #import "Bugsnag.h"
?
from bugsnag-react-native.
from bugsnag-react-native.
Great.. I am checking.
Nice. I've reproduced a working project as you described. Now comparing both projects to trace the differences.
from bugsnag-react-native.
Awesome!! 🎉
from bugsnag-react-native.
Sorry for opening the issue again. When I call:
Bugsnag.notifyError(NSError(domain:"com.example", code:408, userInfo:nil))
The error is being sent correctly to Bugsnag and I can see it in the dashboard. But when doing:
let arr = [2];
let n = arr[3];
I see not error being reported. I've tried it multiple times. (and also in the SturdyPants sample project).
Any clue to why this is happening?
from bugsnag-react-native.
Sure, if you look in the console, the error is being captured, but if you crash the app in the first moments it's open, there's not enough time to send the error report, as that happens in the background.
from bugsnag-react-native.
Actually it happens after the app is loaded, when I click a button:
from bugsnag-react-native.
I can see in the xcode console the error:
fatal error: Index out of range
But after that nothing about "crash reported" or KSCrashReports
from bugsnag-react-native.
Ok, everything is cool. The error is reported. But only after I restart the app.
from bugsnag-react-native.
Ah cool, makes sense. iOS is in an unstable state after an unhandled exception happens, so exceptions are only written to disk and sent on the next launch.
from bugsnag-react-native.
when you get the report, have you managed to get them symbolicated too? because i cant.
from bugsnag-react-native.
Actually I am dealing with this problem right now. Can't seem to get line numbers showing on errors in the dashboard.
from bugsnag-react-native.
Related Issues (20)
- Ask for user confirmation in registerBeforeSendCallback HOT 1
- Intermittent build failure on :bugsnag-react-native:verifyReleaseResources Gradle task HOT 2
- New version utilising new JS and Android versions? HOT 3
- the uploaded source map not getting applied HOT 1
- iOS: Definition of '' must be imported from module HOT 6
- Upload Hermes sourcemaps generated by CodePush HOT 1
- Unhandled crashes not sent. (iOS) HOT 2
- bugsnag-react-native does not support bugsnag-cocoa 6.0 HOT 6
- iOS Build Error: Include of a non-modular header inside framework module 'BugsnagReactNative.Bugsnag' HOT 6
- iOS Library misbehaves when dropping breadcrumbs HOT 4
- Cycle in dependencies between targets 'BugsnagReactNative' and 'FBSDKCoreKit'; HOT 2
- App crash during launch java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader HOT 4
- Files that shouldn't be in your npm package HOT 1
- Sourcemap path in case of android flavor builds HOT 3
- RN62.0: Multiple targets match implicit dependency for linker flag '-lBugsnagReactNative HOT 4
- Missing TS declarations '@bugsnag/react-native' ^7.3.1 HOT 4
- Missing TS definition for `codeBundleId` in Bugsnag.start() HOT 4
- Bugsnag Android Dependency Update HOT 1
- Please add back JS releaseStage and appVersion HOT 1
- Ability to set `errorClass` in new version? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bugsnag-react-native.