question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IPA build is not working

See original GitHub issue

Hi,

I followed this guide https://www.robincussol.com/build-standalone-expo-apk-ipa-with-turtle-cli/ to build the ipa file. The build was successful. Then I uploaded the ipa file to the App Store. Installed TestFlight to install the App on my IPhone. When I open the App following error occur.

Error

Could not connect to development server
...
URL: http://127.0.0.1:8000/bundles/ios-8beb0c...9b.js

Build Environment

build-ios.sh

#!/bin/bash
[ -z "${EXPO_IOS_DIST_P12_PASSWORD}" ] && echo "EXPO_IOS_DIST_P12_PASSWORD is unset" && exit 1;
[ -z "${APPLE_TEAM_ID}" ] && echo "APPLE_TEAM_ID is unset" && exit 1;
[ -z "${BUILD_NUMBER}" ] && echo "BUILD_NUMBER is unset" && exit 1;

printf "\n\nInstall imagemagick\n"
brew install imagemagick

printf "\n\nInstall Expo\n"
npm install -g expo-cli || exit 1;

printf "\n\nInstall turtle-cli\n"
npm install -g turtle-cli || exit 1;

printf "\n\nInstall yarn install\n"
yarn install

printf "\n\nSetup SDK\n"
turtle setup:ios --sdk-version 39.0.3

printf "\n\nRemove Alpha Channel and replace transparency with white\n"
find assets -name "*.png" -exec convert "{}" -background white -alpha remove -alpha off "{}" \;

printf "\n\nUpdate buildNumber\n"
jq ".expo.ios.buildNumber = \"$BUILD_NUMBER\"" app.json > app.new.json && \
  mv app.new.json app.json

printf "\n\nBuild Expo\n"
rm -rf dist
expo export --dev --public-url http://127.0.0.1:8000

printf "\n\nStart Webserver for dist\n"
cd dist || exit 1;
python3 -m http.server &
cd ..

printf "\n\nBuild iOS\n"
turtle build:ios \
  --team-id "${APPLE_TEAM_ID}" \
  --dist-p12-path ios_distribution.p12 \
  --provisioning-profile-path example_Test.mobileprovision \
  --allow-non-https-public-url \
  --public-url http://127.0.0.1:8000/ios-index.json \
  -o app.ipa

Build-Log

What should I do?

Is this behavior normal? Should I provide every build version on a public server? It feels wrong to keep all versions public. On the Android build I don’t need to do it.

Thank you for your help!!

Greets, Tobias

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
charles-m-knoxcommented, Mar 30, 2021

For what it’s worth, I was able to find a solution to this problem using Let’s Encrypt with a subdomain you can control, without having to upload any of your files anywhere.

Context: https://github.com/expo/turtle/issues/302#issuecomment-809848518

Guide: https://github.com/charles-m-knox/space-codes#building-locally

0reactions
charles-m-knoxcommented, Jan 3, 2022

