Compiling non-source files in Xcode - iphone

I've got several file pairs:
mydata.json, mydata.raw
other.json, other.raw
etc...
A custom tool builds these files into data files to be consumed by my app, like so:
mydata.dat, other.dat, etc...
What is the correct way for me to set up Xcode to build these resource files? Either one could change, so I can't just set up a custom build rule for a .raw file, for example. I've thought about using an "external build" project using make, but I don't know how to register the results with Xcode to be copied as a resource.

You should be able to just add a Run Script build phase to your target in Xcode to run the external build tool and copy the resulting files into your app's bundle. Right-click on your target and choose Add > New Build Phase > New Run Script Build Phase.
You can use whatever scripting environment you prefer, just specify its path in the "Shell" field. For a bash script, you'd specify /bin/bash, for example.
You can then use the predefined Xcode environment variables to get the location of the various folders in the built package. Have a look at the Xcode Build Setting Reference for details. For example, the Resources folder in the app bundle is at ${UNLOCALIZED_RESOURCES_FOLDER_PATH}.

Related

How to add predefines to the .cproject file after running a Build Target

I'm trying to import a C project to eclipse (CDT) that is managed by waf. There is a list of predefines generated by waf (when running ./waf configure). That list has to be imported to Project->Properties->C/C++ General/Paths and Symbols/Symbols/GNU C so that the indexer knows about them and does not print errors. That list (when using the GUI) is stored to the .cproject file. I created a Build Target that runs ./waf configure and stores the list to a file named DEFINES.txt. How do I automatically update the list of .cproject with the values of DEFINES.txt after running the Build Target?
I thought about the following solutions and their follow-up problems:
Solution: Writing a plug-in.
Problem: What is the appropriate extension point?
Solution: Writing an external program that calls ./waf configure reads DEFINES.txt and writes the list to .cproject. That program replaces the old Build Target.
Problem: How safe is this? Am I allowed to change the .cproject file by an external program without causing any problems?
Solution: Implementing the .cproject updating algorithm in wscript file.
Problem: This is not a solution for me, because the project is used by others, too, that do not use eclipse as IDE. So the modified wscript will cause errors if the other developers want to build the project.
Does anybody have better ideas or some advice?
Here is how to go about it:
Writing a plug-in: What I recommend you do is write an extension to the LanguageSettingsProvider. The FAQ has some more info, but the summary is that provider does:
This extension point is used to contribute a new Language Settings
Provider. A Language Settings Provider is used to get additions to
compiler options such as include paths (-I) or preprocessor defines
(-D) and others into the project model.
CMake has an option to generate .cproject as part of its configure state, so you could do something similar. See the CMake Wiki for inspiration, but the summary is that you don't store and .cproject/.project in source control and have CMake (or waf in your case) generate the IDE specific files.
You could also just pick up the build settings using the build output parser and ignore the DEFINES.txt altogether. That requires running the build once from within Eclipse for CDT to see all the commands, and requires the commands to be parseable in the build output.

Maintain Xcode Run Script Phase after swift package generate-xcodeproj

I have a Run Script phase in my Xcode project. After I update my dependencies with SPM via swift package update I have to update my project with swift package generate-xcodeproj.
Without using a rubygem, pod spec or other 3rd part tool, how Can I maintain that build phase? Can I add Run Script phase to xcconfig file somehow?
With SwiftPM currently, the xcode project file is generated from a template, and any extensions on it are considered to be ephemeral - the recreation of the xcode project file only looks at what's in Package.swift, and not any existing projects. The result is that any extensions you add in (like a shell script build phase) are always going to be lost when you regenerate the script.
I recommend wrapping the whole project in a Makefile or something equivalent if you need to invoke a shell script or equiv kind of mechanism for your build, rather than extending the generated xcode project.

What ant target does netbeans "Clean & Build" call?

I am trying to automatically copy files after the "dist" directory has been created and populated. The provided ant targets "-post-jar" and "-post-compile" seem to run before the dist directory is created. I can't find the actual build target in the build-impl.xml file. So I was going to attempt to put the command directly in build-impl.xml but can't seem to determine the correct target.
edit: -post-jar does work, however I am still curious what target is called.
The Clean & Build calls the following ant targets:
clean
deps-jar
Edit Ant settings to run build with verbose mode and you get get better insights into what targets are executed and when. build-impl.xml probably includes another build files from NetBeans installation where you can find all the details (some targets are defined through macros and it is not very readable).

BB10 how to generate config.pri file

Is there a script or a tool to generate the config.pri file for a BB10 project? Momentics IDE does it for you automatically whenever a project is refreshed or the directory is changed. Unfortunately, I am deploying and compiling via command line tools (it is an automated script which runs tests).
Without the config.pri file, I can't 'make'. An easy solution would be to track the file on github along with the source code for the project, but since the file has a timestamp on it, it causes many annoying merge conflicts.
Any ideas? I rather not write the script myself to parse through all the directories and accumulate header and source files myself. Since Momentics IDE does it, there must be a script that it calls or uses. Momentics is based off of Eclipse, is there any way to see what commands the IDE is calling?
config.pri is just an additional file included in the project's main .pro file. So if you're able to control .pro file you may not need config.pri at all and this inclusion could be safely removed from .pro file. For example, in earlier BB10 SDK releases config.pri simply didn't exist and has been added later.
.pro file is a main file for generating platform and environment-dependent Makefiles for building project, so I'm not sure if there's some tools allowing to manage it automatically. It could be initially generated by invoking qmake -project but I'm not sure if there are any console tools allowing you to manage it after automatically.
Technically, you should modify this file only if your project structure or build system options changed, all other stuff is done in platform-independent way.

Automatic Build for Non-Java Eclipse Project

I have a project that contains xml files. I also have an Ant build in that project to generate documentation based on the xml files. The Ant build calls a Ruby script for generation.
I would like a way run that Ant build after the modification of any resource in the "{project}/xml" folder. I know that I can right click on the build.xml and Run As->Ant Build, but I want it to be more like the incremental build for Java projects. I have tried creating a builder, importing the Ant build and setting up relevant resources, but when I make a change to the XML file, a build does not start. I have "Build Automatically" checked for the project as well.
This must be possible. What am I missing?
A custom builder will only run when a file is saved that is in a source directory. Make sure the /xml folder is included as a source location in the Project Properties, Java Build Path.