XCode - how to clean and compile in one operation? [duplicate] - xcode

This question already has answers here:
How to clean project before each build?
(2 answers)
Closed 7 years ago.
The code below fails at runtime because the photo member was removed from the Meal class. However the standard XCode build compiles successfully as there is no clean done by default.
Why is the default build option not to clean first and how can you get XCode to clean and build in one op? I'm coming from the Java/Maven world where the standard build does both (mvn clean install).
class Myclass {
var meals = [Meal]()
override func blah(...) {
let meal = meals[x]
cell.photoImageView.image = meal.photo
...
}

I would guess that they don't clean automatically before building because that would make some projects very unwieldy. If a lot needs to be built then you can save considerable development time in relying on previous build products and just building what needs to be built.
If you want to perform a clean and build in one step you can follow this answer:
Clean before build

Related

Netbeans (Maven) build vs clean and build vs build with dependencies

It might be a stupid question, but I'm new to maven. My question is simple: what happens exactly when using build, clean and build, and build with dependencies? and when to use each one?

"go build" does not generate file in golang [duplicate]

This question already has answers here:
What does go build build? (go build vs. go install)
(2 answers)
Closed 7 years ago.
I used go build to generate files. But I can only generate main, which mean go build main.go works while go build dao.go does not generate anything?
How can I generate dao?
From go help build:
When the command line specifies a single main package,
build writes the resulting executable to output.
Otherwise build compiles the packages but discards the results,
serving only as a check that the packages can be built.

Will I ever run into problems if I don't clean before I build?

I've written a git pre-commit hook that aborts the commit if my xcode project fails to compile.
It does this by running xcodebuild with the appropriate settings for my project. If the xcodebuild returns a non-zero status then you can't commit your changes.
Here is the xcodebuild command I'm running:
xcodebuild -project MYPROJ/MYPROJ.xcodeproj -target MYPROJ -configuration Debug clean build CODE_SIGN_IDENTITY='iPhone Developer' >/dev/null 2>&1
What I want to know is what issues will I run into if I remove the "clean" from the build command? I have a vague understanding of what "clean" does: remove previously compiled objects which will cause the following build command to build the entire project from scratch.
However, a full build takes a long time on our project whereas if we don't do a clean and haven't modified a lot, it can only take a few seconds. I'd like to keep our pre-commit-hooks fast and lightweight but I'm worried the build will get in some weird state and prevent a developer from being able to commit even though their code is fine.
Will I run into issues if I don't clean before every build for my pre-commit hook? Will it possibly incorrectly report a build error in some cases or get out of whack if I don't clean?
If you want to have certainty that your commit compiles, you should clean before building. Sometimes libraries and resources can get messed up, that's why the clean command exists. You want to make sure that someone who would check out that revision could compile the project with no issues. You can't guarantee that if you might have some leftovers from previous builds, such as old resources.
Imagine using an image for your GUI. You compile your app and it works. Then you restructure your resources a bit and somehow end up removing the image from the project. If you run the app again, it can still load the old image if you don't clean the project. So it will work for you, but not for someone with a clean build.

Maven re-build and deploy

I'm new to compiled web development, and I'm just trying to figure out the build/deploy process.... I've done:
mvn clean install
on a project, which built and deployed the project and now I can see it. If I want to make changes to the codebase, do I really need to run mvn clean install again to re-build and deploy the changes or is there a way to do a quicker build without using a "proper" IDE?
I'm using vim/gvim
Thanks!
Maven already handles the dependencies and only re-builds the necessary files... unless you throw away all previous build artifacts with clean! You should only need to use clean when you run into problems, or when you have checked out a different version from version control. Usually, mvn install should suffice.
You can integrate that with Vim; the simplest is to
:set makeprg=mvn
and then trigger a build with :make install.
Plugins build on that simplistic setup, e.g. check out:
maven-plugin
maven-ide

Is it possible to automatically generate Xcode projects?

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.

Resources