I am having a single project file. Then I created another target for a "Lite" version. I changed the bundle ID and product name for each target and am able to continue working this way.
But when I added a new custom class to the project, I try to use the class in existing VC by #import "NewClass.h" but it only works on one target, on the Lite target, it says:
File not found
Why is this and how to solve it?
While adding any new file and if you are working on multiple targets and you want that file in both the targets then you need to check both the targets while adding file
Check screenshot
You need to add the file to both the Target, so it can be accessed.
Click on the file you have added and then go to the Utilities Area in the right and click on File Inspector. You will have section called 'Target Membership', please select the target from the list of Targets.
Alternatively approach :
Select the Target in which you are getting error then got to Build Phases -> Compile Sources and make sure the file is present there.
If you forgot to add a target when you creating a file, you can add later by selecting the file in project navigator and then check/uncheck the target(s) in the File Inspector (on the right)
I'm following this steps and works perfect, but i need something additional.
Each time when i do any change, is necessary remove the .framework file from parent project and go to framework project and generate a build again and drag and drop into the parent project AGAIN.
It's possible make a reference in where only need run the framework project to see the changes in the parent project without need follow all this steps?
Build your framework in your framework project , right click on the .framework file in build folder , show in finder , drag it to your parent project , in the window that opens uncheck the "copy items ... " option.
This will create a reference to your framework build file and not a copy.
How do I copy one of the sample projects from developer.apple.com and use it as a starting point for my own app?
I have searched on-line, but cannot find an explanation of the necessary steps to rename/refactor an existing project.
First, copy the sample project and all files in its directory to a new directory and open the newly created .xcodeproj file in Xcode. Then edit the project file name in the project navigator on the left. Once you save a new name, Xcode will ask you if you want to rename related files and targets that share that name, which you do.
Now you want to edit your scheme, which is just to the right of the build button in the top left. Click on the scheme (which is likely the name of the sample project), and select manage schemes. Delete the scheme that has the old project name, and click Autocreate Schemes Now to create an appropriately named scheme for your project.
If you want to rename classes from the sample project, you can do this by right-clicking the class name in the code editor -> refactor -> rename. This will rename all uses of that class in your project along with it's .h and .m files. You can then remove any unneeded files from the sample project, and add any of your own files to the project.
Have a look at link below and follow the steps :
https://developer.apple.com/library/ios/qa/qa1625/_index.html
I have in XCode a main project that relies on a subproject to work. The subproject is basically a library that also define a database model, and the way to interact with it.
To use the subproject in the main project, I just dropped the subproject xcodeproj file in the main project, did some setup (like specifying header search path), and that's it.
I'm using core data, but if I try to use the .xcdatamodelId files directly, by creating managed object context, it fails : looks like the main project can't find the subproject ressources (except .h and .m files).
The only solution I found so far is to copy the .xcdatamodelId file from the subproject in the main project, and it does the trick. But it's not satisfactory, as I have to maintain two files if my model evolves.
I was struggling with this issue for a while and I want to answer it here as I believe it is important.
In order to add model files from a sub-project into the parent project you simply locate the model files you want to add in Finder. You can then drag them into your project into any folder you see fit. When Xcode displays the "Choose options for adding these files" prompt, deselect the "Copy items into destination group's folder" item and you can select either "Create Groups..." or "Create folder references...". After this process you should see the model files under the compile sources phase in Build Settings.
It is important to note that dragging the model files (in Xcode) from the sub-project into either "Compile Sources" or the parent project will not work to my knowledge so rather do it in Finder.
When I move iphone project directory to a new path.
There are some red texts indicate the missing files from the project source codes.
How to avoid these?
Here is how to locate the missing (red) files using the Xcode 4 interface:
Select the file or files in the left hand Project Navigator (the folder icon)
In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page
In the "Identity and Type" section, there is a grey box labeled "Location".
Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file.
Voila, you are done.
Xcode 7
1.) Right click on the red (missing) file.
2.) Select "Show File Inspector"
3.) Look at the right hand side of the screen under "Identity and Type" between "Location" and "Full Path"
4.) Click on the folder icon to the right of the file name.
5.) Navigate to the file's new location in the pop-up window and select the file.
I encountered this issue when copying my project from one mac to another.
The solution for me:
assuming your files are grouped (in folder)
from xcode open the group in file inspector
The group will probably be missing the absolute path.
press the little icon nearby to pick the folder to associate the group with.
restart xcode to see the changes.
I had the same problem, when I changed the permission on the files/folders to everyone read/write they then appeared in Xcode.
This worked on a Pod project. Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
In Finder, create a duplicate of the project directory just in case all goes squiffy.
In Finder, open the project directory that contains all the files with red references
For all the red files you see in XCode, except the info.plist file (see step 5 below), highlight them in Finder and drag them from Finder to XCode's project navigator. i.e. import them.
In XCode's "Choose options for adding these files" window: a) Select Copy items into Destination's group folder (if needed)
b) Select Create groups for any added folder
c) Select Add to Targets, and press Finish
Highlight and drag the info.plist file from Finder to Project Navigator and repeat step 4 WITHOUT selecting Add to Targets
If you had groups in Project Navigator (e.g. Supporting Files), reorder the files to be in the right places.
Delete the original bad red references in Project Navigator, and Cmd-Shift-K to clean for good measure.
Build and run on a device to remove the bad reference to the .app file
you just have to locate the missing file press in file icon in the identity and type you will find the full path just locate your file where do you move it click the file icon
When you create these files be sure to save in your app directory. Or if you import classes from other project be sure to check the copy option.
I dont know if this is the main reason but when you are importing files to the application, do you mary the "Copy items in to destination group's folder (if needed)" ?
this make sure the file is not only referenced but added to your project folder and ir will move any where you move your project.
Did you move files in to folders directly in your project folder and not in xcode?
This worked on a Pod project.
go into finder and project.
right click on your project .xcworkspace and click show package contents
right click on contents.xcworkspacedata and open with textEdit then make sure file path is correct. If project has been moved this can change
I also did this below but now sure if you need it
Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
If you create an Xcode project, then move the .xcodeproj file or the newly created project folder to a different folder using Finder, subsequent builds may show many missing files which still reference the original folder locations (which no longer exist because you moved them). These missing files can appear as red text or as issues in the Issue Navigator.
This can happen when Xcode is configured to automatically add or remove files to/from source control (under Xcode > Preferences > Source Control). When configured this way, simply creating a project in Xcode causes new project folders and files to be marked for addition to source control. When you later move the project folder or .xcodeproj file these pending adds now point to missing files.
To resolve this issue when Subversion is the source control program, revert the pending adds for the phantom items from your local working copy folder. In my case this requires dropping into a Terminal window, navigating to the parent of the phantom project folder, then reverting the automatic add, e.g.
cd /my-working-copy-folder
svn status --depth infinity
svn status --depth infinity existing-parent-folder/phantom-project-folder/
svn revert --depth infinity existing-parent-folder/phantom-project-folder/
Note that the first svn status command will list both missing files as well as properly added, modified or deleted files which you must take care to avoid reverting. The second status command is "practice" for the final revert command, to ensure you've specified the proper path to revert.
I do not know git but I assume it offers corresponding commands.
It's too simple to do :
Close the project that includes the missed files and open the Xcode, go to "Organizer">"Projects" and remove the project from the list there. Open your project from Finder and that's it.
hope this help.