简体   繁体   English

.log文件不会写入iPhone中的documents目录

[英].log file will not write into the documents directory in iPhone

This is not a question i have,these are few points which i like to share with you people. 这不是我的问题,我想与大家分享这些要点。

I came across a situation where i want to create log file in my application and send it as a mail to the supporting website. 我遇到一种情况,我想在我的应用程序中创建日志文件并将其作为邮件发送到支持网站。

So i created aa file with .log extension in resources directory and i tried to move it into the documents directory. 因此,我在资源目录中创建了一个扩展名为.log的文件,然后尝试将其移至文档目录。

The file doesn't gets moved to the documents directory.But all the code which i have done to the move the file into the documents directory is fine. 该文件不会移到documents目录。但是我所做的所有将文件移入documents目录的代码都可以。

I tried with creating a file with .txt extension in the resources directory with same code unmodified now i am able to copy the file into the documents directory where it can be writable. 我尝试在资源目录中创建一个扩展名为.txt的文件,并且未修改相同的代码,现在我可以将该文件复制到文档目录中,并且可以写了。

So i realized that files with .log extension will not get copied into the documents directory of the iPhone. 因此,我意识到扩展名为.log的文件不会被复制到iPhone的文档目录中。

Is that true.I am just sharing my thoughts with you. 是真的。我只是与您分享我的想法。

This is an answer. 这是一个答案。

Your observations are wrong. 您的观察是错误的。 Copying files with log extension works fine. 复制带有日志扩展名的文件可以正常工作。

My guess: 我猜:

your debug.log file has never been on the device. 您的debug.log文件从未在设备上。 Because it isn't assigned to your target. 因为它没有分配给您的目标。 xcode adds .txt files to the target, .log files aren't added to the target. xcode将.txt文件添加到目标,而.log文件未添加到目标。 you have to do this manually. 您必须手动执行此操作。 Yes, even if add to target was selected in the add file dialog. 是的,即使在添加文件对话框中选择了添加到目标。

Fix: 固定:

In your xcode sidebar, make a right click in the "Groups & Files" header and select "Target Membership". 在您的xcode边栏中,右键单击“组和文件”标题,然后选择“目标成员身份”。 See the not checked box infront of your debug.log? 看到debug.log前面的未选中框了吗? Click it. 点击它。
Et voila, the iphone copies logfiles. 瞧,iphone复制了日志文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM