A couple of things:
— Your app cannot write to or otherwise modify its own bundle. Your write operation failed.
— Don't use any file-handling API that doesn't throw an error upon failure. Any existing API that does not should be regarded as obsolete, even if not officially deprecated.
— As far as possible, avoid file-handling API that takes a path parameter. It is recommended to use the variant that takes a URL. If a path-based method doesn't have a URL-based equivalent, you should regard it as obsolete, even if not officially deprecated.
— You've apparently gone off in the wrong direction anyway. If you're trying to create a text file, archiving a String variable won't give you the desired result. (An archive is a binary file that needs to be decoded to extract its contents.)
— You really need to get into the habit of checking the documentation (in Xcode or at developer.apple.com) before choosing API, especially when there are multiple similar choices available. Picking the wrong one accidentally really slows the development process down.
The correct approach is to convert the String to a Data instance, using the encoding that you want in your text file (such as UTF-8). Then use the Data method "write(to:options:)" to write the data to the file. (Using a URL to specify a location where you app can legally write a file, of course.)
Claude, it's really confusing if you continue to suggest Swift 3 syntax, since there are lots of changes in Swift 4. Even if you continue to use an earlier Xcode for your own projects, you should really install Xcode 9 (or, preferably Xcode 9.1 or whatever is latest) for trying out code fragments you post. (Xcode 9 can co-exist with earlier Xcodes on your Mac, though can't run 9 and earlier versions simultaneously.)