What happens if I remove all files from Compile Sources in Build Phases for the project? - iphone

What happens if I remove all files from Compile Sources in Build Phases for the project?
Under Targets -> Build Phses -> Compile Sources -> list of files are present. What happens if no files are present over there?
Thanks

As the warning itself says, the compiler doesn't know how to process some file.
Check for the filename that follows the "no rule to process file" warning, and look for it in the build phases. Then try removing only that file and rebuild the project.
Usually this happens when there's a header file (.h) in the Compile Sources list under Build Phases.

You list objective-c as a tag. Are your files all either .h, .m or .mm? - in addition to any .xib or .nib files?
The group "compile sources" is the set of files that the compiler is expected to compile. Those that are members of a specific target then have the output of their compilation linked together to make that target. The error "no rule to process file" normally indicates that the system can't deduce which language the files are and therefore how to compile them.

added main.m and yourclassess .m file into the compile source after below did
It's very similar:
1.Select the project in the project navigator.
2.Select the Target in the detail view.
3.Select the Build Phase tab.
4.Expand the Compiled Sources section
5.Remove the file you don't want to be compiled anymore

Related

Unable to get xcode project to index appropriate directories

So I had to delete my project and then reclone it from my repository, but when I clone down the project and I open it, other files from some time ago show in there, how is this possible?
Example this is the cloned directory:
But when I open the project, it shows this project structure:
Also it produces the following error when attempting to build the project:
Build input file cannot be found: '/Users/Development/Projects/MapGlider/Application/Utilities/Extensions.swift'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
All help will be appreciated!
The structure of the project as you see it in Xcode is a combination of file system + information about your project in YourProject.xcodeproj/project.pbxproj file. So you have a mismatch between file system and that file, which is typically a result of inaccurate checkin (for example some changes were done directly in file system, and the project was not updated), or a bad merge (developer A did everything right, developer B, or even the same developer on a different branch, overrode those changes incorrectly).
So what you need to do is to fix those errors one by one.
Note: the steps below assume the project is in your control. If you are using some script or tool to generate the project, you will have to address those issues via that tool or script instead.
First, fix the project structure:
Make sure Inspectors on the right side in Xcode are open. Choose File inspector tab
Focus on a folder inside Xcode, and check Name, Location and Full Path of the folder. Especially notice the Full Path, if it's incorrect, change it to a correct one. Here's the example how. Repeat for all folders and files you want to have in the project
Delete all folders and files you don't want to have in the project from Xcode. For example you can delete Extensions which appears as a file in your project, while it's actually a folder. Typically while deleting you should be able to delete them from file system as well if it exists, but if not, you can double check in file system and delete files / folders from there as well.
Add folders and files missing from the project if needed. Follow Add existing files and folders to a project section in the linked page.
Once you cleaned up the project, you need to review / fix all your project targets:
To fix the Project targets
Try to build each target. If it succeeds, most likely everything is resolved (although watch out for runtime errors for resource files - so you may need to test your app to ensure nothing is missing too).
If building a target fails, you will need to see why. For example
if file is missing from the target, but you already added it to the Xcode project, you can add it to the target (see this page).
if file is missing from the target and is not visible in Xcode, go back to step 4 of the previous procedure and add those files to Xcode project, and then add them to the target
if a file is nowhere to find and is not needed, you can delete it from target. If it was needed, then... well, you have a problem and need to locate your missing code in your source repo or rewrite it.

Iphone Linker Error – “class.o for architecture i386" confused?

I am getting error Linker Error – class.o for architecture i386 on xcode project while i try to build the project. on my project i have used some third party framworks as well. any solution for this ??
To break down this issue here are some tips.
1>Make sure to included the QuartzCore framework or other required frameworks in your project. It should be in the Build Phases->Link Binary With Libraries.
3>Check while switching to the new version, you put the new library in a folder next to the old one, in case you had to switch back at some point. Normally when you removed the old version, it did not remove the path to the old version of the .a file from Library Search Paths in the build settings in "Project Name -> Under Targets" and delete the old path and add new one if required.
2>To add new class please select Project Name -> Under Targets select your target project name -> Build Phases -> Expand Compile Sources -> Click + at bottom of Compile sources and add the correct source file.
4>If the above tips are not working for you then be careful while adding files , don’t copy files directly, just create class by clicking on "new files" in Xcode and copy code one by one and add required frameworks. it won't show linker error .
I believe the class is not in your compile sources list.
Select your project on the navigation sidebar -> goto "build phases" -> expand "compile sources" -> add the corrensponding .m file for your class
Please check the class for which you are getting error message is linked to the target you are building.
Also make sure the third party library you are linking into project is properly linked and also linked at runtime of the project.
That is sure that application is able to find the class which you have mentioned at runtime.

