I have a framework that includes a command line utility. This application is called by third party applications to perform certain tasks. There is no way I can go around not having this utility.
I've written the code and added the .m file to my project. I created a new target for it of the Core Foundation type. I added the right files to the Compile Sources section under Build Phases. But for some reason, Xcode doesn't build my utility. Whenever I build the framework and expand the Products group, the command line utility is left red.
How do I force Xcode to build it?
Don't sure if I understand you correctly.You have a framework with utility and you want to include that utility to your boundary? Than you probably need to add that utility to "Copy Files" section of "Build Phases"
Or you want to build utility in your project?
Than you probably need to add "Command line tool" target to your project.
Edit: To link two targets just add dependcy target to the "Target Dependencies" section of "Build Phases" of the main target.
Related
I normally use Qt creator with cmake to program C++ projects. Lately I read quite a bit about meson and it's simplicity and I like to test it. This example explains how to setup meson.
When using meson, I like however to still use Qt creators shortcuts for building (ctrl + B) or running (ctrl + R). How can I configure Qt creator to build a meson project, when I'm using a "generic project"?
Meson is currently not directly supported by Qt Creator. There is a bug report requesting that: https://bugreports.qt.io/browse/QTCREATORBUG-18117 and I am considering to actually implement that.
For the time being I use meson via the "Generic Project". Go to "New File or Project", "Import Project" and there "Import Existing Project". That gets you a dialog where you can select the files that your project consists of.
After that is done you will need to edit "projectname.includes" and add the include directories (one per line) into that file. Then you need to edit "projectname.config" and add defines (one per line) there.
Finally you will need to edit the build configuration and call ninja instead of make there.
With that it works reasonably well for my small project.
Until the QtCreator supports directly meson.build project files, I find this python2 script useful to create QtCreator generic project files: https://github.com/mbitsnbites/meson2ide
with meson and ninja in your PATH, this should work:
$ meson builddir
$ python2 meson2ide.py builddir
this generates a .creator project file in builddir (if you get an error about "mesonintrospect" not found, try this PR: https://github.com/mbitsnbites/meson2ide/pull/1)
To make CTRL+B work properly, In QtCreator build settings, remove the make build step and add a custom build step with the path to the ninja executable, and add the command line arguments
3>&1 1>&2 2>&3
Those redirect allow QtCreator to capture build errors in the "issue" panel.
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 need to do some tasks before any Archive launched in Xcode.
Is there any way in Xcode to add a .sh or .py script run before Archive ?
PS : I can complete these tasks by hand but it requires time, some tasks might be forgotten or if the process is done by someone else all the tasks can be forgotten. The problem is that these tasks are required to have a successfull Apple validation.
Thanks
You can add script build phases at any point between the existing phases. Here is a post which shows you how. In Xcode 4 you select your project, then go to the build phases tab were you usually have the "target dependencies", "compile sources", "Link binary with libraries" and "copy bundle resources" phases, just click on "Add build phase" and select "Add run script". You can select your shell, but not script in python from there.
You can also look at building xcode projects from the command line. You could call that command line from a python script and do anything else you want from "outside" the Xcode project.
I'ld like to automatically detect (using #ifdef) whether I'm building using XCode or using make under Darwin. Is there a specific define to XCode or make set automatically by either tool? I'ld like to avoid setting a define in the XCode project or Makefile manually.
If you look in the XCode 'build results' window, and expand one of the "compile MyFile.m" lines (select the line, then click on the "lines of text" icon at the far right), you can see the exact command XCode is using to invoke gcc, including any "-D" options on the command line.
I don't believe make is adding any -D defines automatically.
Simple question. Are there any tools for generating Xcode projects from the command line? We use SCons to build our cross-platform application, but that doesn't support intrinsic Xcode project generation. We'd like to avoid creating the project manually, since this would involve maintaining multiple file lists.
Look at CMake. You can generate XCode projects from it automatically. I found a previous StackOverflow question about its usage here. To get it to generate an XCode project, you use it as such:
CMake -G xcode
You can use premake (http://industriousone.com/premake) to generate Xcode projects. It can also generate Visual Studio projects.
For the benefit of anyone who lands on this question, I’ve actually just pushed an Xcode project file generator for SCons up to Bitbucket.
I think that your question should be "Is there a way to generate an XCode project from a SCons one?". I suppose, by your asking and by reading the others, that the answer is 'no'.
SCons people should know it better. I think they will be happy if you contribute a SCons Xcode project generator.
In the meantime you may choose to switch to CMake or to create your XCode project by hand that, given a good source tree organization, may be the best pragmatic solution.
qmake in the Qt toolchain generates Xcode projects. You can at least download it and take a look at its source here (LGPL).
You can generate a XCode project using the python based build system called waf. You need to download and install waf with the xcode6 extension:
$ curl -o waf-1.9.7.tar.bz2 https://waf.io/waf-1.9.7.tar.bz2
$ tar xjvf waf-1.9.7.tar.bz2
$ cd waf-1.9.7
$ ./waf-light --tools=xcode6
That will create a waf executable which can build your project. You need to configure how to generate your XCode project inside a file called wscript that should reside in your project folder. The wscript file uses Python syntax. Here's an example of how you could configure your project:
def configure(conf):
# Use environment variables to set default project configuration
# settings
conf.env.FRAMEWORK_VERSION = '1.0'
conf.env.ARCHS = 'x86_64'
# This must be called at the end of configure()
conf.load('xcode6')
# This will build a XCode project with one target with type 'framework'
def build(bld):
bld.load('xcode6')
bld.framework(
includes='include',
# Specify source files.
# This will become the groups (folders) inside XCode.
# Pass a dictionary to group by name. Use a list to add everything in one
source_files={
'MyLibSource': bld.path.ant_glob('src/MyLib/*.cpp|*.m|*.mm'),
'Include': bld.path.ant_glob(incl=['include/MyLib/*.h', 'include'], dir=True)
},
# export_headers will put the files in the
# 'Header Build Phase' in Xcode - i.e tell XCode to ship them with your .framework
export_headers=bld.path.ant_glob(incl=['include/MyLib/*.h', 'include/MyLib/SupportLib'], dir=True),
target='MyLib',
install='~/Library/Frameworks'
)
There are a bunch of settings you can use to configure it for your project.
Then to actually generate the XCode project, cd into your project folder where the wscript is and run your waf executable like
$ ./waf configure xcode6
A promising alternative to CMake which can generate Xcode projects is xmake. I haven’t tried it yet, but it looks good from the documentation.
Install xmake, create a simple project file (xmake.lua):
target("test")
add_files("src/*.cpp")
Then you can either do a command-line build:
xmake
or create an Xcode project:
xmake project -k xcode
Note that currently xmake seems to invoke CMake to generate the Xcode project, although they say they plan to add native Xcode project generation at some point.
You could use Automator to generate them for you.
I checked and there is no prebuilt action.
Therefore you would have to record your actions with Automator to do this.