@susonthapa Here you go, best of luck! P.S. I don’t own a Mac or do Expo app development any more, so I probably can’t help if issues arise : (

Building locally

Building locally is required because the mp3 files in the assets/audio directory are 60mb each on average, and Expo’s build servers will reject them because they’re too big (Cloudfront rejects them as well).

First, install Turtle:

npm install -g turtle-cli
# if the above fails on Mac M1 due to vips, install vips via brew:
brew install vips # this will install a LOT of stuff
# retry installing turtle-cli

Since we are building locally, we have to create a TLS-enabled (and trusted) file server, which will host the dist files from Expo, including the build manifests.

export BUILD_DOMAIN=turtlebuilder.site.com

Install certbot so we can acquire a TLS certificate:

brew install certbot

Acquire a TLS certificate for your domain using a DNS acme challenge - you have to run as sudo because certbot requires access to /etc/letsencrypt as well as /var/log/letsencrypt:

sudo certbot certonly --manual \
    -d "${BUILD_DOMAIN}" \
    --preferred-challenges dns-01 \
    --server https://acme-v02.api.letsencrypt.org/directory

# you will be prompted for DNS verification, don't press anything and continue reading.

This will require you to go to your DNS portal (such as Cloudflare) and create a TXT record under _acme-challenge.turtlebuilder.site.com with the value it specifies.

In a new terminal window, check the DNS record:

# verify that the record shows up in DNS before proceeding
dig TXT _acme-challenge.${BUILD_DOMAIN}

Back in your certbot terminal window, hit enter, and it should succeed.

Next, you have to update your local DNS. Your computer must believe that your local system’s IP address is actually ${BUILD_DOMAIN}. There are many ways to do this; the best options are:

  • (local system only) - add your build domain to /etc/hosts, in the form of 192.168.x.y turtlebuilder.site.com
  • (network-wide) - add your build domain to your network’s DNS configuration. Since everyone has a different network setup, I can’t reasonably instruct you on how to do this.

Now that you have a valid certificate for your domain and your device(s) are setup to work with your custom DNS settings, you can export your assets/bundles/manifests with Expo to the local dist directory - by specifying --public-url, we will be telling Turtle that everything is accessible via that URL when it tries to download all the assets for building:

expo export --public-url https://${BUILD_DOMAIN} --force

Finally, run Caddy - the ./caddy/Caddyfile will mount ./dist and it will be directly accessible via https://${BUILD_DOMAIN} after starting:

brew install caddy # if not installed
cd caddy
BUILD_DOMAIN=${BUILD_DOMAIN} sudo -E caddy run

Building a simulator app

Luckily, this step is much easier than the official IPA build, since you don’t have to sign the package:

turtle build:ios \
    --public-url https://${BUILD_DOMAIN}/ios-index.json \
    -t simulator

Building the official IPA file

Finally, get ready to run the final build step. A few things to note about this:

  • You have to have obtained a wildcard distribution certificate via the standard Xcode setup process
  • You have to export the wildcard distribution certificate as a .p12 file from Keychain Access (using a strong password) on your Mac, and then ensure that password is entered into the script below
  • You have to create the provisioning profile using Apple’s developer portal, and make sure that it uses your Xcode wildcard distribution certificate
#!/bin/zsh -e
echo -n "iOS p12 certificate password: "
read -s DIST_P12_PASSWORD
echo ""
echo "starting..."
EXPO_IOS_DIST_P12_PASSWORD=${DIST_P12_PASSWORD} \
    turtle build:ios \
    --public-url https://${BUILD_DOMAIN}/ios-index.json \
    --team-id 01ABC234DE \
    --dist-p12-path ../certificates/apple-distribution-xcode-wildcard.p12 \
    --provisioning-profile-path ../certificates/Space_Codes_Xcode.mobileprovision \
    -t archive

In my experience, during every IPA build, I get prompted for my Mac local user account password ~4 times or so, maybe more.

Managing your distribution certificates

https://www.robincussol.com/build-standalone-expo-apk-ipa-with-turtle-cli/#53-build-ipa https://support.magplus.com/hc/en-us/articles/203808748-iOS-Creating-a-Distribution-Certificate-and-p12-File

You have to export and use your Xcode wildcard p12 certificate. Other certificates don’t seem to work, despite my best efforts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to install enterprise build in iOS 15 beta version
After updating the os, not able to install the enterprise app through ipa, it throws error unable to install the app. Kindly update...
Read more >
Guide to Fix the "unable to install .ipa file" Issue on iOS Devices
This guide leads you through all the necessary steps to find out the source of the "unable to install .ipa file" error message....
Read more >
I cannot build the .ipa file - Stack Overflow
I want to deploy my app on the Apple Store with flutter build ipa . When I run this command, ... Doctor found...
Read more >
"Show IPA file on build Server" not working - MSDN - Microsoft
Set as active configuration, clean and rebuild. Option will become visible within the "Tools" => "iOS" => "Show IPA on Build Server". Tuesday ......
Read more >
Xamarin iOS mobile app - VS 2019, v16.9.2 not creating iOS ...
The issue is, even though the finished build shows 0 errors and “Show IPA File on Build Server” option is enabled and clickable,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found