JaneaSystems / nodejs-mobile-samples

Repository for demo applications that use Node.js on Mobile
MIT License
168 stars 111 forks source link

read-only file system in iOS #26

Open boby1975 opened 4 years ago

boby1975 commented 4 years ago

Hi guys, And I'm trying to use ios/native-xcode-node-folder sample project. But I can't to save data to the file inside main.js

var fs = require('fs'); fs.writeFileSync('test.txt', 'Hello World!');

EROFS: read-only file system, open 'test.txt'

Does anybody know how it can be writable? Thanks a lot

jaimecbernardo commented 4 years ago

In the cordova and react-native plugins, there's an API for it. On iOS, the current working directory might be the App sandbox by default or this might be accessible through homedir ( https://nodejs.org/dist/latest-v12.x/docs/api/os.html#os_os_homedir ). The iOS app sandbox will have a Documents directory you can write too, if I recall corrrectly.