Weird bugs and undefined behavior of Mac App - macos

At the moment I am experiencing a really weird behavior of my Mac App.
On my Mac (and on all other testing Macs) everything works fine. The app simply works, no leaks,...
BUT on all the review Macs (Yes, on all) it fails: First the launch failed and now, after submitting it more times and trying to workaround the bug, it does not get initialized: Icons that should get loaded dynamically are not shown.
WHY?! Perhaps anyone has made experiences with such a problem because I cannot test it. I try to find the issue but it's nearly impossible.
[EDIT]
App Information:
My app should list all the currently running applications and display them in some way. It reads no files, only the NSUserDefaults to setup itself.
Structure:
appDidFinishedLaunching setups basic stuff like global hotkeys, loads the NSUserDefaults and finally forwards the message to the subclassed main window (<- There is the problem).
There it should load its interface which does not work on review Macs.
I was able to "override" or "fix" this by a little, dirty code snippet but it does not fix the main problem:
//AppDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self performSelector:#selector(didLaunch) withObject:nil afterDelay:0.5f];//<- THIS does the trick, so that the app launches and shows the static content of the NIB, but NO dynamic content is displayed: exactly the same nib state
//Register hotkeys, load NSUserDefaults,
[mainview launched];//<- Here is the problem
finishedLaunching=1;//global var
}
-(void)didLaunch//Launching works
{
if (finishedLaunching==0) {//=0 because of the review results
//Does all the stuff that [mainview launched]; is supposed to do: Display window and setup position
//Calling methods included in main view does not work (OR the window is not refreshed
//so the first start finally works, but the interface is EMPTY, only static content visible
}
}
Does the setup not happen because it is done in its subclassed window?
Why does it work on my Mac (and another Mac mini)?
Do you know why this happens, a way how to correct it or how to reproduce the bugs?
I really need your help and appreciate every tip!

Related

Weird NSOutlineView crash

I'm experiencing weird crash in NSOutlineView: when i click "collapse" button, app crashes immediately and even "exception breakpoint" doesn't help to see where the problem is.
I've tried to run app without debugger, and reproduced the problem. Once app crashed, i've got OSX crash window and was able to extract crash message from there:
The window has been marked as needing another Update Constraints in Window pass, but it has already had more Update Constraints in Window passes than there are views in the window
there also call stack, but it won't help since crash happening inside libsystem_c.dylib, so i'm not posting it here.
It seems there is something wrong going with auto layout. Absolutely have no idea about next steps. Please give me an advice!
Also, one more thing, that began only after update to OSX Mojave.
After hours of debugging and testing, i noticed that that message is caused by "infinite layout loop".
Different code, related to outline view was causing NSSplitView to layout. And delegate method - (CGFloat) splitView:(NSSplitView*)sender constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex has been called about 200 times prior to crash.
It's hard to catch this bcs it's not actually infinite recursion, so just debugger doesnt help a lot.
I just added simple code that helped me to identify the issue:
static int a = 0;
NSLog(#"Layout: %d", a++);
Hope my experience will help somebody else!
For anyone who is having the problem in Xcode 14 and macOS using SwiftUI:
I just had the same crash by hiding a view with an animation. My main view contains two views, one view contained an empty ScrollView, which didn't cause a problem by itself, but by changing it's size it crashed. Just adding a basic Text within the ScrollView solved my problem and the app doesn't crash anymore.
I updated my build to IOS 14 and Mac OS 20.15.6 and the error went away.
try turning off 'Use Auto Layout' checkbox in nib (in File Inspector tab).
May have to disable it for each and every view.
Also, unrelated, but Mojave forces you to use Core Animation.
Most of my nibs have 'set wants layer' turned off.
However, in one of my nibs I had a stray setWantsLayer checkbox checked.
when I unchecked it, the view (NSSearchField) drew properly

Tabbed application troubles in xcode

I am working with my first tabbed application in xcode. I am just testing with some stuff since I'm relatively new to programming. I am just using the 2 views already put into the template. I am putting a slider into the first view and am going to attach it to a text box with numbers. But that isn't the problem! This is probably really stupid and simple, but when i run the application just to see the stuff on the simulator, it is just showing a black screen. NO CLUE WHY! But its killing me and would love some help!
You are not suppose to make connections in AppDelegate. You should use a ViewController for each class. I.E. FirstViewController, SecondViewController. AppDelegate is usually only used for calling save/restore messages.
You are getting the error because the storyboard view is assuming you are assigning it to the correct view. When you create the storyboard say you named it TestApp. Then, you should have a few classes. TestAppDelegate, TestAppDelegateFirstViewController, TestAppDelegateSecondViewController. Or something along those lines. FirstViewController should connect to the first view on the tab view. The Second should attach to the second.
AppDelegate is almost never used for UI. I would suggest you find a book on the matter. I'll suggest "iOS Programming. The Big Nerd Ranch Guide". It helped me a lot when I started.
Photo Exmaple:
I did end up starting a new project. Weird that the black screen showed up.. not really sure why that error was popping up.. I'm not really that knowledgable about the different errors and bugs that a program can have yet! Getting closer though!

applicationDidEnterBackground: Issue

I wrote an app that has about 3 different view controllers for each view in the tab bar. I called applicationDidEnterBackground: in each of the view controllers to save all the data in that specific view after the home button is tapped. This runs flawlessly on the iPad simulator, but for some reason, it crashed after trying to edit the data on the iPhone simulator. I thought this is probably an issue with putting the applicationDidEnterBackground: in the view controller, but if that was the issue, then wouldn't it crash on the iPad simulator as well?
I know that I should put applicationDidEnterBackground in the app delegate, but my method looks sort of like this:
- (void)applicationDidEnterBackground:(NSNotification *)notification {
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:firstField.text];
[array addObject:secondField.text];
[array writeToFile:[self dataFilePath] atomically:YES];
}
If I put this in the App Delegate, of course it doesn't recognize firstField or secondField because I did not declare it in header file or synthesize it or anything. If I were to declare everything in the App Delegate, then the outlets in my nib file will fail because each of the File's Owner's class is one of those specific view controllers.
Is the placement of applicationDidEnterBackground: not even my issue since it runs fine on the iPad simulator?
Also, it used to run fine on the iPhone simulator as well. I changed the Image View's background on all of the nibs, then this started happening. I rechecked all my outlets and actions and they match up fine.
EDIT: I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.
I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.

