Search code examples
cordovajenkinsxcodebuild

Build cordova project using xcodebuild command


I m working on custom plugin for Jenkins to build iOS project using command line. The native project able to build using xcodebuild command where as the hybrid (cordova) project when I build getting build failure.

Shell script:

xcodebuild -project app.xcodeproj -alltargets

The error I m getting is

app/Classes/AppDelegate.h:30:9: fatal error: 
      'Cordova/CDVViewController.h' file not found
#import <Cordova/CDVViewController.h>

Same for other class files as well.

The folder structure is as below.

App
- CordovaLib  
   -CordovaLib.xcodeproj
- Cordova
   -build 
   -run
- App.xcodeproj

Help appreciated


Solution

  • Use -scheme instead of -target or -alltargets:

    xcodebuild \
        -scheme ${projectname} \
        -project ${projectname}.xcodeproj \
        -configuration Release \
        -sdk iphoneos \
        build \
        CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" \
        PROVISIONING_PROFILE="${PROVISIONING_PROFILE}" \
        OBJROOT=${AngejiaBuildPath} \
        SYMROOT=${AngejiaBuildPath}