Firebase Crash Reporting for iOS, upload-sym script failing in Xcode

1,529 views
Skip to first unread message

Kevin Gray

unread,
Nov 22, 2016, 11:02:28 AM11/22/16
to Firebase Google Group
I am working on an project with one main app and two extensions, a keyboard and an imessage app.  I have added crash reporting for each target, and added the Run Script Phases to each for automatic symbol upload.  Often the builds will pass fine, but occasionally, the builds will fail with warnings such as:

/Pods/FirebaseCrash/upload-sym-util.bash:292: Unable to retrieve authentication token from server.

or various other errors.  Rebuilding after a failure such as that will usually succeed, but it's an annoyance and slows down our productivity.  Not only that, but with the build
scripts as they are, it is not possible to build without a connection to the internet, which isn't acceptable for many of us on our commutes home where we don't have a
connection.  

So far, the solution has been to wrap the Run Scripts into ${CONFIGURATION} checks, where, in Debug builds, we treat all errors as warnings, and also, if a non-zero exit
code is returned, we output a warning and exit with code 0 anyway.  In Release builds we run it as specified in the documentation, and all scripts must pass.  

This works for now, but is this how we are expected to be using these scripts?  And it also doesn't answer why we are only getting these errors occasionally.  

Also, occasionally, we hit a line in upload-sym-util.bash which results in this syntax error, and a failed buld:

