acupedia-mobile-ui/docs/instruction_for_ios.md

10 KiB
Raw Permalink Blame History

iOS Release (.ipa) Build Instructions

Note: This guide explains how to build the native iOS release app (.ipa) locally on your Mac using Xcode command-line tools and CocoaPods, without using cloud EAS build.


Prerequisites on Mac (One-Time Setup)

Before building, make sure your Mac has:

  1. Xcode (Download free from Mac App Store).
  2. Xcode Command Line Tools:
    xcode-select --install
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    
  3. CocoaPods (Dependency manager for iOS native libraries):
    brew install cocoapods
    
  4. Node.js & Watchman:
    brew install node watchman
    

Step 1: Prebuild the iOS Native Project

Run this in your project root to generate the native ios/ directory, Podfile, and Xcode workspace:

cd ~/acupedia_mobile_ui
npx expo prebuild --platform ios

Step 2: Install CocoaPods Dependencies

Navigate into the generated ios/ folder and install the native iOS pods:

cd ios
pod install
cd ..

Step 3: Configure Code Signing (One-Time Setup in Xcode)

Apple requires all iOS binaries to be signed with an Apple ID or Apple Developer certificate (unlike Android which uses a local .keystore file).

  1. Open the project in Xcode:

    open ios/acupedia.xcworkspace
    

    (Important: Always open .xcworkspace, never .xcodeproj)

  2. In the left file navigator, select the top-level acupedia project.

  3. In the center pane, select the acupedia Target and go to the Signing & Capabilities tab.

  4. Check Automatically manage signing.

  5. In the Team dropdown, select your Apple ID / Developer Team (click Add an Account... if not logged in).

  6. Confirm the Bundle Identifier matches: com.anonymous.acupedia.


Step 4: Understanding Export Methods in ExportOptions.plist

In ExportOptions.plist, the <key>method</key> defines how the .ipa is signed and who can install it:

Method What it is When to Use Requirements
development Signed for local developer devices. Recommended for your testing. Install directly on your Mac or your own connected iPhone. Free personal Apple ID or paid Developer account.
ad-hoc Signed for external tester devices without App Store. When sending the .ipa file to outside clients/testers to test on their own iPhones. Paid Apple Developer Account ($99/yr) + recipient device UDIDs must be registered in Apple Developer portal.
app-store Production release signed for Apple's servers. Uploading to TestFlight or the Apple App Store. Paid Apple Developer Account. Cannot be installed directly on a phone via USB.

Which should you select?

  • For local testing on your own iPhone or simulator: Select development.
  • For sharing with remote testers outside your office: Select ad-hoc (or upload to TestFlight using app-store).

Create the file ios/ExportOptions.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>development</string>
    <key>signingStyle</key>
    <string>automatic</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>compileBitcode</key>
    <false/>
</dict>
</plist>

Step 5: Build the Release .ipa

You can build either via Terminal (CLI) or Xcode (GUI):

Method A: Terminal CLI (Equivalent to ./gradlew assembleRelease)

Run the following commands:

cd ~/acupedia_mobile_ui/ios

# 1. Clean and Archive the Release build
xcodebuild -workspace acupedia.xcworkspace \
  -scheme acupedia \
  -configuration Release \
  -destination 'generic/platform=iOS' \
  -archivePath build/acupedia.xcarchive \
  archive

# 2. Export the .ipa file
xcodebuild -exportArchive \
  -archivePath build/acupedia.xcarchive \
  -exportOptionsPlist ExportOptions.plist \
  -exportPath build/ipa

Your generated iOS release file will be located at: 📁 ios/build/ipa/acupedia.ipa


Method B: Xcode GUI Archive (1-Click Export)

  1. In Xcode, in the top destination bar, select Any iOS Device (arm64).
  2. In the top menu bar, click Product → Archive.
  3. When the compilation finishes, the Organizer window opens automatically.
  4. Click Distribute App:
    • Select Development (for connected phones) or Ad Hoc (for remote testers) or App Store Connect (for TestFlight).
    • Click Next through the signing steps and click Export.
  5. Xcode saves the acupedia.ipa to your chosen destination folder.

Step 6: How to Install the .ipa File on an iPhone

Unlike Android where you can simply tap an APK to install it, iOS requires a trusted installation method:

Method 1: Using Mac Finder (Fastest via USB)

  1. Connect your iPhone to your Mac using a lightning/USB-C cable.
  2. Open Finder on your Mac and select your iPhone under Locations in the left sidebar.
  3. If prompted on the iPhone, tap "Trust This Computer" and enter your passcode.
  4. Simply drag and drop the acupedia.ipa file directly onto the iPhone window in Finder.
  5. The app will install on your iPhone home screen within 10–20 seconds.

