Foreach error when attempting to publish with assets
Description
Getting below error when attempting to run 'expo publish' using sdk version 33.
Expected Behavior
App successfully publishes, with images present in published version.
Observed Behavior
The app crashes with error printed above.
Cannot read property 'forEach' of undefined
TypeError: Cannot read property 'forEach' of undefined
at /[email protected]/src/Project.js:1033:26
at Generator.next (<anonymous>)
at step (/usr/local/lib/node_modules/expo-cli/node_modules/xdl/build/Project.js:2349:191)
at /usr/local/lib/node_modules/expo-cli/node_modules/xdl/build/Project.js:2349:361
Environment
Please run expo diagnostics in the project folder and copy the output here:
Expo CLI 2.14.0 environment info: System: OS: macOS 10.14.4 Shell: 3.2.57 - /bin/bash Binaries: Node: 11.13.0 - /usr/local/bin/node npm: 6.7.0 - /usr/local/bin/npm IDEs: Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: expo: ^33.0.0 => 33.0.7 react: 16.8.3 => 16.8.3 react-native: https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz => 0.59.8 react-navigation: ^3.11.0 => 3.11.0 npmGlobalPackages: expo-cli: 2.14.0
My package.json is:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "~3.0.0",
"@expo/vector-icons": "^10.0.1",
"@unimodules/core": "^2.0.1",
"axios": "^0.19.0",
"expo": "^33.0.0",
"expo-asset": "^5.0.1",
"expo-constants": "^5.0.0",
"expo-font": "^5.0.0",
"expo-web-browser": "^5.0.0",
"expokit": "^33.0.3",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-cache": "^1.1.7",
"react-native-elements": "^1.1.0",
"react-native-grid-component": "^2.0.0",
"react-native-iap": "^3.2.2",
"react-native-material-dropdown": "^0.11.1",
"react-native-modalbox": "^1.7.1",
"react-native-really-awesome-button": "^1.4.2",
"react-native-web": "^0.11.4",
"react-navigation": "^3.11.0",
"tcomb-form-native": "^0.6.20",
"unimodules-task-manager-interface": "^2.0.1"
},
"devDependencies": {
"babel-preset-expo": "^5.1.0",
"jest-expo": "^33.0.0"
},
"private": true
}
And my app.json is
{
"expo": {
"name": "StreamedBook",
"slug": "StreamedBook",
"privacy": "public",
"sdkVersion": "33.0.0",
"platforms": [
"ios",
"android",
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.textbooks.streamedbooks",
"publishBundlePath": "ios/streamedbook/Supporting/shell-app.bundle",
"publishManifestPath": "ios/streamedbook/Supporting/shell-app-manifest.json"
},
"isDetached": true,
"detach": {
"iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v2.11.0-sdk33.0.0-4b05019b-b5d6-454b-8350-09c2187b9f91.tar.gz",
"androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.11.4-sdk33.0.0-6a4f0f3e-1f1b-4c33-9155-d0237f6d7c34.tar.gz"
},
"scheme": "expa907bcf7d8c1412cade19d7d4048d62e",
"android": {
"package": "com.textbooks.streamedbooks",
"publishBundlePath": "android/app/src/main/assets/shell-app.bundle",
"publishManifestPath": "android/app/src/main/assets/shell-app-manifest.json"
}
}
}
I'm aware that this is related to the issue documented here https://github.com/expo/expo-cli/issues/179. But, because I have the proper react native version, the fix there doesn't work for me. I'm wondering if this is a new sdk version 33 issue.
having the same issue here. I have updated the expo-cli as well. It seems that this "assetBundlePatterns": ["**/*"] is the problematic line here. When I change it to "assetBundlePatterns": ["./assets/"], it runs without any errors and publishes the app successfully but the assets do not get displayed in the app. It seems that they do get uploaded somehow. I tried including different assets and publishing the app and the dimension of the placeholders in my app changed according to the dimensions of the image. But still they were not displayed
Fixed my issue by downgrading my project to SDK 32 in order to see images correctly on publishes.
"expo": "^32.0.0",
"expo-cli": "^2.21.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
Having the same issue after upgrade from SDK 32 to SDK 33
Am having the same issue after upgrade to SDK 33
Having the same issue after upgrade to SDK 33 Here is the structure of the assets folder at the root of my app
- assets
- images
- file.png
- other_file.png
- fonts
- custom-font.ttf
It looks like the .png files in my /assets folder are bundled (with "assetBundlePatterns": ["./assets/images/*"]). But what triggers the foreach error is a .ttf custom font file implemented following the "Using Custom Fonts" expo guide (with "assetBundlePatterns": ["./assets/images/*", "./assets/fonts/*"]).
Updating expo-cli with npm i -g expo-cli@latest finally fixed it for me
Same issue
Is there any update to this???
Im having this same issue with expo v34, (after upgrading from v32). Changing the asset string fixed it, but it seems like a temporary fix.
I've roll-backed to expo cli 2.19.0 and seems it works here
any fix yet?
I've fixed it also as migration to the latest versions And don't forget change version in app.json
@anton-zardi-ru what version is the "latest" version for you that worked? Before I found #753, I made these updates based on #704 :
// package.json
"expo": "^35.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
// app.json
"sdkVersion": "35.0.0",
and still no worky.
Updating the asset path the same as what @doub1ejack did in https://github.com/codeforbtv/cvoeo-app/pull/110 made it work.
Are you seeing this error with the latest Expo CLI? (3.3.0 at the time of writing this comment.)
I was not able to reproduce this using the latest version, but if you can, please link to a project that you can't publish (aka a repro), as this will greatly speed up fixing this issue, provided that it still exists.
I'm closing this issue since there's no new activity, it seems that it has been fixed in the newer versions. Please open a new issue, if you're still seeing this problem.