Realm stops processing my code without crashes the app - ios

For some reason when I call let realm = Realm() it stops processing (doesn't crash) my code. My app is still running, but the screen keep frozen.
When I try to open default.realm using realm browser app, it shows me:
Again, it doesn't crash my app. It is a kind of pause.
No braekepoints
I've already tried: cocoapods and xcode install
I've already tried run on simulator and device (iPad)
App already deleted
Project cleaned up
Derived data cleaned up

Related

Looking for local crashlog when device was tethered to Xcode

Question:
When iOS device is tethered to Xcode and crashed after building (app loaded in, was not a crash ON build), where is the crash log saved to?
Here's my predicament with some context:
I pulled a user's crashlog of EXC_BAD_ACCESS for my app. I symbolicated and I've narrowed it down to get a rough idea but now I'm trying to re-create the issue via building in Xcode to my iOS device (not simulator). Normally the app does not crash on load in (this crash isn't easy to replicate) but I've been able to have the app crash consistently with Address Sanitizer enabled, and it always crashed and points to a line in a thread with an men address -- not anything I don't already have from previous debugging.
However, one time I had a crash occur where it highlighted what func was called as well as every func called in the stack trace and what file this was all occurring in. In haste I hit build again in Xcode before I saved the output however... and now I cannot replicate.
The crashlog wasn't saved locally to my iOS device as I was still tethered to Xcode, and I checked ~Library/Logs/CrashReporter/MobileDevice but that did not contain them either.
I need find where Xcode would've saved these logs on my mac (if it did at all)?
Typically all the crash dumps are stored in Settings -> Privacy -> Diagnostics & Usage -> Diagnostics & Usage Data
Scroll down the list and find the crash file with your app name.
This link might be helpful - https://developer.apple.com/library/content/qa/qa1747/_index.html

UserDefaults - not saving consistently when using Xcode Simulator

I am learning iOS development and I have stumbled across an issue where UserDefaults doesn't seem to be consistently saving correctly.
When I open the app, it checks to see if a UserDefaults property exists, if so, it does something. Now, if I save the UserDefaults property and 'synchronize', then press stop on the simulator and then press 'play' again to re-open it, sometimes the UserDefaults value is nil.
I have yet to test this on a physical device, but has anyone had the same issue - if so, is it expected?
Maybe UserDefaults work fine but when you save some data to UserDefaults and rebuild or run use Command + R if already running simulator
then sometimes nothing changed (saved data disappear)
so everytime when this situation(have to save some data to UserDefaults , CoreData or Realm) I stop and exit simulator first and rebuild or run Xcode
it works fine to me

iOS app crashes immediately when debugging AppleWatch app on Simulator (not on device)

I've got an AppleWatch app that is working fine in Simulator and Device, but when I call openParentApplication, it appears that the parent app is crashing immediately because I see this in the console output:
The UIApplicationDelegate in the iPhone App never called reply()...
When I try to manually launch the parent iOS app in the Simulator it crashes there too immediately. I don't have time to attach the debugger (which is already attached to the AppleWatch app) to see what is crashing it. Note that the parent app runs fine when the AppleWatch is running and I'm using a real iPhone. I can also run the app fine on the Simulator when not debugging the AppleWatch app.
I've tried resetting the Simulator, but problem persists.
I'm just not sure how to debug this. Any help is appreciated.
Start an explicit background task in handleWatchKitRequest. Otherwise, your app gets killed before it reaches reply().
Refer to this post for a code example on how to create a background task.
In turns out that after commenting out all code in the parent app's didFinishLaunching and stripping almost all code out of the watch extension, the problem was indeed at a lower level.
The Simulator has a
Debug | Open System Log...
menu option that showed the crash logs, which contained:
Dyld Error Message: Library not loaded:
#rpath/MyCore.framework/MyCore Referenced from:
/Users/me/Library/Developer/CoreSimulator/Devices/A2061705-DDDF-477C-9AAA-E50GG43A6350/data/Containers/Bundle/Application/DEB7FB25-8233-4B9F-8DAB-9FF8AE42BF33/MyApp.app/MyApp
Reason: no suitable image found. Did find:
/Users/me/Library/Developer/CoreSimulator/Devices/A2061705-DDDF-477C-9AAA-E50FF43A6350/data/Containers/Bundle/Application/DEB7FB25-8553-4B9F-8DAB-9FF8AE95BF33/MyApp.app/Frameworks/MyCore.framework/MyCore:
mach-o, but wrong architecture
My Swift app has a few dependent Swift projects that are used by the app and extension. Getting the Swift frameworks to link has been a major pain. I've included the dependent frameworks (compiled in the same workspace) as embedded binaries. This works when running on the device, or on the Simulator, but not when running in this hybrid watch app + parent app Simulator context.
I changed the embedded binary references to point to the frameworks under ...DerivedData...Debug-iphonesimulator, as opposed to ...DerivedData...Debug-iphoneos, and the problem went away.
Still hoping the Swift framework story will improve.
Are you seeing an actual crash? That message has appeared for me plenty of times without the host app crashing.
99% of the time, that error appears because developers aren't opening a background task to complete their work in handleWatchKitRequest. Without the background task, the OS kills your app in the background before it has a chance to reply.

Xcode 6.1 builds crashing on device

I recently made the mistake of upgrading to Xcode 6.1 (release version - 6A1052d) from 6.0.1 where everything was working fine. Upon first loading the project, I immediately had numerous errors, which I corrected by removing ?s or adding !s and commenting out an Apple supplied line from the persistent store coordinator in the app delegate:
// error = NSError.errorWithDomain("YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
My app now runs fine in the simulator, but on my device it crashes almost immediately after the build succeeds and takes me to lldb with almost no useful information. Currently it crashes on my first println statements, but I've tried bypassing things and it will still crash on simple variable declarations or println. I've tried updating my iOS, deleting the old app from my devices and restarting the devices. Any advice would be appreciated.
I'm still not sure what caused this problem in the first place, but I deleted Xcode, re-downloaded it, installed it, reloaded my old project, re-fixed my errors and the project is running now running on devices in the newest version of Xcode.

App crashes without reason with xCode 4

Something weird is going on here.
My app crashes on this line of code:
int end = NSMaxRange(endRange);
but I don't get any error message, and everything is fine: endRange. The app just freezes in the iPhone and that's it.
1.
The weird thing is that the same code was working before, and I've reversed from repository to see what's wrong but it still doesn't work.
2.
Also xCode removes the breakpoint every time the app crashes. I add it again, I run the app, I step over, the app crashes and Xcode removes the breakpoint.
3.
I've cleaned the build, restarted xCode, restarted the iPhone, removed the app from the iPhone. Same issues.
4.
If I don't use breakpoints, the app doesn't crash, but the code right after that line is "skipped", but it was working before. At least the app doesn't freeze without breakpoint.
What the hell ?
I've had similar problems with the debugger in the past too. Try switching from LLDB back to GDB (From the Product / Edit Scheme menu). I've found LLDB to do exactly what you are describing with breakpoints.

Resources