* * *

Author Topic: Problem debugging Lazarus app using Xcode/lldb [SOLVED]  (Read 839 times)

Phil

  • Hero Member
  • *****
  • Posts: 2147
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #15 on: July 18, 2017, 01:58:22 am »
I've also looked at the Build Settings for the app that doesn't build, but I can't find any mention of "Run Script" in there. Mind there's a veritable shed load of info in there so I may be looking at the wrong thing.

Sorry, I meant Build Phases.

The 2nd problem is just warnings. You probably added some .pas files to the Xcode project. Xcode adds them to the Compile Sources list, also on Build Phases, but later doesn't know _how_ to compile them. Just remove them from the Compile Sources list. That will eliminate the warnings.

Don't know about the 1st problem. Looks like lazbuild is crashing for some reason.

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #16 on: July 18, 2017, 02:08:55 am »
And yet the same copy Lazbuild executable is building all apps OK on the command line.

I've been looking at this page https://www.hockeyapp.net/help/runscriptbuildphase/ where it describes how to access the Run Script settings. However, if I go to Editor -> Add Build Phase all the menu options underneath are greyed out.

And I don't have a section called "Targets" like in the images on that page, so I cannot easily select my Application Target and I don't have a blue "Build Phases" link above the search box.

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #17 on: July 18, 2017, 02:12:25 am »
Actually, Phil, I'm going to call it a day for now, as I'me really tired. I'll catch up with this conundrum in the morning. Thanks a lot for your help so far, I really appreciate it.

Phil

  • Hero Member
  • *****
  • Posts: 2147
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #18 on: July 18, 2017, 02:18:33 am »
And I don't have a section called "Targets" like in the images on that page, so I cannot easily select my Application Target and I don't have a blue "Build Phases" link above the search box.

Select your project at the top of the Navigator panel at left. You probably just have Info and Build Settings tabs on the right. Move the mouse over the controls at the top (concept!). You'll see hints like "Select a project or target" (select your target) or "Show project and targets list" (select your target). Now you'll see the other tabs, including Build Phases.

Apple has voluminous docs on using Xcode. You're making it too hard on yourself.


carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #19 on: July 18, 2017, 02:08:05 pm »
OK.

Build Phases for TestLazbuild (which Xcode is failing to build):

1. Target Dependencies (0 items)
2. Compile Sources (1 item)
  main.c
3. Link Binary With Libraries (0 items)
4. Copy Files (0 items)
5. Run Script - Shell /bin/sh
Code: Pascal  [Select]
  1. set -e
  2. CMD_LINE="'$LAZBUILD_PATH' $LAZBUILD_OPTIONS '$LAZ_PROJECT_DIR/$LAZ_PROJECT_LPI'"
  3. echo "set -e" >lazcmd.tmp.sh
  4. echo $CMD_LINE
  5. echo $CMD_LINE >>lazcmd.tmp.sh
  6. echo cp -p "'$LAZ_PROJECT_DIR/$LAZ_TARGET_EXEC'" "'$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH'" >>lazcmd.tmp.sh
  7. if [ -e "$LAZ_PROJECT_DIR/$LAZ_TARGET_EXEC.app/Contents/Resources" ]; then
  8.   echo cp -p -R "'$LAZ_PROJECT_DIR/$LAZ_TARGET_EXEC.app/Contents/Resources/'" "'$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources'" >>lazcmd.tmp.sh
  9. fi
  10. /bin/sh lazcmd.tmp.sh
  11. rm lazcmd.tmp.sh
  12.  
[Checked] Show environment variables in build log
[Unchecked] Run script only when installing

Build Phases for CodePreview (which Xcode is building successfully):

1. Target Dependencies (0 items)
2. Compile Sources (1 item)
  main.c (I trimmed out the .pas files)
3. Link Binary With Libraries (0 items)
4. Copy Files (0 items)
5. Run Script - Shell /bin/sh
Code: Pascal  [Select]
  1. set -e
  2. CMD_LINE="'$LAZBUILD_PATH' $LAZBUILD_OPTIONS '$LAZ_PROJECT_DIR/$LAZ_PROJECT_LPI'"
  3. echo "set -e" >lazcmd.tmp.sh
  4. echo $CMD_LINE
  5. echo $CMD_LINE >>lazcmd.tmp.sh
  6. echo cp -p "'$LAZ_PROJECT_DIR/$LAZ_TARGET_EXEC'" "'$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH'" >>lazcmd.tmp.sh
  7. if [ -e "$LAZ_PROJECT_DIR/$LAZ_TARGET_EXEC.app/Contents/Resources" ]; then
  8.   echo cp -p -R "'$LAZ_PROJECT_DIR/$LAZ_TARGET_EXEC.app/Contents/Resources/'" "'$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources'" >>lazcmd.tmp.sh
  9. fi
  10. /bin/sh lazcmd.tmp.sh
  11. rm lazcmd.tmp.sh
  12.  
[Checked] Show environment variables in build log
[Unchecked] Run script only when installing

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #20 on: July 18, 2017, 02:40:31 pm »
Clearly, in the case of TestLazbuild (which Xcode is failing to build), the run script is not making it to the end because lazcmd.tmp.sh is remaining there after the attempted build.

Here's a strange (that word again!) one. If I go to the Xcode folder where TestLazbuild.xcodeproj is and run the leftover lazcmd.tmp.sh, I get the Lazbuild error
Code: Pascal  [Select]
  1. Hint: (lazarus) [RunTool] /usr/local/bin/ppc386 "-iWTOTP"
  2. Hint: (lazarus) [RunTool] /usr/local/bin/ppc386 "-va" "compilertest.pas"
  3.  
  4.   $0021F38B
  5.   $000114F2
  6.   $00185B75
  7.   $001866FA
  8.   $00186C3E
  9.   $00014043
  10.   $00012E1C
  11.   $0001192B
  12.   $0001628C
  13. Error: (lazbuild) Strange lpi file
  14. The file /Users/carlca/Code/fpc/Test/TestLazbuild/TestLazbuild.lpi does not look like a lpi file.
  15. lazbuild is non interactive, aborting now.
  16.  

