Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS build failing with 'main.jsbundle does not exist' #11961

Closed
jakubgs opened this issue Apr 7, 2021 · 28 comments · Fixed by #11967
Closed

iOS build failing with 'main.jsbundle does not exist' #11961

jakubgs opened this issue Apr 7, 2021 · 28 comments · Fixed by #11967
Assignees
Labels

Comments

@jakubgs
Copy link
Member

jakubgs commented Apr 7, 2021

The iOS nightly builds have been broken for several days because of:

▸ Processing Info.plist
▸ Generating 'StatusIm.app.dSYM'
▸ Running script 'Bundle React Native code and images'

❌  error: File /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle does not exist. This must be a bug with

    The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'boost-for-react-native' from project 'Pods')
** ARCHIVE FAILED **

The following build commands failed:
	PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/IntermediateBuildFilesPath/StatusIm.build/Release-iphoneos/StatusIm.build/Script-00DD1BFF1BD5951E006B06BC.sh
(1 failure)
[09:40:34]: Exit status: 65

Specifically main.jsbundle does not exist.

This started happening on the 3rd of April: https://ci.status.im/job/status-react/job/nightly/1903/

@jakubgs jakubgs self-assigned this Apr 7, 2021
@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

What's interesting is that there are no new commits recorded between build 1902 and 1903, and yet the former succeeded while the latter failed.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

I tried purging the Jenkins workspaces with:

 > ansible ci-slave-macos -a 'rm -fr /Users/jenkins/workspace/status-react/combined/mobile-ios'

But it didn't help: https://ci.status.im/job/status-react/job/nightly/1909/

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

This error was mentioned in one comment in the PR that implemented use of shadow-cljs: #10217 (comment)

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

According to the logs this is the script that failed:

/Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/IntermediateBuildFilesPath/StatusIm.build/Release-iphoneos/StatusIm.build/Script-00DD1BFF1BD5951E006B06BC.sh

And when I check it's contents I see this:

[email protected]:~ % cat /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/IntermediateBuildFilesPath/StatusIm.build/Release-iphoneos/StatusIm.build/Script-00DD1BFF1BD5951E006B06BC.sh
#!/bin/sh
set -o errexit
export NODE_BINARY="node"
export NODE_ARGS=" --max-old-space-size=16384 "

bash -x ../node_modules/react-native/scripts/react-native-xcode.sh 2>&1 > ./react-native-xcode.log

Which is simply this:
https://github.com/status-im/status-react/blob/be0ad943eaf9807c79fae405c15a2a573d7ffc29/ios/StatusIm.xcodeproj/project.pbxproj#L526
And when i check the ios/react-native-xcode.log there's nothing useful in it:

[email protected]:/Users/jenkins/workspace/status-react/combined/mobile-ios/ios % cat react-native-xcode.log 
warning: the transform cache was reset.
                 Welcome to React Native!
                Learn once, write anywhere


React Native, please report it here: https://github.com/facebook/react-native/issues

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

I tried building locally with make release-ios BUILD_TYPE=nightly but it fails with some unrelated error:

ld: warning: directory not found for option '-L-L/Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-byxfyjmbslalemdeptottzdfriyp/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/BVLinearGradient'
ld: library not found for -lBVLinearGradient
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** ARCHIVE FAILED **

The following build commands failed:
	Ld /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-byxfyjmbslalemdeptottzdfriyp/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/InstallationBuildProductsLocation/Applications/StatusIm.app/StatusIm normal arm64
(1 failure)
make: *** [release-ios] Error 65

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

I fixed piping of logs into ios/react-native-xcode.log with:

