[iOS] Missing bundled scripts and assets in IPA, won't work offline


#1

Hello,

Firstly, can we just say a big “Thank you” for Expo. We’ve come from web app building and found the workflow to be really straightforward and enjoyable to use.

We are trying to build a:

  • standalone iOS app
  • ejected to ExpoKit
  • bundle scripts and assets to launch first time without a network connection
  • no use of external servers/ OTA updates

Following the instructions from here hosting-your-app we have hosted the static files on our own server.

We have successfully expo ejected to ExpoKit. Installed pods, and opened the project workspace in Xcode.

Trying to build and run gives an error that shell-app-manifest.json is invalid. It’s empty, and so is shell-app.bundle.

We enter {} in shell-app-manifest.json so it’s at least valid JSON.

In Supporting/EXShell.plist set manifestUrl to localhost/dir/project/ios-index.json

The project will then build successfully. It runs on the simulator, and we can even Archive and install the .IPA on real devices using our Apple certificates. Which is excellent.

However, the app will always hit eg. localhost/dir/project/ios-index.json on launch and download the other assets from there too. If we turn off wifi, the app will give an error

“There was a problem loading the requested app. Make sure you’re connect to the internet. Try again.”

The Xcode build process isn’t picking up the scripts and assets.

This issue from May 2018 seems to say that expo publish is required for ExpoKit apps, but a comment from @terribleben implies this won’t be needed now we have expo bundle-assets, and we’re hosting the dist files on our server (as above).

We can’t seem to get the build process to grab those assets though.

Any help would be greatly appreciated, cheers.

Environment

OS: macOS Mojave 10.14.3
Node: 11.1.0
npm: 6.7.0
Watchman: 4.9.0
Pod: 1.5.3
Xcode: Xcode 10.1 Build version 10B61

Packages

expo: ^32.0.0
expokit: ^32.0.6
react: 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz

#2

Hey @daniel!

Looks like according to the link you shared, as well as what I’ve found (this github issue has the exact same problem as you, empty shell-app-manifest.json file), that you have to run expo publish

Let me know if that resolves it!


#3

Unfortunately, no. We had previously found that github issue, and tried expo publish.

That command uploads our project to exp.host (as stated above, we can’t use external servers).

How do we tell expo publish to use the assets we created with expo export --public-url ?


#4

@daniel,

After appropriately hosting your app, you can configure your standalone binary to pull from your own server using expo build:ios --public-url <path-to-ios-index.json>

Additionally, you can override where the assets are hosted using assetUrlOverride field in your ios-index.json, there’s more info on this @ https://docs.expo.io/versions/latest/distribution/hosting-your-app/#asset-hosting

Thanks for raising the question :slight_smile:


#5

Since this is an ejected ExpoKit:

‘exp build’ is not supported for detached projects

We have partially solved the missing assets, by manually replacing:

/ios/<appname>/Supporting/shell-app-manifest.json <----- /dist/ios-index.json
/ios/<appname>/Supporting/shell-app.bundle <----- /dist/bundles/ios-<hash>.js

This allows us to build and archive the app using Xcode. It will launch OK, even without a network connection first-time. Which is great!

However, our bundled image assets aren’t displaying. Interestingly, bundled fonts do work.

We’ve inspected the Archived .ipa/Payload to see what assets are actually being bundled.

Working OK were:

  • Images from React Navigation and the app icon/ splash screen
  • Icon fonts
  • Custom fonts we added

Our image files appear to be there, but they are all just 243 bytes.

asset_0b114a00a26ef7c72ca9f57d05273699.png

Opening the file gives this:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>C8F50820A16A9DBB</RequestId><HostId>0hFK9Dir/oRF3ghG4G9C1Ls6bg5kwi8s+mKXBm1GsnXRuaf1ME12jrErTxzGguhQpuDqbCMCkVs=</HostId></Error>

Which looks like it might be an error message from AWS? Maybe, somehow the build process is attempting to fetch these images from AWS, instead of using the /dist bundle, as it did correctly for the fonts.

The fact the fonts are bundled correctly, but not the images is very strange.


Generate shell-app.bundle without publishing