When you drag the libpython2.7.dylib system into your project, make sure the "Copy items ..." checkbox is not selected. You want the library to just be referenced, not copied to your project.
The CpResource command you pasted convinces me that Xcode is trying to copy a file from your project (which does not exist) into your .app resources. You don't need that either. If the dylib file is in your target build phase in the "Copy Copy Resources" section, you should delete it. (You can search for CpResource and you will find people having similar problems).
It should be noted that Apple recommends not relying on the installed system when implementing the scripting language and instead linking its own version. Thus, you will not spare the Apple version, or if their version is later changed or removed from the system.
Edit:
If you want to link your own version of Python, this is what I did for one of my applications (I used version 3.3):
- Download and compile Python from source. I recommend setting it statically (perhaps this can be done by default).
- Copy the static library (.a file), python3.3 library and include the files that spit out in my Xcode project.
- Confirm there is a build phase for my purpose to copy the python3.3 library from my project to my .app
- Set the PYTHONHOME and PYTHONPATH environment variables to my python3.3 directory located inside my .app (path obtained with NSBundle) before initializing Python at runtime
- #include "Python.h" and make a call to Py_Initialize ()
- Add the path to the python3.3 / lib-dynload / directory (inside my .app) to the Python sys.path variable so that the compiled C modules are imported there
And it should work.
Additionally:
You might not want to include> 100 MB of Python data in your application. I used this command to convert all the source files of the standard .py library into .pyc byte code files in place:
path/to/built/python -m compileall path/to/python3.3/ -b
(- b may not be needed / relevant in 2.x)
Then I continued removing __pycache__, and any packages / modules that I know I do not need (e.g. tkinter, antigravity, etc.). I have adjusted the size of my python related files to 20 MB (7 MB in compression)
source share