Load Remote Bundle Error on iOS

Hi everyone.

I got some error when Load Remote Bundle on iOS platform. This is my code

const uri = "https://<mywebsite.com>/<platform>/<bundle_name>";
    
        assetManager.loadBundle(uri, null, (err: Error, bundle : AssetManager.Bundle) =>{
            console.log("error load bundle",err);
            bundle.loadScene("MySceneName", (err, scene)=>{
                console.log("error load scene", err);
                director.runScene(scene);
            });
        });

the code was running well in Android Device. but when I tried to run on iOS I got this error message

11:34:09 [DEBUG]: JS: error load bundle null
2023-08-22 11:34:09.454058+0700 SampleLoadBundle-mobile[2496:397100] open on /var/mobile/Containers/Data/Application/869CFED8-9554-495C-AE96-C0E0E57D0245/Documents/gamecaches/<mybundle_name>/16926787931462.json: No such file or directory
11:34:09 [ERROR]: JS: Download file failed: path: https://<mywebsite.com>/<platform>/<bundle_name>/import/02/02c9ae476.json message: The file “CFNetworkDownload_8oU62u.tmp” doesn’t exist., -2

I don’t know what happen. can you help me to solve this problem. may be there are some configuration or permission setting on Xcode project that I need to edit so I can load remote bundle successfully on iPhone Device.

I think the problem is about downloading process restriction in iOS platform when load remote bundle but I don’t know how to solve this problem because I don’t have experience in iOS Development (for your information, my remote bundle size is about 900kb)

this is the file structure of my bundle (build using cocos creator 3.8) :
bundle_name :
import/somefile
native/somefile
index.js
cc.config.json

I run the project using :

  • Cocos Creator 3.8 (build ios platform) remote bundle and the project itself built by cocos creator 3.8 (built using same version)
  • XCode 14.3.1
  • Run on iPhone 12 Real Device (iOS 16.6) failed to load remote bundle
  • Run on iPhone 14 Pro emulator (still failed to load remote bundle)
  • Set Minimum Deployment Setting on XCode to ios 12.0 (same error)
  • Set Minimum Deployment Setting on XCode to ios 16.0 (same error)

I was also facing the same issue, and I was able to point out the problem. The issue is Cocos was creating a folder with the same name as the server. Instead of the bundle name. By manually creating the folder in the same directory and copying the file from the server folder to the folder I created was able to load the bundle, but it is an issue.

1 Like

facing same issue

Hi ChandanKrishnani, Thank you so much. it’s very helpful to me. I hope the cocos engineer team can solve this problem in the next update. If you don’t mind, can you give me an example code to create the folder manually and copying the file from the server to this folder :pray:

It is a development-level fix, not a production fix. It needs to be fixed by the Cocos engine developer team. For this temporary fix start x code> window>devices and simulators > select the app>click on three dots > You will see the option to download the container ( There is also an option to replace the container once you update the package you need to replace it ) > In the downloaded container right click on it and click package contents.> Follow the error path you will find a folder exactly named your server. there only have to create a folder with the same name as the missing folder Cocos is looking for replace files in the server folder with the folder Cocos is looking for. Replace the app bundle from Xcode. Restart app. Wallah bundle loaded. It is a temporary fix.

@pandamicro please fix this issue :face_with_head_bandage:

Can you provide me with your reproducible demo, I will verify it and fix it as soon as possible

Have you ever try on local server or only on CDN server? I’ve test on local server and run well. I’m not sure there’s any different between local and cdn. If you can provide me a demo, that will help me a lot:)