Sign in Join
Wiki copytemporary

Cocoa Debugging: what changed

Revision 1 to 2. 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-` cd project1.app/Contents/MacOS`
11+```
12+ cd project1.app/Contents/MacOS
13+```
1214
1315(for your project "project1.app" needs to be changed to your project's name)
1416
1517- run the project
1618
17-`./project1`
19+```
20+./project1
21+```
1822
1923See the output! The output might suggest what's going on. Any OS or error warning messages should be shown.
2024
2125### Console App
2226
2327The log entries could also be acquired from Console utillity.
2428
2529## Run with lldb debugger
2630
2731Repeat the same steps as in "Run from Terminal", but run the program as
2832
29-`lldb project1`
33+```
34+lldb project1
35+```
3036
3137(loading of lldb requires admin rights, and well as takes some time) once loaded enter command
3238
33-`r`
39+```
40+r
41+```
3442
3543and wait for it to stop or catch the application crash. See more [[lldb|here]]
3644
3745## Troubleshooting
3846
3947- 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
4048- 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.
4149
4250## Creating a Minimal Sample Project
4351
4452It's likely you would encounter a problem when working with a big production project.
4553
4654It's likely you might have some closed-source code that you're not allowed to share.
4755
4856It's preferred to have a simple project demonstrating the problem. "Simple" meaning:
4957
5058- it's small in size one (or two) forms only.
5159- minimal set of controls
5260- NO external package dependencies (packages supplied with Lazarus are ok)
5361
5462In order to get a simple project from the big production project you can do the following:
5563
5664- copy the project stand-alone (not to harm the existing code base)
5765- remove (delete) pieces that are not related to the bug
5866
5967:* (i.e. if you're having problems with placement of a control, you might want to remove main menu, TActions, if any)
6068
6169:* remove bigger pieces first (it might be much easier than you think)
6270
6371- after each piece is removed, run the project, to make sure you're still getting the error.
6472- keep removing code (and reference to any other external dependencie) until you reach the point that you cannot remove anything without affecting the bug.
6573
6674At this point you should have small enough project to demonstrate the problem and [[How do I create a bug report|bug report it]].
6775
6876## See also
6977
7078- [[How do I create a bug report]]
7179- [[lldb]]
7280- [[Cocoa Interface]]
7381- [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)
7482
7583---
7684*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).*
7785Category: Cocoa
7886Category: Debugging
7987Category: macOS

Back to history