34

I've successfully built the iOS app with the ionic build ios command. But now I want to use TestFlight and it asks me for an IPA file. It seems that file is not generated with that build command. So, how can I generate it?

Thanks

nicolasaiz173
  • 590
  • 1
  • 4
  • 12

4 Answers4

38

You can easily build IPA from ionic framework. by following these steps

  1. Navigate to app folder

OS X terminal with list command

  1. Run cordova build command

OS X terminal running ionic build command

  1. Open the Xcode Project

OS X Finder with project location

  1. Clean the project

XCode Product -> Clean menu

  1. Select iOS mobile device to build for, don't use iOS emulator as device otherwise the archive is disabled.

Xcode Target device selected

  1. Archive the project

Xcode Project -> Archive menu

  1. Distribute the project

XCode Organizer

  1. Choose a method for distribution

Selecting method for distribution

  1. Choose a Profile

Choosing a profile

  1. Select a location to save the .ipa file

Saving IPA file to Desktop folder

I have generate my .ipa file by using these steps hope it will works for your's.

alonsovb
  • 517
  • 4
  • 14
Roshan Bharti
  • 616
  • 6
  • 15
  • 3
    You need to have the correct provisioning profiles setup in order to run the archive command. Perhaps you could mention/link this. – Marc Mar 10 '16 at 17:31
  • @roshan-bharti this steps works with Ionic 2? ,because I don't have enable the `archive` option – Cristian Oct 27 '16 at 20:49
  • @CristianChaparroA. yes it works. Check out step 5 - by selecting Generic iOS Device the archive option will be enabled – Bernardo Dal Corno Nov 05 '16 at 11:08
  • Is it possible to generate an unsigned ipa? Someone else is going to publish the application and they require an unsigned ipa and apk from me. Android is easy but I have no idea if you can even build ipa without signing. – DFSFOT Mar 22 '19 at 12:06
6

this article is kind of old but should help you.

In Command line change into the folder that contains your *.xcodeproj, and run the following:

xcodebuild -target "My Target" -scheme "My Scheme"
-configuration Release clean archive

Now you’ve got your xcarchive , Following line will generate ipa which you can upload to TestFlight.

cd platforms/ios/build/device/usr/bin/xcrun -sdk iphoneos PackageApplication "$(pwd)/$PROJECT_NAME.app" -o "$(pwd)/$PROJECT_NAME.ipa"

Hope this helps

Bhumit Mehta
  • 16,278
  • 11
  • 50
  • 64
  • is it possible to do this from my ubuntu.. I try to do ```ionic build ios``` but it gives me an error. Is this solution only for macs? – HIRA THAKUR Oct 26 '15 at 06:16
  • I am getting stuck between step 6 and step 7. I select Product > Archive, and I get "Build succeeded". I then cannot find a list of archives. – JonathanPeel Nov 17 '16 at 08:57
  • 1
    @Bhumit, I am new to IONIC. Is above commands still works for IONIC3?? I am looking for sequence of command to generate ipa using terminal. Thanks in advance. – Tushar Trivedi Dec 03 '18 at 20:29
  • see new command for PackageApplication https://stackoverflow.com/questions/43094380/whats-the-replacement-for-xcodes-packageapplication#43116435 – pungggi Sep 03 '19 at 15:13
1

What I do is to run this command:

ionic cordova run ios

It will build and make the project, generate the IPA and then launch the simulator. At that moment I just quit the simulator and voila! I have my IPA with just one command (Ionic 4).

VictorEspina
  • 352
  • 2
  • 7
  • 1
    what is the path where .ipa file is? – jcmendes98 Feb 01 '20 at 23:58
  • It should be under platform/ios/build... but I was just.a newbie when I posted that comment. I do know now that building an IPA that is actually usable on other devices its a much more complex task. – VictorEspina Jul 01 '20 at 23:29
0

Use npx ionic build ios --device to build the IPA for debugging and adhoc installations

Use npx ionic build ios --device --release to build for release.

You need to have a build.json file to specify your keys. Note the CLANG is to prevent compilation errors from the CocoaPods which they made into an error rather than a warning from before.

{
  "ios": {
    "debug": {
      "buildFlag": [
        "CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES"
      ],
      "developmentTeam": "XXXXXX",
      "automaticProvisioning": true,
      "packageType": "development"
    },
    "release": {
      "buildFlag": [
        "CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES"
      ],
      "codeSignIdentity": "Apple Development",
      "developmentTeam": "XXXXXX",
      "automaticProvisioning": true,
      "packageType": "app-store"
    }
  }
}

Before it will upload to AppStore/TestFlight you need to modify the platform/ios/exportOptions.plist file to include

<key>destination</key>
<string>upload</string>

Then deploy it to the AppStore as follows

xcodebuild -exportArchive -archivePath "platforms/ios/myApp.xcarchive" \
  -allowProvisioningUpdates \
  -exportOptionsPlist platforms/ios/exportOptions.plist \
  -exportPath platforms/ios/build/device

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265