Automatically link sources file to an XCode project - xcode

Im auto-generating C/C++ source code from another IDE and would like to add/remove the source(s) files automatically to an open XCode project to be compiled.
What I would like to know is if it is possible to "link" to XCode a folder where it can find all the source files to compile?
Or I absolutely need to write and manually run an AppleScript each time?

After more research I found that basically parsing and editing the .xcodeproj package content is the easiest route.

Related

xcode 5 - compiling source without including the files

I am creating a library for Mac using XCode5 which is using some code (c++) that is being developed and maintained by other developer and is at a different path than my library project.
e.g. my project is at /svntrunk/../../mylibraryproject/
The code I want to compile(use) in my library is at
/svntrunk/../../../utils/networkutils/src/source files here
I have tried following approaches
Refer the source files into my project but don't copy them into my project, that way when the other developer updates his code that is automatically reflected since I am pointing to his location. But in this case the linker fails to find the symbols from networkutils code.
Here while adding the file to the project I don't select 'Copy items ..' option
Second approach I took is to select 'Copy items..' option while adding the source files from networkutils to my project. This way the files is copied to my project and the compiler is able to find the symbols. But now if the other developer updates networkutils code I have to manually copy the updated code files which doesn't seem to be right thing to do.
It seems that to move forward I will have to go with option 2. Please let me know if there is a better way to approach this problem.
Thanks
Dev
If he's developing using Xcode as well and has a project, you could link to the project, build that as a lib and include it in the build dependencies in your project.
I do this for Cocos2d.
Failing that, I would pursue option 1 and try to figure out why it's not finding the symbols. Are you sure you have the correct headers included? One reason the compiler fails to find symbols is that you're using functions whose headers are not included.
Extra info here:
https://stackoverflow.com/a/17415609/290072

Extract Xcode project file from an .ipa or executable file

Is there any way to extract an Xcode Project file from an .ipa (executable file)?
I tried the following:
Make a copy of the .ipa file and change .ipa to .zip. Double click on the Payload folder and open project folder. Right-click on that folder and select Show Package Contents.
Everything seems to be okay, but I want to see the code, which is now showing as executable files. Is there any tool or any way to achieve this?
The .ipa file contains, as you have noticed, your compiled project. So no, you can't get the Xcode project file or the source code. (Unless of course, someone deliberately copied those files in).
No, you can't convert a compiled executable back into source code.
An .ipa is an archive of a compiled iOS application, containing the compiled executable plus any resources (images, property lists, etc.). You can't easily translate compiled code back into the human-readable source code that produced it, and you certainly cannot get the Xcode project file that defined the build process for the app. While there are machine code disassemblers out there, they will only give you rough approximations of the original code and can lose valuable information such as the original variable names, comments, etc.
Actually, you can unpack it and see a lot of included files that may be helpful. For me, I needed to see what cordova version and cordova plugin version were in the .ipa file.
After you use XCode to export a previous submission, change the .ipa file to .zip.
Inside "Payload" directory right click on your app name and click Show Package Contents and voila.
To see the cordova version navigate to www/cordova.js, you will see PLATFORM_VERSION_BUILD_LABEL
For plugins, check the very BOTTOM of the file cordova_plugins.js
Thanks to oxdaily.com for the tip about converting to zip file.
Yes Stuart is right we cannot extract the code from its binary so easily the reverse engineering process is very hard to do and even if done it has a lot of complication and the code is not exactly in the same form and more importantly not understandable

Using downloaded sample projects with a missing .xcodeproj

I'm trying to learn Obj-C but when I download sample projects, the .xcodeproj file seems to be missing on all the examples I download. Not quite sure why, but I'm stuck. A few questions (which overlap):
How do I open these projects to run them if the .xcodeproj file is missing?
How do I turn these downloaded examples into projects I can use?
Is there some fundamental reason why it seems to be standard practice NOT to include the .xcodeproj file?
It's not possible to open a project without an .xcodeproj. This directory contains several compulsory infos like :
list of files, resources of the project,
compilation options,
etc.
Where are you getting these samples from? Is it possible that xcodeproj files are hidden on your filesystem? If there really isn't an .xcodeproj file, then it's not too hard to make your own and drag in the source files.
I had the same issue when using git command lines to clone repositories.
However, if you use XCode's integrated source control features to work with existing projects you can open the project and you will find the xcodeproj in your source code directory.
To do this, launch XCode, choose "Connect to repository", specify the location (for example: https://github.com/insurgentgames/Alphabet-Blocks.git), hit 'Clone', then Open Project.

Xcode source code directory

Goodday!
ToDo: compile the files from a directory that is outside of my Xcode project.
How to tell Xcode the path to look for source codes to compile (like the VPATH in a makefile)?
Note1: Right-click the target and it is easy to add the search path for header files or lib, but there I havent found any option to add a new source code directory.
Note2: I havnt found an answer in the xcode build documentation for this issue.
P.S.: I hope that I can do it without copying all the files to the xcode explicitly.
Thank you!
Drag the directory containing the files into your Xcode project. The only way Xcode knows it needs to compile the files is if they are contained in the project and a part of the target.
You indicated that you wanted to use at least some of the source files in a project and intend on using some set of the same source files for other future projects.
Create a new static or dynamic library using the external collection of source files and then just link this project to it and future projects to it
The design of most build environments encourages the use of code in reusable libraries.
Davidli
By the way (for those who are still searching and have problems with this issue), i have Xcode 4.5.2 and when i drag the items they are not linked! It seems that xcode's getting worse with each new version.
In case of xcode 4.5.2 if i copied class files into the separate folder i had to do right click to the group and choose 'add files to ""'

Generate an xcodeproj

I know this might sound a bit strange but I'd need to generate a xcodeproj automatically.
Basically scanning the filesystem and adding certain files to the project and to a specific target.
The main reason behind this, is that I work in an zero IDE environment. Thus, we have our own build system and source files are added and removed all the time.
I could use "create folder references for any added folders". However, xcode won't ever parse source files if they aren't part of any target. So, no symbols, no code completion...
To me, my only option would be to "auto-update" my xcodeproj with a script...
Thanks in advance for your inputs!
Cmake is one option (see this related question) and there's also Scons which I think can generate Xcode projects. There's also Qt's qmake which can generate the project files, but this is probably overkill unless you're using full Qt.
You can either user AppleScript (or anything OSA-compatible) to automate the process of creating the project in Xcode itself, or you could look at CMake, which is able to generate Xcode project files.

Resources