Method 2: Using Xcode Devices Window (USB)

  1. Connect your iPhone to your Mac.
  2. In Xcode, go to the top menu: Window → Devices and Simulators (or press Cmd + Shift + 2).
  3. Under Connected, select your iPhone.
  4. Under the Installed Apps section, click the + (plus) icon.
  5. Select acupedia.ipa and click Open. The app installs immediately.

If you built with ad-hoc and want to send the app to a remote tester without cables:

  1. Open free distribution services like Diawi.com or InstallOnAir.com.
  2. Upload acupedia.ipa.
  3. Share the generated link or QR code with the tester.
  4. The tester opens the link in Safari on their iPhone and taps Install. (Note: Requires the tester's iPhone UDID to be registered in your Apple Developer Account).

Method 4: Sideloadly (When Mac & iPhone are in Different Locations & Using Free Apple ID)

If the Mac and iPhone are in different locations and you do not have a paid Apple Developer Account ($99/year), you can send the raw .ipa file directly to the tester, and they can install it using their own computer (Windows PC or Mac) with Sideloadly:

  1. Send the file: Send acupedia.ipa to the remote user via Google Drive, WeTransfer, or Telegram.
  2. Download Sideloadly: On their computer (Windows or Mac), have them download and install Sideloadly (Free).
  3. Connect iPhone: Connect the iPhone to their computer using a USB cable. If prompted on the iPhone, tap "Trust This Computer" and enter the passcode.
  4. Open Sideloadly:
    • Sideloadly will automatically detect the connected device.
    • Drag and drop acupedia.ipa into the IPA icon box on Sideloadly.
    • In the Apple ID field, have the user enter their own personal Apple ID (email).
    • Click "Start".
  5. Installation: Sideloadly signs the application using their Apple ID and installs it directly onto their iPhone within 1–2 minutes!
  6. First Launch: The user must then complete Step 7 below (Trust Developer & Developer Mode) to open the app.

Method 5: 3uTools (Windows PC Alternative)

If the remote tester uses a Windows PC:

  1. Send acupedia.ipa to the tester.
  2. The tester installs 3uTools (Free) on their Windows PC.
  3. Connect iPhone to PC via USB cable.
  4. In 3uTools, go to Apps → Click "Import & Install IPA".
  5. Select acupedia.ipa and it installs directly onto the connected iPhone.

Method 6: Apple TestFlight (Official Remote Distribution)

If you have a paid Apple Developer Account:

  1. Build with <string>app-store</string>.
  2. Upload using the free Transporter app on your Mac.
  3. In App Store Connect → TestFlight, enter the tester's email address.
  4. The tester receives an invitation email and installs the app via the free Apple TestFlight app from the App Store (no cables, no UDID required).

Step 7: Required iPhone Permissions & Settings (Must-Do on Phone)

When launching the app for the first time, iOS security will block it until you enable these two settings:

1. Trust the Developer Certificate ("Untrusted Developer" Alert)

If you tap the app and see:

"Untrusted Enterprise Developer / Untrusted Developer: Your device needs to trust this developer before opening."

Fix:

  1. On your iPhone, open Settings → General → VPN & Device Management.
  2. Under Developer App, tap your Apple ID / Email.
  3. Tap "Trust [Your Email / Name]" and confirm.

2. Enable Developer Mode (iOS 16, 17, 18+)

On iOS 16 or newer, Apple blocks developer-installed apps until Developer Mode is toggled:

  1. On your iPhone, open Settings → Privacy & Security.
  2. Scroll to the very bottom and tap Developer Mode.
  3. Toggle Developer Mode to ON.
  4. Tap Restart when prompted.
  5. After reboot, unlock your phone and tap Turn On, then enter your device passcode.

Troubleshooting Common iOS Build Issues

Issue Cause Solution
"No signing certificate found" Xcode has no Apple ID account configured. Go to Xcode → Settings (or Preferences) → Accounts → Click + and sign in with your Apple ID.
"The maximum number of apps for free development profiles has been reached" Apple limits free Apple IDs to 3 active sideloaded apps. Delete any old test apps from your iPhone before installing, or use a paid Apple Developer Account.
App certificate expires after 7 days Free personal Apple IDs only grant 7-day provisioning profiles. Rebuild and re-install with Xcode after 7 days, or sign with a paid Apple Developer account ($99/year) which lasts 1 year.
"App Transport Security (ATS) blocked cleartext HTTP" App is trying to access an insecure http:// URL. Ensure .env uses https://api.acupedia.in (already configured). iOS strictly requires HTTPS.
CocoaPods error during pod install CocoaPods cache is out of date. Run cd ios && pod cache clean --all && pod install --repo-update && cd ...