ios – Get URL to folder from bundle at runtime – or forestall folder from being flattened

ios – Get URL to folder from bundle at runtime – or forestall folder from being flattened


I’ve an Xcode challenge with the next construction:

projectName
│
└── Part
    │
    └── Property
        │
        ├── subfolder
        │   ├── subfolderA
        │   ├── subfolderB
        │   ├── subfolderC
        │   ├── subfolderD
        │   ├── fileA
        │   ├── fileB
        │   ├── fileC
        │
        ├── fileD
        ├── fileE
        ├── fileF

...

I have to get the URL to fileA and subfolder itself.

I can reliably get the URL to fileA like this:

personal var fileURL: URL? = Bundle.fundamental.url(forResource: "fileA", withExtension: "js")

How do I get the URL or path for subfolder? I’ve tried a number of issues like this:

personal var subfolderURL: URL? = Bundle.fundamental.url(forResource: "subfolder", withExtension: nil)

However it returns nil.

I do know the sources are within the bundle and have confirmed in Construct Phases > Copy Bundle Sources.

When the app is operating on my simulator, if I print the fileURL, it’s one thing like this:

~/Library/Developer/CoreSimulator/Gadgets/{UUID}/knowledge/Containers/Bundle/Software/{UUID}/{AppName}.app/fileA.js

So it looks like the sources are being flattened at runtime.

I am utilizing a WKWebView and inside it including some HTML with a <script> factor that wants the subfolder URL:

require.config({
    paths: { 'subfolder': '(subfolderURL)' }
});

The script expects that folder and its information in a sure construction, so I do not assume I can simply specify the sources individually.

Is there any method to do that?

Right here is an analogous query from some time again. The reply has little or no info and a damaged hyperlink that supposedly solved the entire subject.

Notice: subfolder is a blue folder (reference, not group) within the Venture Navigator. In Construct Phases > Copy Bundle Sources, neither subfolder itself nor any of the folders inside it present up as line gadgets, however all their contained information do. For instance, there’s a line merchandise for fileA.js ...in projectName/Part/Property/subfolder, or someFile.js ...in projectName/Part/Property/subfolder/subfolderA.

I am utilizing Xcode 16.2.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.