문제

I am writing my own library. I want to catch crashes in my library. Library spawns several threads, writes to database, connects to remote servers etc.

My question: IS THERE A POSSIBILITY TO CATCH CRASHES THAT CAUSED ONLY BY MY LIBRARY?

UPDATE 1:

@try/@catch will only handle exceptions that are within method calls

@try {
do smth

//do async task in database

//start sending data to remote server


}
@catch {

}

UPDATE 2:

I want to catch NSExceptions, EX_BAD_ACCESS and, if possible SIGABRT, SIGKILL, low memory etc.

도움이 되었습니까?

해결책

No, this is not possible per library, especially since libraries on iOS will be statically linked into the actual apps. Crashes happen per app process, there is no way to limit a crash reporting library to a subset of an apps code.

Your only option is to test your code as good as possible so that it doesn't have bugs that can cause a crash. Use instruments, static analyzer, write tests.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top