NSApplicationPresentationOptions doesn't work with FIREBREATH

I am trying to customize user experience from the plugin I am working on, my goal is to provide a kiosk style using the options available in COCOA NSApplication, the code is like following:
// Hide the dock tile and the menu bar:
NSApplicationPresentationOptions options =
NSApplicationPresentationHideDock + NSApplicationPresentationHideMenuBar;
[NSApp setPresentationOptions:options];
I have tested this code using a normal cocoa application and it works fine but when I embed this code in a function inside a "Firebreath PlugIn" nothing happens although the firebreath builds correctly and the other functions I have works normally.
some ideas? this is about system security restrictions maybe?? if so how to enable it? I don't know why this doesn't work if other cocoa functions works fine.
I am developing over Mac OS X Lion with XCODE 4.2
My guess is that you can't get tot he NSApplication because you are in a different process; you might be able to create a fake one or something like that with a new NSWindow to make it work, but since you're in a different process from the browser there is no way to access the browser's NSApp or other similar objects.

Changes in XCode App Delegate don't show up in simulator

This is really bugging me to the point where I'm going to have to step away for a bit.
So I am coding away and decide to change which ViewController gets launched on startup. I go into the app delegate and make the changes so that the the new ViewController will get loaded on startup, but when I run it in the simulator, the old one appears.
I've cleaned out the simulator, and i've tried "touching" files to force a relinking of the resources and it doesn't seem to make a difference. I can get an error to happen when I change the name of the ViewController in the app delegate to something like "vc". I then get a linking error saying the key value pair isn't found.
Anyways, if I am trying to just change which viewcontroller starts up in the app delegate, is there anything other than coding changes that I need to look at to inform xcode that I'm doing this? I've been searching google and working on this for the last couple hours and not really making any progress. If it makes any difference, this is for an ipad app.
Did you connect the controller IBOutlet of the app delegate with the your view controller?
Check your main XIB file in InterfaceBuilder.
And of course don't forget to save your changes made in InterfaceBuilder before launching the app since there is no "auto-save".

Resources