Xcode 4 - renamed/deleted file, yet get 'file not found' error - iphone

I just used Xcode's refactoring tool to rename a core data class from Player to Person. After fixing about 100 errors resulting from using dot notation that Xcode missed in the rename, I got to the last one:
Player.m - Lexical or Preprocessor issue - 'Person.h' not found
Player.m no longer exists in the project, and shows up as deleted (empty icon) in the error. Obviously, since I got rid of it, I don't want it to exist anymore!
To fix this, I have tried re-adding an old copy of Player.h and Player.m, and also cleaning. I have checked the Build Phases->Compile Sources section, and Person.m is there, Player.m is not. Person.h does in fact exist.
Not sure if it matters, but I am using mogenerator to generate my core data classes. Also, this is my third xcdatamodel version. Versions 1 and 2 used Player.h.
Here is a screenshot of the error:

Try clean build, if that doesn't work, restart Xcode, if that doesn't, delete the DerivedData directory, maybe even reboot.
Xcode sometimes gets confused.

You can try to do a super clean (not sure what the real term is) by hitting Cmd+Alt+Shift+K. This performs a clean and removes everything from the build folder.

Well I had a very similar problem and solve it removing the missing compile source of my project settings. to do that follow these steps
Click at the project page. This page contains the general settings
of your app
Select Build phases.
In Build Phases section, select compile sources.
If there is missing some class or file or something that needs to be compiled.
Select water mark file and click the minus sign at the bottom of this section.
Just click and the project may run. I hope this help others.

Related

File name used twice Xcode

Error
I'm trying to use the CoreData functionality but when Xcode creates the two files (xx+CoreDataClass.swift and xx+CoreDataProperties.swift) Xcode gives me this error. The problem is: there's xx+CoreDataClass.swift is in the project's directory and in another directory that it creates when it compiles... so this error persist even if I delete the second one.
What should I do??
This is most often bugs in Xcode where it gets confused about generated files (I literally ran into this exact problem this morning....)
The solution generally is to close Xcode, delete DerivedData, and reopen Xcode.
DerivedData is in ~/Library/Developer/Xcode/DerivedData/. You can remove the whole directory, or just the subdirectory related to your project.
"Delete DerivedData" is an incredibly common solution to Xcode problems, and has been for years. Most of us have some kind of alias to simplify it. This is mine:
alias cdd='cd ~/Library/Developer/Xcode/DerivedData/'
This kind of error generated some times because of your codegen property of Managed Class. You have to change your codegen to Manual/None from attributor.

How to manually add SSZipArchive to my project

First off, I'm a Mac OSX newbie, both using and programming, but it's been thrust upon me. My project is moving along nicely, but I need to unzip a file, and it looks like SSZipArchive seems like the way to go. I want to manually add it to my project, so that it stays all together in my source code control system. Others, esp. the release engineer, shouldn't need to do anything, and we need to have all the source code local.
I've tried a million ways and back, only to keep getting the dreaded "No Such module" error. I've researched for a couple days now, and still no closer. So I'm starting from scratch in a new project to say what I'm doing and to plead for some help here. All this is being done on an El Capitan laptop, using Xcode 7.3.1, with Swift 2.2.
Create a Cocoa Application project, calling it 'ziptest', using Swift, nothing else checked. Build it just for fun.
Drag 'n' Drop the SSZipArchive folder found in the master.zip downloaded from the SSZipArchive GitHub site into my project. I'm not sure where it should go, or if it matters - top level, between ziptest project icon and the ziptest group or inside the ziptest group. But I'll put it inside the ziptest group. Now I'm faced with a new question - for the "Added folders", do I want to "Create groups" or "Create folder references". I do copy the items, because, as I said, I want to add them to SCCS later. I saw somewhere here on Stackexchange to make sure it is Group, so that's what I'll do. Build again and it still works.
I know I need a "bridging header" file, so I'll create it. I thought at some point, Xcode asked if I wanted to create it, but the above step doesn't do that. After much experimention, I found that if I d'n'd the SSZipArchive.m/.h files directly, it asks me. It doesn't put anything into it, but at least it creates it and updates the Build Settings. But I do this now manually by right clicking on the ziptest group folder, select New File... and create an empty Header File called "ziptest-Bridging-Header.h", following the pattern from the Xcode created one, being sure to check off the ziptest Target.
I add:
#import "SSZipArchive.h"
to that file. And building still works.
I added ziptest-Bridging-Header.h as the Objective-C Bridging Header in the Build Settings. And building still works.
Now comes the moment of truth. I add:
#import SSZipArchive
to AppDelegate.swift and I get the dreaded No such module 'SSZipArchive'
What am I doing wrong?
Edited to add: Oh, I also added libz.dylib to the Build Phases -> Link Binary With Libraries part. Doesn't help, of course, because we haven't even gotten to the link phase yet.