/Pods/FirebaseCrash/upload-sym-util.bash:158: ((: <= NOW: syntax error: operand expected (error token is "<= NOW")

the offending line (158) looks like this: if (($(tok_property expires_at) <= NOW)); then

So, in summary, the questions are:

Are we expected to handle the Run Scripts as we are, so that people can work offline?
Why are we hitting these invalid token errors, and why are they only failing occasionally? (probably 1/10 builds)
What is going on with line 158, that Xcode is saying it is a syntax error? 

Thanks.

Kato Richardson

unread,
Nov 22, 2016, 3:14:10 PM11/22/16
to Firebase Google Group
Hi Kevin,

What are "various other errors", and how often are auth requests being sent during build process for a given IP address (any chance you're sending more than, say, 50 in a minute?

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/b7bba588-2f18-4bf3-b309-6e1fa1206e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Kevin Gray

unread,
Nov 23, 2016, 3:35:52 PM11/23/16
to Firebase Google Group
Hi Kato, 

The various other errors are other exit codes that are hit during the build process, due to exit codes from the scripts, though some times they are just warnings, such as "token does not match". Sorry I can't currently provide a complete list, but they are generally related to authentication or attempting to connect to the server, such as when you have no connection.  I could possibly compile a list of all the errors/warnings we see if that would be helpful.  But by far the most seen is "Unable to retrieve authentication token from server."

Also in response to your question, I haven't read into the scripts very thoroughly,  so I am not sure how often these scripts do authentication, but I can say that the application target, the keyboard extension target, and the iMessage extension target all run the same script from Xcode in the Run Script Phase, which all invoke the upload-sym script in the Pod.  Also, they all reference the same service account key.  So I suppose at least 3 are sent per minute, but possibly more depending on the scripts.

Thanks, 
Kevin


On Tuesday, November 22, 2016 at 3:14:10 PM UTC-5, Kato Richardson wrote:
Hi Kevin,

What are "various other errors", and how often are auth requests being sent during build process for a given IP address (any chance you're sending more than, say, 50 in a minute?

☼, Kato
On Mon, Nov 21, 2016 at 10:29 PM, Kevin Gray <ke...@goposse.com> wrote:
I am working on an project with one main app and two extensions, a keyboard and an imessage app.  I have added crash reporting for each target, and added the Run Script Phases to each for automatic symbol upload.  Often the builds will pass fine, but occasionally, the builds will fail with warnings such as:

/Pods/FirebaseCrash/upload-sym-util.bash:292: Unable to retrieve authentication token from server.

or various other errors.  Rebuilding after a failure such as that will usually succeed, but it's an annoyance and slows down our productivity.  Not only that, but with the build
scripts as they are, it is not possible to build without a connection to the internet, which isn't acceptable for many of us on our commutes home where we don't have a
connection.  

So far, the solution has been to wrap the Run Scripts into ${CONFIGURATION} checks, where, in Debug builds, we treat all errors as warnings, and also, if a non-zero exit
code is returned, we output a warning and exit with code 0 anyway.  In Release builds we run it as specified in the documentation, and all scripts must pass.  

This works for now, but is this how we are expected to be using these scripts?  And it also doesn't answer why we are only getting these errors occasionally.  

Also, occasionally, we hit a line in upload-sym-util.bash which results in this syntax error, and a failed buld:

/Pods/FirebaseCrash/upload-sym-util.bash:158: ((: <= NOW: syntax error: operand expected (error token is "<= NOW")

the offending line (158) looks like this: if (($(tok_property expires_at) <= NOW)); then

So, in summary, the questions are:

Are we expected to handle the Run Scripts as we are, so that people can work offline?
Why are we hitting these invalid token errors, and why are they only failing occasionally? (probably 1/10 builds)
What is going on with line 158, that Xcode is saying it is a syntax error? 

Thanks.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/b7bba588-2f18-4bf3-b309-6e1fa1206e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Haney

unread,
Nov 28, 2016, 2:15:33 PM11/28/16
to Firebase Google Group
Hi Kevin,

Sounds like most the trouble you're having is when you're offline. You can change your build script to look something like this:

# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID
=1:1234567899:ios:235fbac36576bd
nc
-z 8.8.8.8 53  >/dev/null 2>&1
online
=$?
if [ $online -eq 0 ]; then
  echo
"Online, uploading symbol file."
 
# Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
 
"${PODS_ROOT}"/FirebaseCrash/upload-sym "${PROJECT_DIR}/ServiceAccount.json"
else
  echo
"Offline, not uploading symbol file."
fi



This can be a little bit nefarious because it will appear to succeed when offline, but it'll probably be ok as long as you make sure it uploaded something (the echo statements will be in the build log) for builds that are distributed to anyone. If you continue to have errors after this, let us know what those are, they're probably a different issue.

Kevin Gray

unread,
Nov 29, 2016, 11:53:42 AM11/29/16
to Firebase Google Group
Hi Michael,

The issue isn't only with offline uploads, the script also occasionally gives the errors stated above, such as, "Unable to retrieve authentication token from server."  This only happens occasionally though, usually building again will cause the upload to succeed.  We have wrapped the upload script such that it will ALWAYS pass in a Debug configuration, but still attempt it.  So offline building is not a problem for us.  The two problems I still see are the following two:

1. Why is authentication failing, but only occasionally?  We would like the upload script to succeed as often as possible, but not hinder our developers from building and testing as quickly as possible.  This isn't breaking our builds, as we have wrapped the scripts as stated above, but it is less than optimal.

2. /Pods/FirebaseCrash/upload-sym-util.bash:158: ((: <= NOW: syntax error: operand expected (error token is "<= NOW")  
Occasionally that line is getting hit, (Line 158 of upload-sym-util.bash), and it states it as a syntax error, and that WILL always fail.  Is it a bash syntax error?, or is it some odd xcode bug?  This rarely gets hit at all, but when it does, the build will not succeed.

So we don't have any breaking/blocking issues, but they are issues and I have been told to resolve them, so any help would be appreciated.

Thanks! 

Michael Haney

unread,
Dec 6, 2016, 5:06:53 PM12/6/16
to Firebase Google Group
Hi Kevin,

Sorry for the slow response.

1. The authentication error you're getting usually means 1 of 2 things--network connectivity isn't good, or the token cache on your machine is messed up for some reason (it can be reset by removing it as follows).

rm $HOME/Library/Preferences/com.google.SymbolUpload*

2. If you replace line upload-sym-util.bash:158 with 
if [[ "$(tok_property expires_at)" <= "${NOW}" ]]; then
does that fix that problem?
Reply all
Reply to author
Forward
0 new messages