Post

Replies

Boosts

Views

Activity

Swift file reading permission error on macOS sandbox
I'm trying to read the contents of a file on the filesystem in a macOS Swift app (Xcode 9 / Swift 4).I'm using the following snippet for it:let path = "/my/path/string.txt" let s = try! String(contentsOfFile: path) print(s)My problem is the following:1. This works in a Playground2. This works when I use the Command Line Tool macOS app template3. This terminates in a permission error when I use the Cocoa App macOS app templateThe permission error is the following:Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=257 "The file "data.txt" couldn't be opened because you don't have permission to view it." UserInfo={NSFilePath=/my/path/data.txt, NSUnderlyingError=0x60c0000449b0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}I guess it's related to sandboxing but I found no information about it.1. How can I read from the filesystem in a sandboxed app? I mean there are so many GUI apps which need an Open File dialog, it cannot be a realistic restriction of sandboxed apps to not read files from outside the sandbox.2. Alternatively, how can I switch off sandboxing in Build Settings?3. Finally, I tried to compare the project.pbxproj files between the default Cocoa Apps and Command Line Tool template and I didn't see any meaningful difference, like something about security or sandbox. If not here, where are those settings stored?
8
0
25k
Jan ’18
Is OpenEXR supported
I am trying to find out if reading OpenEXR files are supported or not on iOS? Here is what I found out:1. The docs barely mention OpenEXR, and where they do they say that it's only supported on recent macOS.2. Yet, the official WWDC 2017 samples for ARKit simply load .exr images with UIImage(named: "image.exr") This is found in the following samples:- Handling 3D Interaction and UI Controls in Augmented Reality- Interactive Content with ARKit- Audio in ARKit- Placing Objects [old, I think it's removed now]Can you point me to anything about how is OpenEXR support on iOS and on macOS?
5
0
4.6k
Feb ’18
Metal texture / CGImage from data asset
I believe native reading of OpenEXR format is (at least officially on macOS) supported both on recent macOS and iOS versions: https://forums.developer.apple.com/thread/97119I'd like to load an OpenEXR image to a Metal texture, probably via MTKTextureLoader.newTexture().My problem is that XCode doesn't recognise OpenEXR files as texture assets, but as data asset.This means I cannot use MTKTextureLoader.newTexture(name: textureName, ...).What cross platform (recent macOS / iOS) options are there to read an image from a data asset?Since .newTexture supports CGImage, I'd guess that the natural way would be to load into CGImage, but I don't quite understand how.Or should I simply make an URL out of the data asset's file and try to load that one?
3
0
2.7k
Feb ’18