iPhone "_OBJC_CLASS_" compilation error

I am trying to compile my project in Xcode. But i am getting the following error.
"_OBJC_CLASS_$_InfrastructureBenchmarkingViewController", referenced from:
objc-class-ref-to-InfrastructureBenchmarkingViewController in RootViewController.o
4 more of similar type.
Can't understand the meaning of this error?
Small Clarification: Actually the _InfrastructureBenchmarkingViewController was a module in another project. The files pertaining to that I have copied into the new application.
Sometimes it happens when the project definition file (.xcodeproj/project.pbxproj) is somehow messed-up, eg. because of XCode crash or project is taken from someone else, etc.
So try removing InfrastructureBenchmarkingViewController (Delete the file, then choose "Delete reference", so it is not deleted physically from disc) and then again add this file to project (Add > Existing file from the project context menu).
It worked for me several times.
you need to link in whatever framework _InfrastructureBenchmarkingViewController is a part of. Try going to the project window, right click on frameworks and choose add existing framework ....
you should be able to find the framework including _InfrastructureBenchmarkingViewController there.
Seems you have some object files that are not valid anymore. Use the clean option from menu and build it again. That should solve it.

iPhone: Failed to launch simulated application: Unknown error

This is a new iPhone project, only 1 target (different from this question)
On build we get:
Failed to launch simulated application: Unknown error.
The google again gives us nothing, lots of people have encountered this and there are lots of crazy ideas to try "oh clean the build", "clear the cache", "twiddle this flag" and none of them work and work consistently. We can reproduce this on two different machines with SDK 2.2.1 and 3.0 beta. Not the install on the machines since other iphone projects work just fine so we believe it has something to do with the config of this particular project but after combing through the config twice we can't spot the problem.
Vanna, I'd like to buy a clue for $200 please.
Tried: XCode menu->Clear cache
Tried: clean all targets
Tried: rm -rf ~/Library/Application\ Support/iPhone\ Simulator
This happened to me once and I think I saw in a blog to simply quit and restart Xcode. Miraculously, it worked for me. I doubt this is the end all solutions to all problems like these though, but if you haven't yet closed Xcode, it's worth a try.
I sometimes see this problem and it is fixed by rebooting the maching. I suspect the internal state of the simulator gets screwed. Doesn't sound like your problem though.
I agree with MiRAGe; if this persists, start a new project and import your source.
If other projects work fine; start a new one and copy the files. Combing through configs just won't do it (since XCode has, well, thousands of config possibilities).
You can send me a check with the $200.
P.S: When you actually do start a new project, do it step by step. Run it after each change. Maybe you will find your problem. It might be a ton of work, but it might also help the other thousands of lost souls who have an 'Unkown Error'.
Changing the product name worked for me. I tried several different alternatives and all of them worked fine. It was the "magic product name" I used at the onset that failed every time I went back to it. YMMV.
This might be because items are missing for the target. Expand the target and verify that all needed source files and libraries are there. Restart Xcode after you've messed around.
alt text http://pici.se/pictures/TsnTQxhKh.png
Thanks ...Did have the same problem or worse. My app wasn't loading in the simulator, alternatively sometimes the build failed. Now realized it's pretty logical.
When you create a new project and info.plist get associated with the project.
Each time you add a modify/add the target another plist is generated with the new name.
But the original association with the info.plist is still around and there's a conflict.
So remove that association from the current target or better still remove from project and trash the info.plist.
Just make sure in the target settings(do getInfo) the correct info.plist is mentioned.
Note the name for product/target should not have spaces. If you really want it change the bundle display name.
Now the only reason why xcode should be closed is to ensure the project file has registered all changes.
I got this problem when I added the .plist to my target (Info.plist -> Get Info -> Targets -> Target Memberships). It went away when I unchecked it again.
I see that that's separate from the Targets -> -> Get Info -> Build -> Packaging -> "Info.plist file" -> my.plist that trips mentioned, but I still don't really understand what's going on, and definitely don't understand why we get such an unhelpful error message.
I've had this twice for the same reason: adding a folder called Resources to the project. This is a naming conflict with something (though there is nothing called "Resources" in the application bundle by default). It might be that mysterious naming conflicts are a common cause of this problem.
To fix I renamed the folder to something else ("Assets"), manually deleted the entire build folder (clean didn't work) and quit the simulator.
Another thing to try if you are desperate is to change the 'Product Name' setting. This worked for me once when everything else didn't.
I had the same problem because I had changed the BundleName and some other values but not changed the PRODUCT_NAME. I had problems finding where PRODUCT_NAME is defined: Get Info on the target, Build-tab and it is down the list somewhere.
I changed PRODUCT_NAME to match the bundle name, restarted Xcode and it worked.
Fred
I had this problem recently and the fix was ridiculously simple. I remembered that I had been editing the target settings and under the "Properties" tab in the "Executable" field there was a space after the value which was ${EXECUTABLE_NAME}. Yes, a single space. It was impossible to see unless you highlight the field. I figured this out because I had edited that field seeing if I could add a command line option that way. I guess when I cut the additional option back out, I missed a space. So while this is the only possible cause of this problem, it's worth checking out.
Had same problem. None of the answers above worked for me. Then i remember i had just added the icon to the Resources folder before the problem started. Moved icon to Other Sources folder and it worked. Weird!
Thanks Guys.
I had the Product name different than in the info plist. A restart once I fixed that made it all go away.
ps, stackoverflow has been a real help to beginners like me. Thanks from downunder.
I add this issue with a folder named "resources". Rename it, clean every thing and run again.
1) Restart Xcode;
2) Use "Get Info" on Info.plist and uncheck current target (Info.plist would be added anyway).
That's all.
I can confirm that a naming conflict was the source of our problem. We had a filesystem folder named resources inside the Xcode group named Resources. Sometimes we would get the error and a system would lock up and sometimes it would not. Changing the folder to the name assets resolved our problem. After reading some of the above comments - it appears that Xcode group names can clash with directory/folder names.
This happened to me when I changed my version number from 1.0 to 0.1. When I changed it back it started working again.

