从Finder运行时,应用程序不会写入文件(在Xcode中为ok) [英] App won't write to file when run from Finder (ok in Xcode)

查看:179
本文介绍了从Finder运行时,应用程序不会写入文件(在Xcode中为ok)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个在Xcode中完美运行而不是从Finder窗口运行的osx应用程序。
它读取一个二进制数据文件并输出两个简单的文本文件并显示一些图形。
由于它在Xcode中工作,我将应用程序文件复制到Applications目录以及二进制输入文件。
二进制文件可以正常读取。这两个文本文件不能打开写入(权限被拒绝)
,所以程序退出。当从Xcode运行时,将
中的两个文本文件写入Applications目录是没有问题的。

我检查了文本文件的权限,读取/写入我的用户名和组(职员)
都来自unix终端ls -al和Finder获取信息。

所以看起来应用程序无法打开任何在Finder
窗口双击的应用程序目录下的文件。



我尝试了几个应用程序目录位置和二进制输入文件没有成功。
$ b $ / Users / person / Library / Application Support / MyApp
/ Users / person / Applications / MyApp


$ b $当从Finder启动时,无法工作,但所有工作都来自Xcode。

从Finder启动时,工作目录是/,但程序在启动时将其更改为相应的目录。



这个问题让我感动。我已经用完了想法。任何帮助将不胜感激。

解决方案

完整路径名称解决了从Finder运行的所有问题。多个目录位置尝试成功。非常感谢Paul R。


I have created an osx app that runs perfectly in Xcode but not from Finder window. It reads a binary data file and outputs two simple text files and displays some graphics. Since it works in Xcode, I copy the app file to say Applications directory along with the binary input file. The binary file can be read okay. The two text files cannot be opened for writing (permission denied) and so the program exits. When run from Xcode, there is no problem writing the two text files in the Applications directory.

I have checked the permissions for the text files and they are read/write for my username and group (staff) both from unix terminal ls -al and Finder get info.

So it appears that the app cannot open any file for writing in the Applications directory when double clicked from Finder window.

I have tried several directory locations for the app and the binary input file without success.

/Users/person/Library/Application Support/MyApp /Users/person/Applications/MyApp

None work when started from Finder, but all work from Xcode.

The working directory is / when started from Finder, but the program changes it at startup to the appropriate directory.

This problem has got me beat. I’ve run out of ideas. Any help would be appreciated.

解决方案

Full path names resolves all issues with running from Finder. Multiple directory locations were tried successfully. Awesome thanks to Paul R.

这篇关于从Finder运行时,应用程序不会写入文件(在Xcode中为ok)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