iOS package build fails due to 'invalid byte sequence in UTF-8'

When running the package build for iOS I always get the error below.
I can build it locally without issues.

Running with gitlab-runner 10.2.0~beta.147.gbd1f3fcb (bd1f3fcb)
  on ip-10-2-158-91 (dc549c99)
Creating new VM...
Running on Ionics-Mac-3.local via ip-10-2-158-91...
Cloning repository...
Cloning into 'builds/project-0'...
Checking out 68cd950b as feature-appflow...
Skipping Git submodules setup
$ fetch-updates || true
Checking for build process updates...
$ build-ios
Setting up project pipeline...
Running build process...
+--------------------------------------------+---------+----------------------------+
|                                   Used plugins                                    |
+--------------------------------------------+---------+----------------------------+
| Plugin                                     | Version | Action                     |
+--------------------------------------------+---------+----------------------------+
| fastlane-plugin-update_project_codesigning | 0.2.0   | update_project_codesigning |
+--------------------------------------------+---------+----------------------------+

[14:30:18]: Sending anonymous analytics information
[14:30:18]: Learn more at https://docs.fastlane.tools/#metrics
[14:30:18]: No personal or sensitive data is sent.
[14:30:18]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[14:30:18]: You have required a gem, if this is a third party gem, please use `fastlane_require 'securerandom'` to ensure the gem is installed locally.
[14:30:18]: ------------------------------
[14:30:18]: --- Step: default_platform ---
[14:30:18]: ------------------------------
[14:30:18]: Driving the lane 'ios package_build' 🚀
[14:30:18]: ---------------------------
[14:30:18]: --- Step: build_summary ---
[14:30:18]: ---------------------------

+---------------------+---------------------------+
|                  Build Summary                  |
+---------------------+---------------------------+
| Job ID              | 6588141                   |
| Node.js version     | v10.16.0                  |
| Cordova CLI version | 9.0.3 (cordova-lib@9.0.2) |
| npm version         | 6.9.0                     |
| macOS version       | 10.14.5                   |
| Xcode version       | Xcode 10.2.1              |
|                     | Build version 10E1001     |
+---------------------+---------------------------+

[14:30:23]: --------------------------------
[14:30:23]: --- Step: detect_native_type ---
[14:30:23]: --------------------------------
[14:30:23]: Checking if cordova or capacitor project
[14:30:23]: Cordova project detected
[14:30:23]: -------------------------
[14:30:23]: --- Step: get_web_dir ---
[14:30:23]: -------------------------
[14:30:23]: webDir is `www`
[14:30:23]: ---------------------------------
[14:30:23]: --- Step: add_git_credentials ---
[14:30:23]: ---------------------------------
[14:30:23]: -------------------------------
[14:30:23]: --- Step: modify_config_xml ---
[14:30:23]: -------------------------------
[14:30:23]: No custom native config detected.
[14:30:23]: -----------------------------
[14:30:23]: --- Step: create_keychain ---
[14:30:23]: -----------------------------
[14:30:23]: $ security list-keychains -d user
[14:30:23]: ▸ "/Users/ionic/Library/Keychains/login.keychain-db"
[14:30:23]: ----------------------------
[14:30:23]: --- Step: download_certs ---
[14:30:23]: ----------------------------
[14:30:24]: -------------------------
[14:30:24]: --- Step: upload_logs ---
[14:30:24]: -------------------------
[14:30:24]: ---------------------------
[14:30:24]: --- Step: shell command ---
[14:30:24]: ---------------------------
[14:30:24]: -----------------------------
[14:30:24]: --- Step: delete_keychain ---
[14:30:24]: -----------------------------
[14:30:24]: invalid byte sequence in UTF-8
+------------------+-------------------+
|             Lane Context             |
+------------------+-------------------+
| DEFAULT_PLATFORM | ios               |
| PLATFORM_NAME    | ios               |
| LANE_NAME        | ios package_build |
| PROJECT_WEB_DIR  | www               |
+------------------+-------------------+
[14:30:24]: invalid byte sequence in UTF-8

+------+---------------------+-------------+
|             fastlane summary             |
+------+---------------------+-------------+
| Step | Action              | Time (in s) |
+------+---------------------+-------------+
| 1    | default_platform    | 0           |
| 2    | build_summary       | 5           |
| 3    | detect_native_type  | 0           |
| 4    | get_web_dir         | 0           |
| 5    | add_git_credentials | 0           |
| 6    | modify_config_xml   | 0           |
| 7    | create_keychain     | 0           |
| 💥   | download_certs      | 0           |
| 9    | upload_logs         | 0           |
| 10   | shell command       | 0           |
| 11   | delete_keychain     | 0           |
+------+---------------------+-------------+

[14:30:24]: fastlane finished with errors
WARNING: Nokogiri was built against LibXML version 2.9.2, but has dynamically loaded 2.9.4
/Users/ionic/.fastlane/bin/bundle/bin/fastlane: [!] invalid byte sequence in UTF-8 (ArgumentError)
\e[91mFailed to upload ipa to storage please retry your build.\e[0m
Running after script...
$ clean-up
Cleaning up files...
Successful clean up
ERROR: Job failed: Process exited with: 1. Reason was:  ()
1 Like

I have the same error, did you find any solution?

Apparently this was connected to some special characters in my app certificate/provisioning profile. Setting up the certificate and the provisioning profile without any special character solved the issue for me.

Any Solution? My company name is NOVEWEB AGÊNCIA DIGITAL LTDA ME and the distribution certificate generated by apple comes with this name using special char “Ê” in company name. Maybe it is the problem. I’ve regenerated provisioning profile and P12 certificate but without success.

Do you know the exact octet sequence (raw bytes) here? Ê in ISO-8859-1 is just 0xEA, but in UTF-8 it needs to be 0xC3 0xAA.

Problem solved requesting to Apple my organization name change.

I requested to change the name of my organization on the apple developer console from AgÊncia to AgEncia, without accent. After that I generated a new certificate and a new provisioning profile and reinstalled both on ionic appflow console.

After this changes, development and production build services is working without errors.