Indeed if I manually type /usr/local/bin/lazbuild /Users/carlca/Code/fpc/Test/TestLazbuild/TestLazbuild.lpi I get the error.

Bear in mind that all that is in lazcmd.tmp.sh is the following:
Code: Pascal  [Select]
  1. set -e
  2. '/usr/local/bin/lazbuild' '/Users/carlca/Code/fpc/Test/TestLazbuild/TestLazbuild.lpi'
  3. cp -p '/Users/carlca/Code/fpc/Test/TestLazbuild/testlazbuild' '/Users/carlca/Library/Developer/Xcode/DerivedData/TestLazbuild-dxqebgtvlqoefdbumbwgbbqthksb/Build/Products/Debug/TestLazbuild.app/Contents/MacOS/TestLazbuild'
  4. cp -p -R '/Users/carlca/Code/fpc/Test/TestLazbuild/testlazbuild.app/Contents/Resources/' '/Users/carlca/Library/Developer/Xcode/DerivedData/TestLazbuild-dxqebgtvlqoefdbumbwgbbqthksb/Build/Products/Debug/TestLazbuild.app/Contents/Resources'
  5.  

If, however, I go to the folder where the TestLazbuild lazarus app is, and type lazbuild testlazbuild.lpi it builds without a problem.
« Last Edit: July 18, 2017, 02:46:24 pm by carl_caulkett »

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb [SOLUTION HERE]
« Reply #21 on: July 18, 2017, 03:05:12 pm »
OK. At last, I have distilled the problem down to its purest constituents and the cause of the problem has emerged.

Given that /usr/local/bin/lazbuild  testlazbuild.lpi works perfectly and this /usr/local/bin/lazbuild TestLazbuild.lpi doesn't, where do you think the problem is??!!

lazbuild is bloody case sensitive when it comes to the project name. I've got to go out in a minute so I won't be able to confirm this till later, but Aaaarrrggghhh!
« Last Edit: July 18, 2017, 07:58:07 pm by carl_caulkett »

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb [SOLUTION HERE]
« Reply #22 on: July 18, 2017, 07:57:26 pm »
The problem was that although my Lazarus projects themselves were all named using lowercase names, for some reason, when running the makeproj I specified Camel case names for the Xcode project. This ended up with the shell script specifying that, for example, testlazbuild should be built as TestLazbuild - this as I have demonstrated, doesn't work.

While I think that a case could be made for a bug report submitted for lazbuild, the solution to the problem is straightforward, at least. USE LOWERCASE NAMES FOR THE LAZARUS PROJECT AND THE XCODE CONVERTED PROJECT!

I rebuilt the projects using lowercase names and it all builds perfectly and now I can debug to my heart's content. Thanks again Phil, for your patience and guidance. I've learnt a lot and I achieved the satisfaction of finding the solution!

Cheers,
Carl

Phil

  • Hero Member
  • *****
  • Posts: 2147
Re: Problem debugging Lazarus app using Xcode/lldb [SOLUTION HERE]
« Reply #23 on: July 18, 2017, 08:03:45 pm »
While I think that a case could be made for a bug report submitted for lazbuild, the solution to the problem is straightforward, at least. USE LOWERCASE NAMES FOR THE LAZARUS PROJECT AND THE XCODE CONVERTED PROJECT!

Just make sure you use mixed case for the Lazarus project's target name in Project Options. Otherwise you'll end up with lower-case .app name.

And I would always revise the Lazarus-created Info.plist file in the .app bundle since Lazarus is pretty dumb about what goes into this. For example, the bundle ID should be, eg, com.company.TestLazbuild.

Look in /Applications. All .apps are named with mixed case. Look inside those .app bundle in MacOS: the name of the executable is always the same as the .app and always in mixed case.

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb [SOLVED]
« Reply #24 on: July 18, 2017, 08:45:51 pm »
I stand corrected! The solution is not as straightforward as I thought.

So let me get this right. What case should I be using in the initial ./makeproj osx-laz ~/Code/xcode/lazarus/testlazbuild ~/Code/fpc/test/testlazbuild/testlazbuild.lpi cd ~/Code/xcode/ command? I thought that the case used for the Xcode project name filtered back to the lazbuild command...

Or should I start with all lower case as above and then make tweaks to the Xcode project as you described just now?

Cyrax

  • Hero Member
  • *****
  • Posts: 511
Re: Problem debugging Lazarus app using Xcode/lldb [SOLVED]
« Reply #25 on: July 18, 2017, 08:58:57 pm »
Always use lowercase file names in unix environments. Otherwise you will face problems.

carl_caulkett

  • Full Member
  • ***
  • Posts: 168
Re: Problem debugging Lazarus app using Xcode/lldb [SOLVED]
« Reply #26 on: July 18, 2017, 09:07:10 pm »
I changed the case of the project name in Project Options (within Lazarus). And I also changed the name in the Bundle Identifier within Xcode to com.company.TestLazbuild. I then did a fresh build in Xcode. My testlazbuild.app is still resolutely lower case.

Something else that puzzles me is that I am seeing a file built as a testlazbuild Unix executable (~10Mb) as well as a separate testlazbuild.app bundle (102 bytes). I was under the impression that the testlazbuild.app bundle should actually contain the Unix executable. Is this not the case with Lazarus?

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus