Jenkins xcode plugin - how to resolve library search path issues? - xcode

I am running into this error in my jenkins xcode build which I'm attempting to setup:
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libIBAForms.a'
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libLambdaAlert.a'
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libRestKit.a'
I cannot figure out a few things regarding the configuration:
what prompted the jenkins-xcode-plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Xcode+Plugin ) to use /DerivedData/Release-iphoneos/ in the path for the lookup of the .a files
instead why didn't it select /DerivedData/Debug-iphoneos/ as the fragment in the path for the lookup to the .a files
finally the submodules that produce - libIBAForms, libLambdaAlert, libRestKit - are all projects that have a release and a debug profile ... so why the files are actually missing from the /DerivedData/Release-iphoneos/ path where they are supposed to be ... is beyond me.

Regarding points #1 and #2, this is configured based on the Configuration parameter for XCode plugin (and Xcode itself). By default, the plugin uses "Release" value for the parameter. If you want to use "Debug", you should set it as such.
Don't know what to say regarding #3
Personally, i found the Xcode plugin to be restrictive and not providing me with options that i needed. I am using the command line tools that came with xcode (through regular Execute Shell build step)
// Below are my build parameters for the job through regular means
CONFIGURATION=Debug
CODE_SIGN_IDENTITY=iPhone Developer: <DeveloperNameHere>
PROVISIONING_PROFILE=3000000B-7000-4000-9CD5-D0000B0F0000
//
// Code for Execute Shell
xcodebuild -verbose -alltargets -configuration ${CONFIGURATION} clean build CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" PROVISIONING_PROFILE=${PROVISIONING_PROFILE}
&&
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/path_here/${CONFIGURATION}-iphoneos/application.app" -o "${WORKSPACE}/path_here/${CONFIGURATION}-iphoneos/application.ipa" --sign "${CODE_SIGN_IDENTITY}" --embed "/Users/<youruser>/Library/MobileDevice/Provisioning Profiles/${PROVISIONING_PROFILE}.mobileprovision"
Setup parameters as usual for the job
The xcodebuild command does the actual build
The xcrun command packages the app into an IPA (the Archive step in Xcode), signs it, and embeds a provisioning profile directly into the IPA.
Note that some of these switches are options and may not be required for you. But that's the benefit of doing through the command line: you have full control of what you want to do
Small note: make sure you provide full paths to -v and -o switches on the second command

I was able to get past all this when I adeed the submodules which generate libIBAForms and libLambdaAlert as the main project's "Target Dependencies"

Related

Does xcode use "xcodebuild" under the hood?

Does xcode use of the xcodebuild command behind the scenes to build?
If so, how can I find the exact xcodebuild command that is run?
I checked the report navigator but couldn't find it in there.
I would have thought that running xcodebuild -sdk iphonesimulator -configuration Debug -project <myproject>.xcodeproj -scheme <myscheme> would be identical to selecting product -> build in xcode (with a scheme/destination matching the command line), but they seem to have slightly different behavior.
For example, when running the command line above with the -showBuildSettings option, I noticed that BUILD_ACTIVE_RESOURCES_ONLY=NO even though it should be set to YES according to the target's build settings. When running product -> build from xcode, the build settings logs (generated by following #Slipp D. Thompson's answer here) show BUILD_ACTIVE_RESOURCES_ONLY=YES.
There are few other strange differences I noticed as well.
No. One could do an experiment: move all xcodebuild binaries in some local folder and check that Xcode still able to build some application.
Since Apple presents xcodebuild as a self contained command line tool for building Xcode projects, it is reasonable to suspect that use code sharing between both tools.

Can't run Kiwi tests (XCTest) in xcodebuild (Xcode 6)

