I have an application which needs to run an external program.
I have included this program as an Embedded Framework
. When archived, it appears at the location %AppRoot%/Contents/Frameworks/MyExternalApplication.
How can I run this program from my app's code without using an absolute path? I'd like to run in both release and debug.
Thank You!
You can run the executable by using an NSTask
object or the posix_spawn()
function.
You can use the NSBundle
class to find the absolute path of the executable. See this article for details.
Notes:
Contents/MacOS
, as documented here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.