Home / IOS Development / Getting the URL of the resource in Xcode Playground is inconsistent between Xcode versions: iOSProgramming

Getting the URL of the resource in Xcode Playground is inconsistent between Xcode versions: iOSProgramming



Hi, I have a simple Xcode playground where I read fast file and do a few more things with it. The problem is that on Xcode 12 I get zero when I try to read the file with “fast” extension (other files work well). It used to work on Xcode 11. Is there a new way to do it? It’s a playground for MacOS.

r / iOSProgramming - Getting URL to the resource in Xcode Playground is inconsistent between Xcode versions

Code:

["json", "txt", "swift"]
    .forEach { print(Bundle.main.urls(forResourcesWithExtension: $0, subdirectory: nil)) }

Xcode 12:

Optional([api.json -- file:///var/folders/x5/wg_gx53z0254lpyfmm0000gn/T/com.apple.dt.Xcode.pg/resources/B11DE6A8-7AXB-4E08-8987-3F8178CC6BB3/])
Optional([text.txt -- file:///var/folders/x5/wg_gx53z0254lpyfmm0000gn/T/com.apple.dt.Xcode.pg/resources/B11DE6A8-7AXB-4E08-8987-3F8178CC6BB3/])
Optional([]) // .swift file

Xcode 11.6:

Optional([api.json -- file:///var/folders/x5/wg_gx53z0254lpyfmm0000gn/T/com.apple.dt.Xcode.pg/resources/FDC17DB1-5C7D-4412-8CE5-ABA9A7A3C913/])
Optional([text.txt -- file:///var/folders/x5/wg_gx53z0254lpyfmm0000gn/T/com.apple.dt.Xcode.pg/resources/FDC17DB1-5C7D-4412-8CE5-ABA9A7A3C913/])
Optional([code.swift -- file:///var/folders/x5/wg_gx53z0254lpyfmm0000gn/T/com.apple.dt.Xcode.pg/resources/FDC17DB1-5C7D-4412-8CE5-ABA9A7A3C913/])

Source link