Sign in Join
Wiki copytemporary

Cocoa Debugging: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Cocoa Debugging

OldNewLine
1+*(macOS only)*
2+
3+Having problems running a project compiled for Cocoa? Here are steps to try
4+
5+## Run from Terminal
6+
7+- open up a Terminal (Applications -\> Utilities -\> Terminal).
8+- cd to your project directory
9+- cd to the bundle (a bundle is a specially structured directory where binary resides. The bundle directory extension is ".app" )
10+
11+` cd project1.app/Contents/MacOS`
12+
13+(for your project "project1.app" needs to be changed to your project's name)
14+
15+- run the project
16+
17+`./project1`
18+
19+See the output! The output might suggest what's going on. Any OS or error warning messages should be shown.
20+
21+### Console App
22+
23+The log entries could also be acquired from Console utillity.
24+
25+## Run with lldb debugger
26+
27+Repeat the same steps as in "Run from Terminal", but run the program as
28+
29+`lldb project1`
30+
31+(loading of lldb requires admin rights, and well as takes some time) once loaded enter command
32+
33+`r`
34+
35+and wait for it to stop or catch the application crash. See more [[lldb|here]]
36+
37+## Troubleshooting
38+
39+- 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
40+- 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.
41+
42+## Creating a Minimal Sample Project
43+
44+It's likely you would encounter a problem when working with a big production project.
45+
46+It's likely you might have some closed-source code that you're not allowed to share.
47+
48+It's preferred to have a simple project demonstrating the problem. "Simple" meaning:
49+
50+- it's small in size one (or two) forms only.
51+- minimal set of controls
52+- NO external package dependencies (packages supplied with Lazarus are ok)
53+
54+In order to get a simple project from the big production project you can do the following:
55+
56+- copy the project stand-alone (not to harm the existing code base)
57+- remove (delete) pieces that are not related to the bug
58+
59+:* (i.e. if you're having problems with placement of a control, you might want to remove main menu, TActions, if any)
60+
61+:* remove bigger pieces first (it might be much easier than you think)
62+
63+- after each piece is removed, run the project, to make sure you're still getting the error.
64+- keep removing code (and reference to any other external dependencie) until you reach the point that you cannot remove anything without affecting the bug.
65+
66+At this point you should have small enough project to demonstrate the problem and [[How do I create a bug report|bug report it]].
67+
68+## See also
69+
70+- [[How do I create a bug report]]
71+- [[lldb]]
72+- [[Cocoa Interface]]
73+- [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)
74+
75+---
76+*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).*
77+Category: Cocoa
78+Category: Debugging
79+Category: macOS

Back to history