Getting XCode to include, compile and link existing (C++) codebase in XCode 4.3(.1)

I'm trying to 'import' my existing C++ codebase into my XCode iOS project.
Problem is, xCode won't compile (and therefore not link) my code.
This is what I've done so far:
File > Add files to "Project". I don't tick 'Copy files' since it's a shared codebase for multiple platforms and multiple copies of source code is not an option.
I've added appropriate path to the "Header Search Path" project settings. Including header files works, I can #include "stuff.h" from my Objective-C++ (.mm) file.
However, I can't find any way of actually telling XCode to compile the .cpp files?
A few points:
I'm not looking for a way to pre compile it into a library and linking that way
The project is a standard iOS Objective-C project. The C++ code is called from it (that's not a problem)
Update
I've added the codebase directory to the target's "Compile Sources". I actually have to click "Add other..." in the dialog that pops up, since I can't select the directory reference to my codebase.
When I add it, XCode asks me if I want to "Create external build system project". I leave it ticked and the two fields with the default values "/usr/bin/make" and "$(ACTION)". However, my codebase doesn't get compiled during the build. Do I have to write my own Makefile ?
If I don't select "Create external build system project" then a directory reference is created under the target, but not compiled during the build and a warning is emitted:
warning: no rule to process file '$(PROJECT_DIR)/../codebase'
of type folder for architecture i386
Even if you don't check Copy Files you have to check Add to Targets when adding the files to the project.
If you forgot to do that, you can select the target, go to the Build Phases tab and add the files to Compile Sources.
If you go to your Targets -> Build Phases -> Compile Sources -> "+" -> "Add Others" -> (select your external source folder) -> Select: Create Group for any added folders -> Unchecked: Copy items into destination.
Now your folder will be in XCode, mimic the structure. If you add source files to that folder in XCode the source files will be added to your external source directory just fine. So the ease of using multiple IDEs and having to manage source linkage is solved.
The catch. You still have to manually add files into the "Compile Sources" area. This is rather simple. Just click and drag your source files from the group directory in XCode right into the Compile Sources window. So there is an extra step when you add a source file now. Forgetting to add them to the Compile Sources window will yield unresolved symbols compile errors.

Build "dependent Project" every time in xcode

I have added a small project as "dependent Project" to my original Project. Xcode 4.2 does not build the dependent project every time for optimization sake. So when ever i change something in the "dependent project" it is not getting reflected as long as I clean the project and build again.
Is there any way to enforce xcode to build "dependent project" every time?. I checked settings but no success.
As long as the files you modify are referenced by a build task (i.e. code file, libs, ...) by your "dependent project", the build should be triggered even when compiling the parent project. However there is a known issue when the modified files are part of a "Copy Bundle Resources" building phase. To avoid this, you can use a small script that only "touch" a code file inside your "dependent project".
See also XCode Project Code Changes Not Updating 100% After Save-Build-Run
or How to have Xcode always copy files (even if they have not been detected as modified) when building?

Three20 HEADER_SEARCH_PATHS strange behaviours

In one of my Three20 project, I have the HEADER_SEARCH_PATHS
HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/../three20 $(BUILT_PRODUCTS_DIR)/../../three20
But according to this: https://github.com/facebook/three20
I have must the following line in the path..
../three20/Build/Products/three20
I have re-created a project using ttmodule.py and confirm ../three20/Build/Products/three20 is the default but I am not sure why my existing project left it out.
Now the issue is:
Q. Why the project can build without error (Simulator/Device), what do you think is the reason?
in pre xcode 4 days the build folder would be under the project source directory which made sense to add a search header in a relative manner.
Three20 copies the header files into a specific place as part of a copy build phase.
Since xcode4 is out the build directory moved completely out of the project source tree into a temporary place configured as $(BUILT_PRODUCTS_DIR).
The reason you see 2 directories is because xcode generates 2 different paths for Archive builds and all the other kinds of builds (Run/Debug etc...)
$(BUILT_PRODUCTS_DIR)/../three20 $(BUILT_PRODUCTS_DIR)/../../three20
Notice that the manual instruction tells you to find that directory but it doesn't tell you where it is:
Finally, we need to tell your project where to find the Three20 headers. Open your "Project Settings" and go to the "Build" tab. Look for "Header Search Paths" and double-click it. Add the relative path from your project's directory to the "three20/Build/Products/three20" directory.