I have created a 'helloworld' iOS app with cordova using there documentation. The app successfully runs when I run cordova emulate ios. What I can't do, is while deploying when I run cordova build --release. It doesn't create any .ipa files there. All I find is a Helloworld.build file in the PROJECT_ROOT/platforms/ios/build directory. Am I missing something here?
 
    
    - 6,081
- 7
- 42
- 62
 
    
    - 2,092
- 2
- 26
- 35
5 Answers
I found this command which worked for me:
cordova build ios --device
cd platforms/ios/build/device
/usr/bin/xcrun -sdk iphoneos PackageApplication "$(pwd)/$PROJECT_NAME.app" -o "$(pwd)/$PROJECT_NAME.ipa"
Source: http://www.splinter.com.au/xcode-4-command-line-builds-of-iphone-apps/
I did run @MD. Mohiuddin Ahmed's Ruby script first, which would have changed my xcodeproj file. I'm not sure if that was necessary but I don't think so.
Update for XCode 8: As a commenter has noted, PackageApplication has been removed from XCode 8. To update the process, see the question: What's the replacement for Xcode's PackageApplication?
Edited to clarify process by adding cordova build command as suggested by comments.
 
    
    - 1,838
- 19
- 20
- 
                    14Right answer. Just to clarify: run `cordova build ios --device` to generate the app in `platforms/ios/build/device` – M165437 Sep 05 '14 at 15:11
- 
                    Yes that works great using `cordova build ios --device` – mike nelson Apr 16 '15 at 09:33
- 
                    1For some reason the `xcrun` line wasn't necessary for me.. I'm using Cordova 6, was it integrated into `cordova build ios --device` perhaps? When I ran that, it seems to have generated a properly signed ipa file using my XCode settings. – Julian Feb 04 '16 at 23:52
- 
                    1Seems PackageApplication is removed from xcode8, doesn't work for me. – Alba Hoo May 17 '18 at 03:43
If you are using cordova ios 3.9.0 or newer, you can use this command to create the .ipa directly from the CLI with no extra commands:
cordova build ios --device --release
You'll need a build.json file on the root of your project
{
  "ios": {
    "debug": {
      "codeSignIdentity": "iPhone Developer",
      "provisioningProfile": "your-dev-provisioning-profile-UUID-here"
    },
    "release": {
      "codeSignIdentity": "iPhone Distribution",
      "provisioningProfile": "your-distribution-provisioning-profile-UUID-here"
    }
  }
}
To get the UUID I open the .mobileprovision file on a text editor and search for 'UUID', not sure if there is an easier way of finding it.
If using Xcode 8 the build.json needs developmentTeam field and packageType field, but not longer need the provisioning profile, also, the codeSignIdentity should be iPhone Developer for both debug and release:
{
    "ios": {
        "debug": {
            "codeSignIdentity": "iPhone Developer",
            "developmentTeam": "FG35JLLMXX4A",
            "packageType": "development"
        },
        "release": {
            "codeSignIdentity": "iPhone Developer",
            "developmentTeam": "FG35JLLMXX4A",
            "packageType": "app-store"
        }
    }
}
http://cordova.apache.org/docs/en/6.x/guide/platforms/ios/index.html#using-buildjson
 
    
    - 51,328
- 11
- 132
- 176
- 
                    1Just as an FYI, this was not working for me. I mean it created a .app but not .ipa file. Turned out my iOS platform was 3.8, which is now out of date. An easy mistake to make so watch out for it. – Raymond Camden Feb 04 '16 at 14:25
- 
                    
- 
                    1
- 
                    NB/ UUID can be found in itunes by clicking on the serial number a few times or executing $ ios-deploy -c in the terminal if you have ios-deploy installed – Ian Warner Jul 06 '16 at 10:32
- 
                    2I talk about the provisioning profile (.mobileprovision) UUID, not the device UUID – jcesarmobile Jul 06 '16 at 10:45
- 
                    Note: with the latest (dev) release the required content of the build.json has changed. Please refer to the cordova documentation for more information – CWBudde Apr 03 '17 at 22:26
- 
                    @CWBudde have you read the part about Xcode 8? it explains how to use with latest cordova and Xcode 8 and also links the docs. I don't think there has been more changes – jcesarmobile Apr 03 '17 at 23:05
- 
                    @jcesarmobile it's no longer necessary to provide the provisioning profile UUID. However, if using SWIFT based plugins further build flags should be added. Read about the latest changes here: http://cordova.apache.org/docs/en/dev/guide/platforms/ios/index.html#xcode-build-flags – CWBudde Apr 06 '17 at 12:00
I finally figured out a way to automate this by using xcodeproj, xcode and this ruby script :
require 'xcodeproj'
xcproj = Xcodeproj::Project.open("HelloWorld.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
And then in the PROJECT_ROOT/platforms/ios/ directory this command helped me to generate my *.ipa:
xcodebuild -project HelloWorld.xcodeproj -exportArchive -exportFormat ipa -archivePath $(pwd)/HelloWorld.xcarchive -exportPath $(pwd)/HelloWorld.ipa CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -alltargets -configuration Release
Thought we can sign our .ipa later on :)
 
    
    - 2,092
- 2
- 26
- 35
You can try a new tool from http://fir.im.
They have a fir cli tool written in ruby. You can install it with the following command:
sudo gem install fir-cli --no-ri --no-rdoc
Sign up an account (all free like the good old testflight) and get a token from your profile. From your command prompt run:
fir login
Provide your token.
CD into your directory where your .xcodeproj located.
fir build_ipa . 
After a while (if the build success) you will find your ipa in your ./build_ipa folder.
 
    
    - 828
- 1
- 9
- 25
Everything else did not work for me but this works for me
cordova build ios
then
cordova run ios --device
The .ipa file is located at
myPrject/platforms/ios/build/device/myProject.ipa
build.json (set automatic siging)
{
    "ios": {
        "debug": {
            "codeSignIdentity": "iPhone Developer",
            "developmentTeam": "FG35JLLMXX4A",
            "packageType": "development",
            "automaticProvisioning": true,
            "buildFlag": [
                "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
                "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
                "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
            ]
        },
        "release": {
            "codeSignIdentity": "iPhone Developer",
            "developmentTeam": "FG35JLLMXX4A",
            "packageType": "app-store",
            "automaticProvisioning": true,
            "buildFlag": [
                "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
                "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
                "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
            ]
        }
    }
}
Reference docs
Voila!
 
    
    - 2,097
- 15
- 36