I have 2 build files into separate projects,
build_common.xml,
build.xml which is the main build file.
I am trying to import a property from build_common.xml without importing the whole file. Is there a way to do that if I know the path to the build_common.xml?
Thanks
If you only want to import certain properties, they probably SHOULD be in separate files (broken apart by common use). That said, maybe one of your ant tasks could use grep, or some other collection of utilities to transform build_common.xml into a NEW file, that only contains what you want, and then import THAT?
I really don't think it's the BEST way to approach the problem, but I think it could work.
Related
Background
I'm porting a small Windows application to iOS using XCode 6.2 as both the IDE and build platform. I have a workspace created, which I'm using to compile and build all the projects. I currently build every project except the actual iOS app as a dynamic library, and then embed it in the final app package on deployment.
The Problem
I'm currently hard coding relative paths in the projects. Stuff like ../../shared-headers - I really don't like doing this as I have to figure out this path per project, and I'd prefer to use something like props files in Visual Studio, which would let me do something like $(SHARED_HEADERS) in projects.
This makes the projects easier to maintain, and any dependency extremely obvious. It also makes it much easier to move projects when the need arises. What is the preferred method to do this in XCode?
EDIT: I'd like to stick with a Visual Studio-ish include structure. While Copying headers is a good way to manage some of the complexity, I do not prefer this method because it will add time to the build, and developers from Windows will not be expecting this.
I too was looking for the same thing, and i've just found it! using an xcconfig file!
Create a .xcconfig file either from xcode's file menu or just a simple text file, and add your entires like so:
PATH_TO_SOME_SDK = Volumes/DEV/Project
SOME_DEFINITION = 7
once you add that file to the project, you can add it (or different ones) to each configuration in the project's info panel under "Configuration".
the definitions along with their values will then appear in the project's build settings under "User-Defined", and will change dynamically as the value in the file changes.
you can then use the values in any other build setting like any other environment variable or macro:
$(PATH_TO_SOME_SDK)
for more info:
https://nshipster.com/xcconfig
https://medium.com/better-programming/working-with-xcode-configuration-files-398cfbe02b64
https://help.apple.com/xcode/#/dev745c5c974
better late than never...
:-)
I'm a Java developer, and a new comer to ios development. In learning phrase, I try to download some sample projects (include from small one to medium one) for reading how often they do work in an ios project. As I see, often, they put all source file into one folder (include header file, source file, .storyboard file, xib file ...) and I see this will make your project become messy.
So, I come here to ask a question that. Should we put source code in separate folders base on their usage, to make project less messy, right ? For example, all custom core data model class files should put into Model folder. All View file (such as .storyboard, .xib file ...) should put into View folder. All Controller file should put into Controller folder ...
If you often do this, please tell me your experience, how you folder your code ? And does XCode support virtual folders (that in XCode IDE you see source code in folders, but in hard drive, they're just same).
Thanks :)
Xcode differs from Eclipse and Android Studio in maintaining a separate project-level division of resources into folders that need have no correlation whatsoever to the file system. Given that the lack of namespaces usually leads people to be very relaxed about what formally is and is not a 'package', it's a real wild west out there.
I tend to keep things organised by mental package — model, view, controller at the top level, e.g. maybe web services, persistent store under model, etc. But even then command+shift+O and type a symbol or class name is by far the easiest way to navigate a project.
Others might argue that keeping things flat is better because then you don't have to keep the file system layout in sync manually and open-by-symbol plus the class browser obviate the need for stringent organisation, presenting a hierarchical relationship without the need to get either the disk or the workspace into agreement.
You first have to make the difference between folders and groups. Folders are used to organize contents on your filesystem whereas groups are used to organize contents within your Xcode project. You can think of groups as virtual folders. I personally prefer to keep a flat structure on the filesystem and organize everything using groups. This way is slightly more straight forward to include header files and it doesn't force you to maintain both the filesystem structure and the xcode structure.
In you Project you ca do any GROUPS you want to make simple and clean your project, like my screen:
Is easy and simple and you have two ways:
1) in your project right click in to right column then select NewGroup
2) drag and drop your folder in to a column to create a folder reference:
this only if you want integrate in your project a root with inside files PHP, HTML, ASP and more, but attention because after you distribute your app, if a people open .app file they found inside your REFERENCE FOLDER with all your clear code.
I think this is it ;)
Folders makes your code and its management easily, like we have packages in Java that we use to accumulate some common classes and its supporting class files.
In the same way we can use folders to manage our classes in XCode.
However its not necessary, varies from developer to developer as well as the complexity of code.
Happy Coding. :)
The approach you are discussing about is correct.
As far as folder in code is considered. If you create folder within Xcode and dividing the codes based on folders. Than all the classes will exist together on hard disk. But if you create folders within the project using finder and than adding the folder than codes will be saved to their respective folders.
Hope it will help you. Happy coding :)
I was just working with a sample project that uses Tesseract OCR library. I followed compiling and building the library as it was mentioned in the link. There the author mentioned precisely to add files one by creating groups and other by creating references. At times we need to carefully check these values or else you will fail to compile. What is actually going on? I just want to know the reasons behind choosing each particular option?
Thanks in advance
If you choose Create groups the files will actually be located in one folder, but in Xcode they will appear grouped the way you had them in the folders.
If you choose Create folder Xcode will create folders in your project directory and the structure will be like the structure of the imported folder/folders.
I now see Ant has both an <include> task and an <import> task.
According to the descriptions:
Include
Include another build file into the current project.
and
Import
Imports another build file into the current project.
So, why use one over the other?
Here's my actual problem:
In our current build system, we are concatenating a bunch of JavaScripts and then minimizing them. The JavaScripts are located in a dozen different directories, and we are taking batches from each directory and concatenating them into five or six super minimized JavaScripts. Some of these files are copied into multiple super JavaScripts.
In order to make debugging easier, and the build a bit more flexible, I want to copy all of the files into the target/work/resources2 directory with each sub-directory under there representing a different super minimized JavaScript. For debugging purposes, we'll include the non-minimized super JavaScript and the originals. The build script isn't complex, but the whole section is taking up a lot of lines. I was thinking of putting the <copy> stuff into a separate XML file, so the whole thing looks like this:
<target name="process-resources"
description="Concatenate and minimize the JavaScripts (using Maven lifecycle names for our targets">
<!-- The following include the copying stuff -->
<here.be.dragons file="${basedir}/reservations.xml"/>
<here.be.dragons file="${basedir}/date.xml"/>
<here.be.dragons file="${basedir}/select.xml"/>
<for param="concat.dir">
<fileset dir="${work.dir]/resources2"/>
<sequential>
<here.I.am.concatenating.and.minimizing/>
</sequential>
</for>
</target>
I see there are four possibilities:
Use <ant/> to call the files that do the copying
Use <import/> (which might not work because it might not be able to be included inside a target)
Use <include/> (which might not work because it might not be able to be included inside a target)
Use the Entity Include.
I am never crazy about using <ant/> or <antcall> although this might be a good time to do this. The Entity Include idea will work, but that's something most people don't understand, and I am afraid it will cause confusion for people who have to support what I'm doing. The <import> and <include> may not be able to be used in this situation, but I'm still curious what the differences are.
The documentation of import explains the difference:
How is import different from include?
The short version: Use import if you intend to override a target, otherwise use include.
When using import the imported targets are available by up to two names. Their "normal" name without any prefix and potentially with a prefixed name (the value of the as attribute or the imported project's name attribute, if any).
When using include the included targets are only available in the prefixed form.
When using import, the imported target's depends attribute remains unchanged, i.e. it uses "normal" names and allows you to override targets in the dependency list.
When using include, the included targets cannot be overridden and their depends attributes are rewritten so that prefixed names are used. This allows writers of the included file to control which target is invoked as part of the dependencies.
It is possible to include the same file more than once by using different prefixes, it is not possible to import the same file more than once.
I have a large project tree and I decided to set up my tests in a different way. Setting up a new test project is easy but to copy hundreds of files from tens of directories is quite a problem. Is there an easy way to copy all these files from another project tree?
I would not duplicate the files that should be used without change in both test projects, but use separate (sub)folders for the test projects specific files and refer to the common units with a relative path.
Something like:
...\MyProject\Test1 and using '..\MyCommonUnit.pas'
...\MyProject\Test2 and using '..\MyCommonUnit.pas'
You do that for the first Test1 project, then merely saving it in another folder with the 'Save Project As' will duplicate the test only files and you can start directly modifying code in the new Test project...