Cordova ios error building Images.xcassets

Viewed 31190

I've spent a lot of time trying to work this out to no avail.

I udpated cordova and since el capitan my mac now has issues with NPM and cordova.

I got it to install but I have to use sudo for cordova now.

I tried the following:

sudo cordova platform remove ios
sudo cordova platform add ios
sudo cordova build ios

And this gives me the following output:

** BUILD FAILED **


The following build commands failed:
    CompileAssetCatalog build/emulator/<AppName>.app <AppName>/Images.xcassets
(1 failure)
ERROR building one of the platforms: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/cordova/build-debug.xcconfig,-project,<AppName>.xcodeproj,ARCHS=i386,-target,<AppName>,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/sharedpch
You may not have the required environment or OS to build this project
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/cordova/build-debug.xcconfig,-project,<AppName>.xcodeproj,ARCHS=i386,-target,<AppName>,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/sharedpch

Cordova version

sudo cordova -v
6.0.0

Update: I'm now running 6.1.1, still the same issue

Cordova iOS platform version

sudo cordova platform ios -v
6.1.1

Mac Version: 10.11.3
XCode Version:7.2.1

10 Answers

For a solo icon.png file, the image must be 1024x1024 to get working with a solo <icon src="icon.png"/> in the config.xml.

I have to this with cordova-cli 6.5.0, cordova-ios 4.5.1 and xcodebuild 9.0.

Ths simple solution that I have tried is to add the correct size of the image 1024x1024

   <platform name="ios">
        <icon src="res/icon-1024.png" />
    </platform>

This is not a difficult error.Only thing has to do is remove all lines with

Images.xcastsets

from

platform/ios/.xcodeproject

Then remove platform ionic cordova platform rm ios, Add platform again and build.

ionic cordova platform add ios

ionic cordova build ios

I had the same problem as the OP and whilst the accepted answer was correct and helpful there is now an updated (and maintained) resource generator on npm called cordova-res, which replaces cordova-icon and cordova-splash. Also, the required splash screen dimensions have increased. All the details you need are on the npmjs cordova-res page, from which I have taken the following info.

Install with:

npm install -g cordova-res 

You'll need your icon.png and splash.png (the website says JPEG or PNG) images ready. These need to have the following dimensions:

icon.(png|jpg) must be at least 1024 × 1024px

splash.(png|jpg) must be at least 2732 × 2732px (note the increased size)

Just a little side note about the splash screen. Your image needs to be in the centre of the splash screen so that different rectangular device sized images are generated without cropping your splash screen image. As the accepted answer says, the size of this centre image needs to be about 1200 x 1200px.

Place these images in a resources folder in your project:

resources/
├── icon.png
└── splash.png

Before you generate the resources it might be worth removing and adding your ios platform (and others if you're building them too) to start with a clean platform folder. I don't know for sure if this is necessary.

cordova platform remove ios
cordova platform add ios

Run the following to generate the resources:

$ cordova-res

Then you can build your platform:

cordova build ios

Now all should be OK and hopefully resolved your xcassets error, as it did for me.

Related