Build Error - missing required architecture i386 in file

I'm getting this error when building my iPhone application:
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library
/Frameworks/UIKit.framework/UIKit, missing required architecture i386 in file
It goes the same for all the frameworks in my app. It's very weird since this was not happening earlier.
This happens when you add a framework to your project and unintentionally copy the framework into your project directory.
The fix is to check your project directory (where you store your project on disk) for any iphone SDK *.Framework files and delete them.
Project will build fine afterwards.
I had this same problem, and the solution turned out to be an easy fix. Backup then open project.pbxproj (located inside your project file bundle) in TextMate or TextEdit and search for the section titled "/* Begin XCBuildConfiguration section */". Look for a key named FRAMEWORK_SEARCH_PATHS and delete it and it's contents (once per build configuration, so I removed it in two places). Here is an example of what I deleted:
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks\"",);
My project now build for both the iPhone device and the iPhoneSimulator.
What has happened here is that Xcode has mysteriously added a "Framework Search Paths" entry that points to a particular iPhone device SDK. For example, mine was recently set to:
$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks
This leads the compiler to find frameworks of the incorrect architecture. Removing any values under the "Framework Search Paths" key in your target's build settings will resolve the issue.
I just wanted to mention that in XCode if you go to "Edit Project Settings"
and find "Search Paths" There is a field for "Framework Search Paths". Updating this should fix the problem, without having to hack the project file!
Cheers!
Jesse
Check that you didn't copy the framework into your project when you added it. If you copied it, it can't find the original paths. To fix this problem. Delete the AVFoundation framework from your frameworks folder in your project, then add it again, but this time, make sure you don't have copy check marked.
This fixed it for me!
I fixed it in a different way.The reason why i was getting this error was that i added security.framework twice in my project.I was not able to see security framework in xcode ,i opened the project in finder and found this framework which i deleted and problem solved.
If your app is meant to run on the device, make sure you are not trying to run in it on the simulator. May sound obvious, but check anyway.
Though it is possible that something got deleted, it has been my experience that something gets screwed up in the project file. I have yet to pin down what that "something" is. I've had similar issues when the SDK installation is just fine. There are a couple of options.
First, add all of your files to a new project. This seems to usually work. Kind of a pain, though.
Second, you can right-click project in XCode/Get Info/Build/Library Search Paths. Add new paths similar to /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib. Add appropriate versions of that string for each version (2.2.1, etc) and platform (simulator or iPhoneOS). Perform a similar action for Framework Search Paths if frameworks are your problem.
Third, which is more work but more reliable, is to open project.pbxproj from within MyProject.xcodeproj (Textmate is good for this). Look for "/* Begin XCBuildConfiguration section */", then "LIBRARY_SEARCH_PATHS" and "FRAMEWORK_SEARCH_PATHS". Add or modify the paths as appropriate, and save the file.
In any case, a pain in the butt, and I'd sure like to pin-point the cause because I've had this happen a couple of times. Project builds fine, then just up and refuses to do so with what seems to be little reason.
"Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". delete all!!
It just happened here to me as well. Thanks to a great partner we found the answer. Your Xcode may be pointing to the simulator ..change it to a IOS device instead ..built smooth after ....
Run the file command on the framework from Terminal:
file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit
You should get back a message telling you which architectures the UIKit binary is compatible with. If you don't see "i386" listed, then you've somehow managed to remove the i386 version of UIKit, which will mean that you can't build for the simulator.To fix that, you'll have to re-install the SDK.
If you get some other error, hopefully it'll help you figure out what the actual problem is.
I just want to let you know that In my case, I was having the same problem, I realized that I had an older Xcode folder called Xcode3.1.3 I just rename it because it was an older version and that did the magic for me.
Check your library search paths in your target settings. Sometimes goofy libraries get entered in there and this will give you a similar error.
You can remove all entries in this section.
I'd just experienced something slightly different, because I work on my own library (WM_GSRecognizerLib), but the error is the same.
What'd happen: due to some updates, the path targeting the lib to include (.a) was from the "Debug-iphoneos" folder (where it is generated). Compiling for Generic iOS Devices worked fine, but not for simulator, complaining for the missing i386 architecture.
What I did for this issue, is to also include the binaries from the "Debug-iphonesimulator" folder.
It can help for this topic, because the explanation is here: devices require binaries for arm64/armv7/armv7s, while simulator does need i386.
My solution was to set on simulator target debug YES, just look on git status to see the new line added as architecture only on .project. if you don't set this the build will run to all architectures and will show some missing architecture like i386 or other.
NOTE THAT obviously the main issue is to use some framework that implements some kind of specific architecture.
I too got the same error am using xcode version 4.0.2 so what i did was selected the xcode project file and from their i selected the Target option their i could see the app of my project so i clicked on it and went to the build settings option.
Their in the search option i typed Framework search path, and deleted all the settings and then clicked the build button and that worked for me just fine,
Thanks and Regards