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?
Related
I have an XCode project with two executable targets, which I use for my own work (that is, I don't sell or publish the applications, but they are still important to me), which depends on one external project. Until now, it has been unproblematic to build the Application(s) and install into the /Applications folder. What I did, was go into the command line and type:
sudo xcodebuild -scheme Trainer install
This would install the target Trainer into the Applications folder, and the application could be run from there. If I tried to specify the target using -target Trainer instead, it would not work, as it would not find dependencies in the external project. Anyway, since last time it worked, two things have happened:
I have upgraded to OS X 10.11
I have upgraded XCode to Version 7.1.1 (7B1005)
Whatever the reason, xcodebuild does no longer install the built product into the /Applications folder. The last lines from the build log, when building with xcodebuild now are:
Touch /var/root/Library/Developer/Xcode/DerivedData/SoundSample-bvsqlgnuhfmtjkgkhevztdzbjbie/Build/Intermediates/ArchiveIntermediates/Trainer/BuildProductsPath/Release/Trainer.app.dSYM
cd /Users/pbholmen/Projects/SoundSample
/usr/bin/touch -c /var/root/Library/Developer/Xcode/DerivedData/SoundSample-bvsqlgnuhfmtjkgkhevztdzbjbie/Build/Intermediates/ArchiveIntermediates/Trainer/BuildProductsPath/Release/Trainer.app.dSYM
RegisterWithLaunchServices /var/root/Library/Developer/Xcode/DerivedData/SoundSample-bvsqlgnuhfmtjkgkhevztdzbjbie/Build/Intermediates/ArchiveIntermediates/Trainer/InstallationBuildProductsLocation/Applications/Trainer.app
cd /Users/pbholmen/Projects/SoundSample
builtin-lsRegisterURL /var/root/Library/Developer/Xcode/DerivedData/SoundSample-bvsqlgnuhfmtjkgkhevztdzbjbie/Build/Intermediates/ArchiveIntermediates/Trainer/InstallationBuildProductsLocation/Applications/Trainer.app
** INSTALL SUCCEEDED **
I have tried to simply copy the Trainer.app that it builds into the /Applications folder, but if I double-click on it, it just won't run. Of course, the Application works when built and run from within XCode, both with the "Debug" and "Release" configuration.
Back when it did work, this would be the last lines of the build log (in Terminal):
Touch build/Release/Trainer.app.dSYM
cd /Users/pbholmen/Projects/SoundSample
/usr/bin/touch -c /Users/pbholmen/Projects/SoundSample/build/Release/SoundSample.app.dSYM
RegisterWithLaunchServices /Applications/Trainer.app
cd /Users/pbholmen/Projects/SoundSample
builtin-lsRegisterURL /Applications/Trainer.app
** INSTALL SUCCEEDED **
If I try to go into the build log from within XCode, find where it puts the builds, and maneuver into that location in Finder and start the application from outside of XCode, that doesn't work either.
Here you can see my Deployment build settings for the target:
Build settings
Under "Deployment location" I have tried both "YES" and "NO", and under "OS X Deployment target" I have tried both "OS X 10.10" and "OS X 10.11". And all four combinations of the two.
After hours of twiddling, I finally figured out the answer. First off, the command
sudo xcodebuild -scheme Trainer install
is wrong. It was a workaround, because I couldn't get XCode to manage my external dependencies from the command line, even though they were managed correctly within XCode. The correct invocation, for a target other than the project's main target is
sudo xcodebuild -target Trainer install
Previously, the first invocation would work, the product would be installed even though the scheme doesn't really include an "Install" action. This is clearly no longer so with XCode 7.1. The reason I couldn't use -target instead of -scheme previously, was because my target was dependent on a framework in another project, which was added to my main project (the external project was added, not just the framework). All dependencies were set up correctly in my main project, and from the command line it worked only when specifying the scheme, not when specifying the target. When running xcodebuild with -target specified, xcodebuild would not find the modules in the external project (a Swift framework).
I have now figured out the reason for this. The project which contained the external framework was not set up correctly. It was set up to install the framework into a bogus location (/tmp/ProjectName.dst/Library/Frameworks, which is the default). In addition, my main project needed to add /Library/Frameworks into the framework search paths. It seems that when the project is built inside XCode, or for archiving etc... libraries and executables are built into a "private" folder structure separate from the system itself. When running xcodebuild install, however, it tries to install the external frameworks into the proper system folders, and link it there. Therefore, setups that work inside XCode may not work when running 'xcodebuild'.
EDIT: It works now, but StackOverflow won't let me mark it as correct before two days.
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
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"
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
I was using classic Unix Makefile generator until I found a webpage explaining CMake could produce a nice xcode project file using "cmake -G Xcode" so I ran that command in my source directory and I get a nice xcode project. This is great but I'm facing some drawback and was wondering if there are solutions to these :
now I can't build out of tree using unix makefiles (I use to run cmake ../myproj in a build dir and then make command) this doesn't work anymore (I suppose temp files in the project dir are responsible)
some of my headers are generated by cmake (myproj.h.in became myproj.h and is include in some tests for example) but I can't find those files in the xcode project I get.
Thanks in advance for any good advice on how I can combine xcode project and unix makefile to be able to use both.
I found the answer by myself (I mean asking the good person) :
Use 2 separate build directories for each type of build files. This will ensure each build directory has the correct build files and generated files for its use.
In the add_executable() command, in addition to the source files also include the headers and generated headers for those to show up in Xcode.
You can use xcodebuild to still have a proper Xcode project and build it from the command line/shell script/Makefile, e.g.
xcodebuild -project MyProject.xcodeproj -target MyTarget -configuration Release