I'm trying to run my tests using the CLI tools. After following various guides, I came up with this command:
xcodebuild -workspace myworkspace.xcworkspace -scheme testsScheme -sdk iphonesimulator -arch i386 -configuration Debug TEST_AFTER_BUILD=YES clean build
The error I'm getting is:
The following build commands failed:
Ld /Users/<my name>/Library/Developer/Xcode/DerivedData/<project name>-gqrdtdiypfxjrbbjaqofxcjdckcg/Build/Products/Debug-iphonesimulator/<target or schema name>.xctest/<target or schema name> normal i386
I have no idea why the build fails as the error message is not very giving.
As for my pre-configuration, I've followed some guides and did the following: I've added a test-only scheme which targets my tests target (like I've seen in many guides), and also set it's executable to be the .app file (the default settings has no executable which results in an error that the app file is not found).
I'm using Cocoapods, and still not using the standard architecture (arm7, arm64) in my project (I'm dependent on a 3rd party that still hasn't upgraded, so currently my setting is $(ARCHS_STANDARD_32BIT)).
I've also checked that the "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests" run script appears and happens last in the build phases.
Note that running the tests using CMD+U works as intended.
EDIT: Apparently, The .app file wasn't created after a clean (so removing the clean or pre-building the app worked). Nevertheless (even though I need to solve this as well). I'm now getting this error:
PhaseScriptExecution Run\ Script /Users/shay/Library/Developer/Xcode/DerivedData/<name>-gqrdtdiypfxjrbbjaqofxcjdckcg/Build/Intermediates/<name>.build/Debug-iphonesimulator/<test schema>.build/Script-48FB07F617A93C57006E5E2A.sh
I've read that might happen when the iOS simulator is opened, but it happens even if I kill it before running the script.
After sleeping on it, I solved my issue by running:
xcodebuild -workspace <name>.xcworkspace -scheme <scheme> -sdk iphonesimulator -arch i386 -configuration Debug clean build test
Where the scheme is the original one, and not a specially-created one for the tests.

'Cordova/CDVViewController.h' file not found when run in Xcode terminal

So when I am trying to build my code from xcode terminal it is failing and giving me an error of 'Cordova/CDVViewController.h' file not found but when I am building this from xcode then it is building just fine.
In my Xcode, I've done the whole Cordova sub directory thing Upgrade Cordova. Also when I ran list. This is what I see below:
xcodebuild -list
Information about project "myProject":
Targets:
myProject
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes:
myProject
CordovaLib
Environment: Xcode5, OS 10.8.5
Is there anything I am missing? The reason why I am doing this because I am trying to run this through jenkins. I thought it was a jenkins issue but then I got it down to the xcode terminal not seeing the CordovaLib.
I've spent too much time figuring out the solution for this so it is a shame not to share. There can be many possible reasons why this problem arise but if you feel like you've set up everything right in the CordovaLib (like me!) and still has the same problem. This can be one of the causes. What's happening is when I ran the
xcodebuild -scheme myProject -configuration "Release"
it is building successfully, but if you don't supply "-scheme" it it will fail by default it is using the "Release". The parameters of the scheme will control which targets are built and how they are built, myProject scheme contains the subfolder and reference to Cordovalib.
Now, moving to Jenkins, is you need to supply the scheme in the "Xcode Schema File" text box in the Advanced Xcode build options section of the XCode Plugin.
My set-up is Xcode as my slave but this may still apply to whatever Xcode and Jenkins combination you have - so when I ran the
xcodebuild -list
I receive the message the following message:
If no build configuration is specified and -scheme is not passed then "Release" is used.
This project contains no schemes.
The solution for this is, in your xcode project, go to Product|Scheme|Manage Scheme and checked "Shared" to both projects myProject and CordovaLib. Compile. Check-in (because I am grabbing this from TFS). Ran again the "-list" command and you will see the schemes that you just shared.
Hope this helps!
Thanks a lot !
Just adding "-scheme" and "-configuration" parameters fixed the problem for me.
If it can help someone else, here is the full command line i used :
xcodebuild -scheme MyProject -configuration "Release" -arch i386 -sdk iphonesimulator7.1
I used it to generate a ios simulator build in order to submit an Phonegap / Cordova application to the Facebook Review
In build settings
add this item to "Header Search Path"
$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

Multiple command line tool targets in a single project in Xcode

Is it possible to have multiple command line tool targets in a single project?
I'm writing C++ with command line tool, and could build the first target but failed for the second one.
I'm using Xcode 4.1, Mac 10.7.4.
You can have multiple targets and build each of them from xcode commandline tools. You can specify the target from command line tool like:
xcodebuild -sdk iphonesimulator6.0 -target "HelloWorld"
and you can repeat this for each target. I also came across to building workspaces direclty you can check that out too.
Apple's Document about it;
If you have multiple projects in the this
directory you will need to use -project to indicate which project should be built. By default,
xcodebuild builds the first target listed in the project, with the default build configuration. The
order of the targets is a property of the project and is the same for all users of the project.
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

Building Qt Xcode Projects From the Command Line

I've been playing around with Qt for a few hours now. I found that qmake produces Xcode project files on Mac OS X instead of good ol' makefiles. I don't want to launch Xcode every time I want to build "Hello, world".
How do I make qmake generate regular makefiles or, if that's something that cannot be done on the Mac, how do I compile .xcodeproj files from the command line?
I tried xcodebuild -project myProject -alltargets. I get a lot of output followed by Abort trap.
$ man xcodebuild
So a typical command might be something like:
$ xcodebuild -project myProject.xcodeproj -alltargets
The open-source Qt binary installers for OS X from Trolltech default to creating .xcodeproj files when you run qmake. I don't use XCode for editing so it is a pain to open it to compile the project.
To compile your projects from Terminal.app, just set an environment variable of QMAKESPEC to macx-g++
If you want to just compile a certain project from the terminal, go into that directory and run
qmake -spec macx-g++
When you run qmake, this will create a Makefile which you can use by running make.
Try the following way. It has to work.
xcodebuild -project myProject.xcodeproj -alltargets
I have used this method in most of my projects.
Looking at this part of your back trace:
#
2008-12-18 20:40:52.333 xcodebuild[1070:613] [MT] ASSERTION FAILURE in /SourceCache/DevToolsBase/DevToolsBase-921/pbxcore/FileTypes/PBXCFBundleWrapperFileType.m:174
#
Details: path should be a non-empty string, but it's an empty string
#
Object:
#
Method: -subpathForWrapperPart:ofPath:withExtraFileProperties:
#
Thread: {name = (null), num = 1}
This implies that something, maybe one of your configuration variables, is blank when it needs to refer to a file. What I'm wondering is if maybe you have an extra target in your project that doesn't work, so that building with -alltargets is what's causing your problem.
I tested xcodebuild without any arguments on one of my projects just now - it did a default build of my project without errors. What happens if you try it without arguments?

Resources