diff --git a/ios/StatusIm.xcodeproj/project.pbxproj b/ios/StatusIm.xcodeproj/project.pbxproj
index f61fb41de..39ac5c0eb 100644
--- a/ios/StatusIm.xcodeproj/project.pbxproj
+++ b/ios/StatusIm.xcodeproj/project.pbxproj
@@ -523,7 +523,7 @@
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "set -o errexit\nexport NODE_BINARY=\"node\"\nexport NODE_ARGS=\" --max-old-space-size=16384 \"\n\nbash -x ../node_modules/react-native/scripts/react-native-xcode.sh 2>&1 > ./react-native-xcode.log\n";
+                       shellScript = "set -o errexit\nexport NODE_BINARY=\"node\"\nexport NODE_ARGS=\" --max-old-space-size=16384 \"\n\nbash -x ../node_modules/react-native/scripts/react-native-xcode.sh > ./react-native-xcode.log 2>&1";
                };
                1997449D1D0A7BEAADD6CEC8 /* [CP] Embed Pods Frameworks */ = {
                        isa = PBXShellScriptBuildPhase;

And I got back this:

+ BUNDLE_FILE=/Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle
+ node --max-old-space-size=16384 /Users/jenkins/workspace/status-react/combined/mobile-ios/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle --assets-dest /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app
warning: the transform cache was reset.
                 Welcome to React Native!
                Learn once, write anywhere


+ [[ false != true ]]
+ [[ ! -f /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle ]]
+ echo 'error: File /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle does not exist. This must be a bug with
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2

https://ci.status.im/job/status-react/job/combined/job/mobile-ios/8856

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

This is the script that is being called: node_modules/react-native/scripts/react-native-xcode.sh

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

This issue seems to be exactly the same thing, and react-native version also matches: facebook/react-native#31094

This comment - facebook/react-native#31094 (comment) - indicates that the issue might be related to PATH and how metro-bundler identifies watchman.

@flexsurfer
Copy link
Member

facebook/react-native#31138 (comment)

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

As per usual, it makes no fucking sense. But I'm gonna try some other things first.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

Lol, I fixed it by doing:

 > ansible ci-slave-macos -a 'rm -fr /Users/jenkins/Library/Developer/Xcode/DerivedData'       
macos-01.ms-eu-dublin.ci.misc | CHANGED | rc=0 >>
macos-03.ms-eu-dublin.ci.misc | CHANGED | rc=0 >>
macos-02.ms-eu-dublin.ci.misc | CHANGED | rc=0 >>

https://ci.status.im/job/status-react/job/manual/128/

@jakubgs
Copy link
Member Author

jakubgs commented Apr 7, 2021

But the normal nightly failed...
https://ci.status.im/job/status-react/job/combined/job/mobile-ios/8858

1440445292514

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

I don't know why either, but it seems like upgrading Fastlane - and some other gems - worked: #11967

But only for a manual nightly build: https://ci.status.im/job/status-react/job/combined/job/mobile-ios/8863
It failed for the PR build: https://ci.status.im/job/status-react/job/prs/job/ios/job/PR-11967/2/

Makes no sense to me.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

A second manual nightly build on the same commit failed: https://ci.status.im/job/status-react/job/manual/132/

So I think the first one worked only because it accidentally ran on a host on which had ~/Library/Developer/Xcode/DerivedData removed.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

As far as I can tell this is something specific to nightly builds, because PR builds seems to work fine:

image

While nightly builds are failing:

image

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

I tried running the node ./node_modules/react-native/cli.js bundle command with --verbose added but I see no addition log messages explaining why no output bundle is created. I might have to go back to the roots and add some console.log()s.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

By doing dirty console.log() debugging I can see this function call never exists:
https://github.com/react-native-community/cli/blob/v4.10.0/packages/cli/src/commands/bundle/buildBundle.ts#L88
Which appears to be starting a Metro server:

import Server from 'metro/src/Server';

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

And this appears to be the constructor of the server:
https://github.com/facebook/metro/blob/v0.64.0/packages/metro/src/Server.js#L124-L150

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

This line:

    const metroBundle = await output.build(metroServer, requestOptions);

https://github.com/facebook/metro/blob/v0.64.0/packages/metro/src/index.js#L316
Calls buildBundle:
https://github.com/facebook/metro/blob/v0.64.0/packages/metro/src/shared/output/bundle.js#L21

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

As far as I can tell there's multiple async functions run by that Node process, and one of them exits with code 0, and kills the Metro bundle process before it finishes. I base that on different number of console.log() prints I get at different times without changing anything at all.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

Now the behavior has changed on macos-03. I'm running this:

node --max-old-space-size=16384 \
    /Users/jenkins/workspace/status-react/combined/mobile-ios/node_modules/react-native/cli.js \
    bundle --entry-file index.js --platform ios --dev false --reset-cache \
    --bundle-output /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app/main.jsbundle \
    --assets-dest /Users/jenkins/Library/Developer/Xcode/DerivedData/StatusIm-gzbepwnrlqbukxbmmpfskimspfch/Build/Intermediates.noindex/ArchiveIntermediates/StatusIm/BuildProductsPath/Release-iphoneos/StatusIm.app

And now it's getting stuck for no good reason, instead of exiting with 0 without creating the main.jsbundle.
Very, very confusing and annoying.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

And now the nightly build worked even though I didn't change anything in the repo:
https://ci.status.im/job/status-react/job/nightly/1912/
All I did was clean up workspaces and DerivedData.

I swear. I hate iOS so much. So much.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 8, 2021

And now I'm unable to reproduce the issue, either for the PR or the nightly build. This is so dumb.

@jakubgs
Copy link
Member Author

jakubgs commented Apr 9, 2021

And now it's fucked again: https://ci.status.im/job/status-react/job/nightly/1913/

@jakubgs
Copy link
Member Author

jakubgs commented Apr 9, 2021

Oh wait, but the error is different:

❌  /Users/jenkins/workspace/status-react/combined/mobile-ios/modules/react-native-status/ios/RCTStatus/RCTStatus.h:4:9: 'Statusgo.h' file not found
#import "Statusgo.h"
                                                      ^
▸ Compiling react-native-status-dummy.m
▸ Compiling RCTStatus.m

❌  /Users/jenkins/workspace/status-react/combined/mobile-ios/modules/react-native-status/ios/RCTStatus/RCTStatus.h:4:9: 'Statusgo.h' file not found

#import "Statusgo.h"
        ^~~~~~~~~~~~

Looks like #11951 now...

@jakubgs
Copy link
Member Author

jakubgs commented Apr 9, 2021

I'm not actually sure I fixed this permanently, but at least after merging #11967 the nightly build worked:
https://ci.status.im/job/status-react/job/nightly/1914/

@jakubgs jakubgs reopened this Apr 9, 2021
@jakubgs
Copy link
Member Author

jakubgs commented Apr 13, 2021

The nightly has been green for a few days now:

image

So I'm going to close this for now, but knowing Apple this might be re-opened in the future.

@jakubgs jakubgs closed this as completed Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants