XCode add a build rule to run a method on all files of a certain type - objective-c

I'm trying to have xcode run an objective-c project on all of my .idl files before it builds the rest of the project, where the separate project takes the idl file as an arg. Is there an easy way to do this?

Related

ZeroBrane Studios: How to Compile Entire Project?

As title says, how do I compile the entire project?
When I click Project -> Compile (or use corresponding shortcut key) it only compiles the currently open file.
I want to compile the entire project. Compiling each file one at a time is cumbersome, and shouldn't be necessary.
There is AnalyzeAll plugin that compiles/analyzes all files in a project. Note that the compilation doesn't produce any compiled files (like luac does), it simply checks for Lua syntax errors.

CMake generate xcode project with localizations

We've are developing our OSX project using cMake as a tool to create the Xcode project.
However, it turns out we now need some localization, for which we need both English and German .xib files (or .strings to generate them, that's not the important bit).
We have the files in the right place and correctly created, but when cMake generates the project, the files are inserted into the Xcode project as two completely separate and independent files, such as:
Foo.xib
Foo.xib
Instead of two "sub-files" under the same name:
Foo.xib
- Foo.xib (English)
- Foo.xib (German)
If i drag and drop the xib's that are in en.lproj and sv.lproj directly to the resources folder in the project explorer:
Xcode automatically detects that this is some different languages of the same UI, hence the languages are added in the project settings automatically.
Also the xibs get a MainMenu.xib group in the project explorer three, consisting of both the languages.
I try to add the localized xib's to the project through cmake. They get added to the resources folder but not as identified localizations, I only get two xibs in the project explorer three no localization no connection between them.
How can I make the localization work through cmake generation?
set(CEFCLIENT_RESOURCES_MAC_ENGLISH_LPROJ_SRCS_MACOSX
mac/en.lproj/MainMenu.xib
)
set(CEFCLIENT_RESOURCES_MAC_SWEDISH_LPROJ_SRCS_MACOSX
mac/sv.lproj/MainMenu.xib
)
set(CEFCLIENT_RESOURCES_SRCS
${CEFCLIENT_RESOURCES_MAC_SRCS}
${CEFCLIENT_RESOURCES_MAC_ENGLISH_LPROJ_SRCS}
${CEFCLIENT_RESOURCES_MAC_SWEDISH_LPROJ_SRCS}
${CEFCLIENT_RESOURCES_RES_SRCS}
)
Is there a way to generate the Xcode projects through cmake with the .lproj bundles working?
We just did this ourselves. Unfortunately the solution is not pretty. I ended up writing my own python script using mod_pbxproj to modify the xcode project after cmake generated it. If you can get away with using a regular xcode project instead of a cmake generated one, I think you are better off. What you have to do to make XCode recognize a set of files as localizations is pretty complex.
You can find an example of handling xib files for Xcode project here: https://github.com/open-eid/updater/blob/master/CMakeLists.txt.
Summary: one can use custom command + set MACOSX_PACKAGE_LOCATION property on resulting nib:
add_custom_command( OUTPUT MainMenu.nib
COMMAND ibtool --errors --warnings --notices --output-format human-readable-text
--compile MainMenu.nib ${CMAKE_CURRENT_SOURCE_DIR}/mac/en.lproj/MainMenu.xib
)
set_source_files_properties( MainMenu.nib
PROPERTIES MACOSX_PACKAGE_LOCATION Resources/en.lproj )

Export OSX Executable in XCode from Cocoa Application Project

I made a command line tool as a Cocoa Application in XCode and when I archive it, it generates a .app file that contains the underlying executable file. To actually run it, I need to execute that underlying file which is located at AppName.app/Contents/MacOS/AppName. Is there any way I can have it build just the executable? I don't want to have to create a post build step that copies the executable out of the .app file.
Thanks
When you create an Xcode project you choose the project type. Cocoa Application and Command Line Tool are two of the choices. Apparently you created a Cocoa Application but modified the template provided main.m file to execute as a Command Line Tool. However, once a project has been created it cannot be converted to another project type. Xcode will still treat it as the project type you created it as.
You can solve your problem by creating a new project, this time with type Command Line Tool, copy in the same software, and build. The build product will be a UNIX command line program just as you wish.

Can MSBuild ignore a project reference? (BuildProjectReferences doesn't work)

I am trying to make a build script for a .NET solution which consists of several c# projects and one custom project. The custom project can be build by devenv but msbuild chokes on it.
I would like MSBuild to ignore the custom project because I'm already building it with an Exec task. I actually need MSBuild to not even open the custom .proj file because it's in JSON format and thus causes MSBuild to crash out.
The /BuildProjectReferences=false switch doesn't work. MSBuild still tries to read the custom project file. Is there any way around this?
This question stemmed from a project which had a SilverFrost Fortran project alongside several c# class libraries. The solution would only compile using devenv. Msbuild would throw an error on the Fortran project because it doesn't use the standard .csproj format.
Even with /BuildProjectReferences=false, msbuild would try to read the Fortran project and throw an error. The workaround I discovered was to wrap the msbuild task in an nant task which does the following:
Invokes the Fortran command line compiler
Removes all references to the Fortran project from other .csproj projects using the xmlpoke task
Replaces said references with a direct dll reference to the Fortran compiler output
Invokes Msbuild on the modified solution
Instead of building your solution once by MSBuild, try to build each project one by one. In this case, you can ignore the desired project. You can also define your own "Exec"-based build in this new script.
In your project that uses the custom project, can you right click on the Project Dependencies and remove the custom project from the list? You can refer to the custom project's binary output instead.

Cannot find output .a of Cocoa Static Library (in xcode 4)

I have a project with two targets, one is a Cocoa Static Library, the other is the accompanying test project. Despite building the main project in different ways over and over again, I cannot find the .a file that I expect it to produce.
In fact, I cannot find the build folder associated with the project. I need to link to the library in an app, but cannot do so if I can't find the file to link to.
These properties are correctly set:
(Build Products Path) SYMROOT = build
(Intermediate Build Files Path) OBJROOT = $(SYMROOT)
All tests pass (which means the code MUST be building right?)
Breaking the code causes the build to break - again suggesting that it is building.
Also, the "Products > libproject.a" file is red in the xcode project navigation
I also checked the DerivedData directory, but all the seems to get created is the objects fot the OCunit stuff. Still no .a file against which I can link.
Where is my .a file?
Any help would be much appreciated.
It's probably in ~/Library/Developer/Xcode/DerivedData/ somewhere.