I know how to build an existing Xcode project using xcodebuild, but I also need to generate Xcode projects from maybe a Python/Shell script. Is there any document somewhere that describes the process?
From personal experience generating xcode projects by hand is a pain; I've never seen a clear format defined anywhere, besides Apple keeps changing/adding stuff to it with each new version of Xcode.
I think the easiest way would be to use cmake/qmake or scons to generate your xcode project for you. For example, using cmake for this is pretty simple: you can have your script generate cmake makefiles, then run "cmake -G xcode" on those and it will create an xcode project for you. Also, since you mentioned python you could probably look into using scons for this purpose.
One possible way is to generate a project with Xcode and recreate the file hierarchy with your script.
Related
I have a Swift demo project that comes bundled with my framework. I want to ensure that the Swift code in the demo compiles successfully with both Xcode 6 (Swift 1.2) and Xcode 7 (Swift 2.0) without user intervention.
Since there's only marginal preprocessor support in Swift, how can I determine at compile-time which version of Swift or Xcode is being used to compile the code?
Now, here's the important detail:
It has to work automatically!
Open the project in Xcode 6 -> compiles
the Swift 1.2 code.
Open the project in Xcode 7 -> compiles the Swift
2.0 code.
No build settings or other means that require the user to specify, one way or another, which Swift/Xcode version she is using.
I keep thinking: this is such a trivial task, how could that not be possible with Swift?
As a framework developer this is driving me nuts since a successful compile of a Swift project now entirely depends upon the user's version of Xcode, and I can't ask them all to "update to Xcode 6.4" and at a later point having to ask them all over again to "update to Xcode 7.1". This is insane!
The alternative would of course be to have separate demo projects, managing different code bases, one for each version of Swift. And hoping the user will know what project will work with her version of Xcode. Not a real alternative.
The other alternative, to simply not use any of Swift 2.0's enhancement, is unfortunately not possible either. There is syntax, classes and methods that won't work in one or the other Swift version, if only due to the compiler being more picky in newer Xcode versions.
You can accomplish this using some of Xcode's advanced build settings, in particular:
XCODE_VERSION_MAJOR: Which encodes the Xcode major version as a string like "0700".
EXCLUDED_SOURCE_FILE_NAMES: A "fnmatch"-style pattern of source files to exclude by default.
INCLUDED_SOURCE_FILE_NAMES: A "fnmatch"-style pattern of source files to include.
I would not generally recommend doing this, as it will make your project hard to understand for most Xcode users, but if you absolutely want to make it work you can use this technique.
The way you accomplish it is as follows:
For any source files which need to be versioned, name them something like "Thing-Versioned-0600.swift" and "Thing-Versioned-0700.swift". Make sure both files are in the sources build phase.
Use the excluded mechanism to prevent any versioned files from being compiled by default, by adding a project-level build setting: EXCLUDED_SOURCE_FILE_NAMES = *-Versioned-*.swift.
Use the included mechanism to only add back in files that match the current Xcode major version, by adding another project-level build setting: INCLUDED_SOURCE_FILE_NAMES = *-Versioned-$(XCODE_VERSION_MAJOR).swift.
Having 2 versions of the code inside your project won't work since the code would not compile. There is no compiler directive for conditional compiling based on a version.
There is one workaround that could work (did not test it)
First create 3 files named version_current.swift, version_1_2.swift and version_2.swift. Make sure that only version_current.swift is part of your build target.
Then create a new build script phase and place it right above the 'compile sources' phase. In that script you will copy over the content of either the 1_2 or the 2 version over the current.
My scripting knowledge is not so good, so I can't give you much help doing this. You can get the version with code like:
$ xcrun swift -version
And then just execute a copy statement.
But then this will only work for the default Xcode version on your system. When you want to use a different version, you also have to change the default version.
I'm really interested in an Arduino IDE project from GitHub, but since I'm a new programmer i don't have figured out how to compile those source files on my Mac. There is already ported to Mac as it shows on the version 0.6.0.0 changelog but i just does not know how to do it.
Can someone provide instructions for me?
GitHub link:https://github.com/aporto/mariamole
So as I'm sure you've noticed, that project is a vcxproj-- i.e visual studio. Compiling it on Mac would require some finagling. I don't have experience myself, but I found this in my queries for you
How to support both vcxproj to cmake on a project?
You're going to want to read up on a lot of resources to try to get a better understanding and maybe form a better google query. Alternatively the easiest route would just to get your hands on a windows machine to build this
Good luck!
You have two options:
1) There's already a cmake project included in the project file. It's used for compiling it at Linux
2) There's also a Qt .pro file, also included in the project files, that you can load at Qt Creator
I'm having an issue with xcode. My project has a lexer which should be created (from lexer.l) before compiling anything. Flex should create two files from lexer.l: lexer.c and lexer.h. The latter is included in some other files. What happens now is Xcode does not process lexer.l and then complains about missing lexer.h. lexer.l is include in the compile sources list under build phases. Any thoughts?
One year late I can provide a solution. Maybe someone else can use it.
As I read on some answer on SO Xcode needs some special file extensions to map them to the different programming languages. When you want to compile c++ code f.e. you have to give the lexfile the ending .lpp. Xcode will handle the rest
I'm using Xcode 3.2.1 on OSX 10.6.8, and I want to study how Avogadro works by debugging its source code. There is a CMake guide here:
https://web.archive.org/web/20160816105549/http://avogadro.cc/wiki/Compiling_on_Linux_and_Mac_OS_X
that explains how to do it (and the sources are provided), but I am not very familiar with debugging. How do I organize the source files into a new Xcode project and step through a compiled version?
Here is the git clone command:
git clone --recursive git://github.com/cryos/avogadro-squared.git
I spot a folder called /Users/Eric/Desktop/avogadro-squared/avogadro/avogadro/src but I'm unsure as to how to proceed with setting flags etc., since the project is originally compiled in Cmake.
I'm not familiar with Avogadro but I just downloaded the source. There are not any xcode projects that I could find. So if you want to use Xcode to debug it you will need to create the necessary projects. How do you do that? Well, Avogadro seems to be built up with several other sub modules, openqube, openbabel, and eigen in particular. So you will need to create xcode projects for them also (if they don't have them already.)
This is not a small job, you'll need to read the makefiles and see what libraries they need etc...
But, and this is the good news, once it is done you will have learn a lot about how Avogadro is built which will help you learn how Avogadro works, which was your goal.
And when you are done, you can then offer up your changes to the community, after all, that is what open source is all about, right?
Avogadro uses CMake, and CMake is a build system generator (part of the reason we chose it). So you can use its generator mechanism to request an Xcode build system. There is a general answer on StackOverflow to generate an Xcode project using CMake. You are looking at the superbuild which gathers/builds all dependencies - you really want to go into the avogadro subfolder and open that in Xcode.
I'd like to use all the power of Xcode for generic C/C++ projects but I can't figure out what are the basic steps to configure a new Xcode project and attach it to an existing source tree of a legacy, plain, C/C++ project.
Creating a new empty project, attaching it to a source tree and configuring a build target (using GNU Make) was a really silly task.
I can't figure out how to enable source code indexing in order to enable source refactoring tools, searching and fast-jumping and all the amenities that makes the Xcode programmer's life great.
Moreover I'd like to use the internal debugging facilities…
Does anyone point me to a tutorial, a hint or whatever could be useful?
Thanx
I've found a (dirty) path to enable refactoring tools:
I've added a new standard «console target» to the project and added all the source files under the Build Phases > Compiled Sources.
Refactoring tools now works. Having two targets doesn't seem to be a relevant issue (elegance apart)
Personally, I wouldn't attempt to use legacy Makefiles, even though I think there's some support for that.
Typically what I do with a traditional C/C++ project is to store my XCode project folder at the root of the project. So it might look like:
--myApp
--src
--inc
--myApp Xcode
I then drag the src folder and inc folder into the project navigator. This gives me an Xcode project to compile with on the Mac, and then I have the traditional Makefile for compiling on Linux (actually, I prefer CMake for other platforms, but either way works).