Using the Python templates for Xcode, I have a simple project running on one machine and failing on two others, for different reasons. The failure I solved is that even though main.m has:
Py_SetProgramName("/usr/bin/python");
The actual running Python as seen from main.py with this:
import sys
print sys.version
is different. And the problem was that this other Python didn't have objc installed. So the question is: short of cleaning up my machine, how can I direct Xcode to use the system Python?
Edit:
This is a problem that seems like it is trivial, but it isn't. It seems so because when I specify Mac OS X 10.5 as the Base SDK, Xcode links against that Python.framework, as I can see by double-clicking the icon in Linked Frameworks in the Xcode project.
Each Version in Python.framework has a key/value pair in its Info.plist: CFBundleExecutableName/Python. Luckily (for the forensics) this Python in the Version 2.5 framework launches 2.6.1! Yet by printing sys.version (from main.py) or by snooping on the loader (by doing export DYLD_PRINT_LIBRARIES=1), I can see that the PyObjC App actually launches Python 2.5.4.
The line above with Py_SetProgramName.. is irrelevant---it can be commented out and everything works fine.
So what it looks like is that Python.framework controls which Python is launched, it doesn't do this in the way I expected, and it might be controlled through an initialization routine that is opaque, since it's controlled by Apple. It seems the best way to "control" the situation is to change the Base SDK.
Sorry to answer my own question but I was just confused. This part is an error
Python in the Version 2.5 framework launches 2.6.1
caused by my not realizing that what's going on here (from the Version/2.6 directory)
> ./Python
-bash: ./Python: cannot execute binary file
> Python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
is that we're searching my $PATH and launching /opt/local/bin/python.
Apologies for the confusion.
To summarize, setting the SDK should get the desired Python to run as we can see by snooping on the loader:
> export DYLD_PRINT_LIBRARIES=1
> ~/Desktop/X/build/Debug/X.app/Contents/MacOS/X
dyld: loaded: /Users/telliott_admin/Desktop/X/build/Debug/X.app/Contents/MacOS/X
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /System/Library/Frameworks/Python.framework/Versions/2.5/Python
..
Related
I have a build phase that calls some python scripts.
This has been working fine for well over 2 years, but after recently updating to Xcode 13.3 it now fails.
the error I started receiving is:
/Users/me/Library/Developer/Xcode/DerivedData/MyApp-fsowouspdsdjjzfmlfafizjbkcae/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Script-9002D8C42166BC850081D43D.sh: line 6: python: command not found
Command PhaseScriptExecution failed with a nonzero exit code
At a glance, it looks like xcode is attempting to run the script on the simulator instead of running in the local project directory.
python --version:
Python 3.8.3
I am wondering if there is some new configuration that I am unaware of for new xcode versions?
EDIT:
when i run the the lines in the script in my terminal, they run just fine.
You have installed Python 3 somehow (brew, perhaps), and it is in your PATH. That is why, when you say python, it is found.
But that same Python is not in Xcode's PATH! And it never has been. You've never noticed this, and you've never needed to notice it, because Xcode has always used the system Python, which was located in /SystemLibraryFrameworks. You and Xcode were probably using different Python versions (the system version stopped at 2.7), but this didn't matter.
But now (Monterey 12.3), it isn't. There is now no Python in Xcode's PATH. Thus, when your script says python plain and simple, it isn't found. You can fix this by using a complete path in your scripts that specifies where your Python is. You can find this out by saying which python.
So, Xcode seems to bundles its' own versions of python and python 3. It does not use the system version, so changes to Monteray 12.3 would not affect this.
Since that is the case, the correct solution is changing python to python3 since it looks like an Xcode update dropped python2.7 to parallel the OS dropping it later. I had to also update my python file to ensure compatibility.
After rebooting my dev machine, my Rust project stopped running on macOS. The error message is:
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
I have absolutely no idea what changed and caused this. The problem seems to be with my rig, not with the code, since it runs fine on a Docker container, and the older commits refuse to run on my computer. Another thing is that my project shouldn't be using any image-processing libraries. (And I don't know how to list transitive dynamic dependencies on macOS to check whether it really does.)
otool -L /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO reveals that ImageIO links to /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib (compatibility version 1.0.0, current version 1.0.0). That file exists indeed. /usr/local/lib/libjpeg.dylib (My FS is case-insensitive) exists too, but it's a symlink to a homebrewed file ../Cellar/jpeg/8d/lib/libjpeg.dylib, so clearly the system library shouldn't use that. However, I have not set LD_LIBRARY_PATH or any other env var that – as far as I know – should coerce macOS to use /usr/local/lib as a dylib search path.
So my questions are:
1) Is there a tool on macOS to check, which libraries in my project link (possibly transitively) to the ImageIO.framework?
2) How are dylib search paths configured on macOS? Is there a tool to check which paths are searched and in which preference order? The problem itself might be due to some Homebrew problem, but I'd like to have the tools to diagnose and understand it.
I still don't know a good answer for 1).
For 2) the answer can be found from the Apple docs. This page lists all the env vars that affect dylib loading and their default values: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
For the mystery, why the wrong path was attempted to be loaded: although my environment didn't have any funny variables set, my build tool (cargo run) set DYLD_LIBRARY_PATH before running the binaries. This is because of the behaviour (not sure if bug) explained here: https://github.com/sgrif/pq-sys/commit/3ad9f7b77a6c4f50d5d7277bce05c836a62a4398
I want to build a Darwin Streaming Server on my mac for iOS development test. But after taking the following steps which I searched from google, it fails all the time.
Method 1:
Download from http://dss.macosforge.org/ ->Mac OS X Install -> Streaming Server;
Install the dmg;
It tries to open http://127.0.0.1:1220/ but fails with "This webpage is not available ERR_CONNECTION_REFUSED".
Method 2:
Download the source code of 6.0.3 version;
$ tar xvf DarwinStreamingSrvr6.0.3-Source.tar
$ cd DarwinStreamingSrvr6.0.3-Source
$ wget http://www.abrahamsson.com/dss-6.0.3.patch
$ patch -p0 < dss-6.0.3.patch
$ ./Buildit
Then, it fails with the following words.
Darwin Streaming Server
I don't know your platform. I'll assume this is a Linux x86 platform.
Please edit the BuildServer script & PlatformHeader.h to add your platform.
Building for Darwin.x86_64 with gcc
xcodebuild DarwinStreamingServer
=== BUILD LIBRARY TARGET AtomicLib (Library) OF PROJECT StreamingServer WITH CONFIGURATION Development ===
Check dependencies
Jam is deprecated and has been removed; targets that use Jam must be upgraded to native targets. For more information on doing this, consult the Xcode documentation.
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)"
I tried to run ./Install, it showed me
Unable to perform install
You must be logged in as root to install Darwin Streaming Server
and I don't know what to do now.
PS: I've installed Xcode on my mac and didn't find any available document about Darwin Streaming Server, or I missed it?
Hope for any help. Thanks.
Calios and Jessica, thank you for your answers. I'm running using OS Windows 7 and installing DSS 5.5.5 for windows, and I also meet the condition same as with you.
However, after I followed your instructions, it's not close enough with our needs, because the button will lose meaning in presentation.
So I started digging more information from another articles, and I found interesting perception from a developer at this article. He said the following:
Maybe this has something to do with the perl script which generates the web sites?*
So starting from Jens's perception, I tried to downgrade my Perl Script from version 5.26 to 5.8. This resolved my problem, the interface displays correctly as in the DSS Tutorial.
Right now I'm still working on testing the DSS function
I hope this solution will help others.
Well, finally I solved this issue with the help of my friend.
Here's the steps of solution.
I've given up compiling and building on my own and downloaded the dmg file.(version 6.0.3)
Install the dmg as directions.
Then, go to /usr/sbin in terminal and find streamingadminserver.pl and QuickTimeStreamingServer.
Run them.
Check if they're running with ps aux|grep streaming.
Open http://localhost:1220/parse_xml.cgi in Safari or Chrome. It will show some textfield and a button.
However, there's no words at all ! Go to /Library/QuickTimeStreaming/AdminHtml and edit setup_assistant2.html.
Find line 333 and change it from return "$message{$name}"; to return $name;.
Then it shows some understandable words, though not exact words.
Till now, it can be partly work. However, in some steps I mentioned above, for example, html editing step, I really don't know why the words just don't show and just have a try.
Save the exact steps I did here for memory. It will be wonderful if it can help anyone or anyone have some good idea about it.
Thanks.
#SouravGupta, I am a newbie for stackoverflow, so I could not add comment to reply your question.
I just installed DDS 6.0.3 on Mac OS X El Capitan. I hit the same problem you had. I found that ** return "$message{$name}"; ** is no longer in setup_assistant2.html. It is in parse_xml.cgi (/Library/QuickTimeStreaming/AdminHtml). Just search for "sub foundString". There were two return places there. You need to change both in order to make it work.
It seems that DDS web admin software has localization function. Html files only contain string keywords. It suppose to use that "foundString" function to get translated string from keywords. However, for some reason, it returns empty string here even if there is a "messages" file inside html_en folder. I could not spend more time to figure out why right now.
QTSS/DSS Web Admin 6.0.3 requires Perl version 5.16 and earlier. OS X 10.11 El Capitan installs both Perl versions 5.16 and 5.18, but it defaults to using Perl version 5.18.
In order to run QTSS/DSS Web Admin in OS X 10.11 El Capitan, you need to examine each of the Perl script (.pl) within the AdminHtml folder and change the line #!/usr/bin/perl to #!/usr/bin/perl5.16.
Using XCode 4.5.2 and MacRuby 0.12, my app works fine on my computer but the release version won't work on others computers :
Dyld Error Message:
Library not loaded: /Library/Frameworks/MacRuby.framework/Versions/0.12/usr/lib/libmacruby.dylib
Referenced from: /Users/USER/Desktop/PocheFactory.app/Contents/MacOS/PocheFactory
Reason: image not found
I have checked my deployment settings and they seems fine:
In the BuildPhases->"Link Binary With Libraries", I have the "MacRuby.framework" required and in the BuildSettings->Framework Search Paths, I have include "/Library/Frameworks" with recursive option.
How come this particular library is not included within the release version?
Any idea?
Rather than figuring out the right Xcode settings, it's much easier to run this:
/usr/local/bin/macruby_deploy --compile --embed
I got this info from Matt Aimonetti's MacRuby, The Definitive Guide.
(The last command argument was stripped off: it's the path to the application bundle in Derived Data that was created by Xcode.)
I've spent a very frustrating evening trying to get wxpython to work on my MacBook Pro (running Snow Leopard 10.6.6). From reading the various threads on this topic both here and on other websites this is my understanding so far:
If you are running python 2.6 or greater you can only work with wxpython if you access the 32-bit version
Typing python at the command line prompt reveals that I am using python 2.6.1.
Typing which python returns /usr/bin/python so I'm using the default version installed with my OS. This means that typing the following at the command line prompt
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes should change the version I'm using to the 32 bit version.
With the above in place, I can now simply type the name of my python file (with the wx module imported) and my file will run successfully.
As you can no doubt guess however my file doesn't run successfully. I can't figure out what's going on, but maybe someone else can here are some other observations that might help...
typing help(), modules yields the following message and then prints out the modules, including wx and wxpython
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pkgutil.py:110: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible.
__import__(name)
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pkgutil.py:110: DeprecationWarning: twisted.flow is unmaintained.
__import__(name)
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/python/filepath.py:12: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/words/im/__init__.py:8: UserWarning: twisted.im will be undergoing a rewrite at some point in the future.
warnings.warn("twisted.im will be undergoing a rewrite at some point in the future.")
Fri Jun 3 22:23:48 Paul-Pattersons-MacBook-Pro.local python[3208] <Error>: kCGErrorFailure: Set a breakpoint # CGErrorBreakpoint() to catch errors as they are logged.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
Then examining the wx module specifially yields...
NAME
wx
FILE
/usr/local/lib/wxPython-unicode-2.8.12.0/lib/python2.6/site-packages/wx-2.8-mac-unicode/wx/__init__.py
Can anyone help?
I don't have a Mac, but I read almost all the messages on the wxPython mailing list. As I understand it, you don't want to use the Python that came with your Mac. It has been modified for the Mac specifically somehow, so you should download a normal version of Python and install it.
As for the 32-bit question, with wxPython 2.8, you are correct. You are limited to 32-bit because of the Carbon API. However, if you scroll down the download page (http://wxpython.org/download.php) you will see that wxPython 2.9 has been released and it has a Cocoa build which (and I quote) "requires at least OSX 10.5, and supports either 32-bit or 64-bit architectures" and Python 2.7.
I highly recommend that you go and seek help on the wxPython mailing list. The author of wxPython is there and he uses a Mac and there are several other Mac addicts on the list too that answer these sorts of questions.