Extract Xcode project file from an .ipa or executable file - xcode

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

Related

How do I retrieve the original code from an Xcode Archive file?

I'm a newbie coder would like to get the lines of code that went into making a previous xcarchive file. How do I do this?
The Archive does not contain your iOS App source code as this is mainly the .ipa folder that contains the complied app bundle so for these kind of condition you have to use source version control system like Github.com

Automatically link sources file to an XCode project

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.

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.

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.

Xcode file system

I am using Xcode as part of my build for OS X, but since it is not the only IDE used, files may be added from the file system directly.
As far as I can tell, there are two ways of adding folders:
Folder reference picks up all the changes on the file system but does not register any of the files as sources.
Recursive copy allows for the files to be built but I need to constantly maintain the file structure
I am wondering if there was a way to setup Xcode to build all of the files that are a part of the folder reference or failing that, if there is a quick script to automagically fix file system discrepancies.
I came up with proof-of-concept solution that works, but will require some work to use in production. Basically, I set up a new "External Target", which compiles all source files in a given directory into a static library. Then the static library is linked into the Main Application.
In detail:
Create a directory (lets call it 'Code') inside your project directory and put some source code in it.
Create a Makefile in the Code directory to compile the source into a static library. Mine looks like this.*****
Create an External Target (lets call it 'ExternalCode') and point it to the Code directory where your source and Makefile reside.
Build the ExternalCode and create a reference to the compiled static library (ExternalCode.a) in the Products area of your project. Get Info on the reference and change the Path Type to "Relative to Built Product".
Make sure ExternalCode.a is in the "Link With Binary Libraries" section of your main target.
Add the ExternalCode target as a dependency of your main target
Add the Code directory to your "User Header Search Paths" of your main target.
Now when you drop some source files into 'Code', Xcode should recompile everything. I created a demo project as a proof of concept. To see it work in, copy B.h/m from the 'tmp' directory into the 'Codes' directory.
*Caveats: The Makefile I provided is oversimplified. If you want to use it in a real project, you'll need to spend some time getting all the build flags correct. You'll have to decide whether it's worth it to manually manage the build process instead of letting Xcode handle most of the details for you. And watch out for paths with whitespace in them; Make does not handle them very well.
Xcode's AppleScript dictionary has the nouns and verbs required to do these tasks. Assuming your other IDE's build scripts know what files are added/deleted, you could write very simple AppleScripts to act as the glue. For example a script could take a parameter specifying a file to add to the current open project in Xcode. Another script could take a parameter to remove a file from the current project. Then your other IDE could just call these scripts like any other command line tool in your build script.
I'm not aware of any built-in functionality to accomplish this. If you need it to be automatic, your best option may be to write a Folder Action AppleScript and attach it to your project folder.
In all likelihood it would be a rather difficult (and probably fairly brittle) solution, though.
It's not pretty, and I think it only solves half your problem but... If you recursively copy, then quit xcode. Then you delete the folders, and replace them with simlinks to the original folders, you at least have files that are seen as code, and they are in the same files as the other IDE is looking at... You still will need to manually add and remove files.
I sort of doubt that there's a better way to do this without some form of scripting (like folder actions) because xcode allows you to have multiple targets in one project, so it's not going to know that you want to automatically include all of the files in any particular target. So, you're going to have to manually add each file to the current target each time anyway...
One way to import another file from add/existing file:
and set your customization for new file that added .
see this

Resources