简体   繁体   中英

.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.

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.

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.

So i realized that files with .log extension will not get copied into the documents directory of the 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. Because it isn't assigned to your target. xcode adds .txt files to the target, .log files aren't added to the target. 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". See the not checked box infront of your debug.log? Click it.
Et voila, the iphone copies logfiles.

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.

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