Sign in Join
Wiki copytemporary

Cocoa Debugging: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11*(macOS only)*
22
33Having problems running a project compiled for Cocoa? Here are steps to try
44
55## Run from Terminal
66
77- open up a Terminal (Applications -\> Utilities -\> Terminal).
88- cd to your project directory
99- cd to the bundle (a bundle is a specially structured directory where binary resides. The bundle directory extension is ".app" )
1010
11-```
11+```text
1212 cd project1.app/Contents/MacOS
1313```
1414
1515(for your project "project1.app" needs to be changed to your project's name)
1616
1717- run the project
1818
19-```
19+```text
2020./project1
2121```
2222
2323See the output! The output might suggest what's going on. Any OS or error warning messages should be shown.
2424
2525### Console App
2626
2727The log entries could also be acquired from Console utillity.
2828
2929## Run with lldb debugger
3030
3131Repeat the same steps as in "Run from Terminal", but run the program as
3232
33-```
33+```text
3434lldb project1
3535```
3636
3737(loading of lldb requires admin rights, and well as takes some time) once loaded enter command
3838
39-```
39+```text
4040r
4141```
4242
4343and wait for it to stop or catch the application crash. See more [[lldb|here]]
4444
4545## Troubleshooting
4646
4747- if a project can compile and run for Carbon, yet it cannot do the same for Cocoa, then the issue is likely with Cocoa widgetset. Creating a minimal sample project is suggested
4848- if a project runs but does nothing and provides a constant CPU load (i.e. 99%, 50% or 25%, depending on the number of cores), then there's an endless loop triggered by some code.
4949
5050## Creating a Minimal Sample Project
5151
5252It's likely you would encounter a problem when working with a big production project.
5353
5454It's likely you might have some closed-source code that you're not allowed to share.
5555
5656It's preferred to have a simple project demonstrating the problem. "Simple" meaning:
5757
5858- it's small in size one (or two) forms only.
5959- minimal set of controls
6060- NO external package dependencies (packages supplied with Lazarus are ok)
6161
6262In order to get a simple project from the big production project you can do the following:
6363
6464- copy the project stand-alone (not to harm the existing code base)
6565- remove (delete) pieces that are not related to the bug
6666
6767:* (i.e. if you're having problems with placement of a control, you might want to remove main menu, TActions, if any)
6868
6969:* remove bigger pieces first (it might be much easier than you think)
7070
7171- after each piece is removed, run the project, to make sure you're still getting the error.
7272- keep removing code (and reference to any other external dependencie) until you reach the point that you cannot remove anything without affecting the bug.
7373
7474At this point you should have small enough project to demonstrate the problem and [[How do I create a bug report|bug report it]].
7575
7676## See also
7777
7878- [[How do I create a bug report]]
7979- [[lldb]]
8080- [[Cocoa Interface]]
8181- [Apple: Appendix A: LLDB for GDB Users – Command Summary](https://developer.apple.com/library/archive/documentation/General/Conceptual/lldb-guide/chapters/A3-GDB-Summary.html)
8282
8383---
8484*From the Free Pascal wiki, page "Cocoa Debugging", as it stood on 2020-08-06 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
8585Category: Cocoa
8686Category: Debugging
8787Category: macOS

Back to history