I can add a build-phase script to an Xcode C project but not a run-phase pre-action script.
I'd like to reset a test condition each time I run a program I'm debugging. The easiest way to do this is to run a shell script every time I run (debug) the program in Xcode. I can see the place to add this script in Xcode's "edit scheme..."->"Run"->"Pre-actions" setting, but that just displays "No Actions".
I'm probably being stupid but I cannot see any way to add a "script phase" where the scheme currently shows "No Actions" in the scheme's "Run" "Pre-actions" section.
I guess I could try to remember to manually run a shell script from a terminal before chasing down a rabbit hole of debugging, but did I remember to set up that test condition each time I tried to chase the last rabbit?
Post
Replies
Boosts
Views
Activity
I include a picture on an HTML page by:
<img src="./name.png" class="inline" alt="" usemap="#html"/>
I create a link map, defining areas of the picture that I want to link to notes like this:
<map name="html">
<area shape="circle" coords="73,250,30"
href="./PassiveStrideRecovery_W12_Notes.html"
alt="PassiveStrideRecovery_W12" target="_self"
/>
...(more of these areas)
</map>
All the linked areas work fine for a few seconds and then some of the areas are obscured by automatically detected (not well though) areas of interest (to something) in the .png and stops my mouse clicks getting through to some of the linked areas I define.
When I use the Debug menu item and examine the HTML source elements (using "Develop->Show Page Source") I created. Initially they include:
a minute to so later they change to:
indicating the img has acquired some extra structure, which now looks like this:
and define some areas, some of which overlay my map areas in a layer above mine.
Looking at the last "div" created by MacOS, they seem to be inserted in real-time by Apple Data Detectors.
I changed my img include statement to
<img src="./GroundContact_W7_Bubbles.png" x-apple-data-detectors="false" class="inline" alt="" usemap="#html"/>
but it made no difference.
How do I stop real-time area overlay of click-obscuring blocks over pictures included on my HTML page?
TIA
Problem Description
MacBookPro M2, MacOS Sonoma 14.3.1, Xcode 15.3.
I'm trying to recompile my project that uses SDL2, from:
SDL.org's github
using their SDL2-2.30.2.dmg release. "Embed Framework" is required to get around this runtime error:
dyld[85171]: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2 Referenced from: <525E2631-2C23-3E66-96F5-031C734CF0B5>
Once the "Embed Framework" step is performed, the Xcode mapping of #include files stored in the loaded framework is undone. Undoing the "Embed Framework" step, puts the name mapping back but the program aborts as before. Either I can compile and obtain a run-time abort or I can not compile and not run the program. I've included a cludge to get around the issue, awaiting your fix (or advice).
Replication Details
Starting from a “from scratch”, Apple-supplied, “one-liner” (“Hello World”) as follows:
Start new project in Xcode, selecting “MacOS”, “Command Line Tool”.
Product Name:FrameWorkTest, Team:None, Organization Identifier:frameworktest, Language:C.
Create the project in a new folder. with the given (default) settings.
hit Apple-R… yay… it compiles and runs!
add this line under the #include <stdio.h>
#include "SDL2/SDL.h"
Now “main.c” source is showing “file not found” against this new #include line. That’s expected.
(6) Select FrameWorkTest from Navigator Pane (left hand side)
(7) Select “General” tab (middle pane)
(8) Finder drag “SDL2.framework” into Xcode’s middle-pane “Frameworks and Libraries” section (check the navigator pane (left pane) and now you have a “Frameworks” group containing “SDL2.framework”
After a few seconds the “file not found” indicator in “main.c” vanishes and the program is compilable (Apple+B). The Framework has been integrated (Hooray).
After a few seconds the “file not found” returns, though the program is still compilable (this seems to be a real-time parser mismatch with the compiler results, but not the main issue). I found the program is actually runable (Apple+R), probably because “main.c” has not been recompiled.
(9) Force a recompile by adding a space to “main.c” (and remove the space) and, once again hit Apple+R.
Now compile fails because “SDL2/SDL.h” is not found.
(10) Change the
#include "SDL2/SDL.h"
to
#include <SDL2/SDL.h>
“file not found” goes away after “Apple+R” forces a recompile. though now the runtime “abort” issue is present. Xcode is seriously confused at this point as putting double-quote version:
#include "SDL2/SDL.h"
back is fine now (no longer “file not found”) even though the source is back to a failing state. Fine. now to fix the runtime “abort” issue:
(11) Select “file view” in the Navigator pane (little folder icon). Select Project name, (topmost “FrameWorkTest” to show settings in middle pane). Select “Build Phases” tab.
(12) Drag “SDL2.framework” from the “Frameworks” group in the project Navigator pane (leftmost pane) into “Embed Frameworks” (middle pane)
(13) Now Apple+R will not compile (again) with “file not found” and I cannot get the project to compile and run without my “Trick” detailed above. Once the “Trick” is applied and the “file not found” goes away, the embed step (#12) lets the program compile and run - without “abort”.
Apple’s prepending of framework name to included files is inconsistent and faulty. The step 12 appears to undo the framework name mapping for #included files found in the framework. This step-by-step repeatable bug crib is not fixed by a “Product->Clean Build Folder…”.
Note: If step 12 is applied by doing a Finder drag and not a pane-to-pane drag, a (pointless) second Framework entry is introduced into the project, this confuses things further!
CLUDGE WARNING
Get around the “file not found” issue (total cludge but awaiting Apple’s real fix) is:
Logged in as an admin, in a terminal shell, do this:
cd /usr/local/include
(if you don’t have this directory; mkdir -p /usr/local/include; cd /usr/local/include)
ln -s /Library/Frameworks/SDL2.framework/Headers; mv Headers SDL2
Now in target settings, “Build Settings” tab, find “Header Search Paths” section and add “/usr/local/include” with “recursive” option selected (if it’s not already there).
I used a symbolic link (-s) for the trick so that the link is not disrupted when you next upgrade your SDL2.framework.
Now, even when you do a Product->Clean Build Folder, the project should build and run without Xcode issues.
Additionally, if you’d like to perform “the trick” for SDL2_ttf.framework #include files, do:
cd /usr/local/include
ln -s /Library/Frameworks/SDL2_ttf.framework/Headers; mv Headers SDL2_ttf
in an admin terminal.
Aside...
Reporting web page renumbers my 1) through 13), though the renumbering does not appear in the preview as it does in the actual post!