xcode name change causing iphone simulator to crash [duplicate] - xcode

This question already has an answer here:
Build and run Fails after changing Xcode project name
(1 answer)
Closed 9 years ago.
Today I changed my Xcode project and now when I build and run the app it crashes when clicking anything in the app. If anyone could please help out I would really appreciate it, I spent so much time working on this project and had just finished it. I decided to change the name last minute and now I got myself in a pickle.
Thanks for all the help everyone but i guess I'm going to try and re work a new project all over again. :(

You need to reset the Simulator and do a Product - Clean in Xcode.
Renaming the project changes your bundle identifier. It's often recommend as a best practice to not use the default bundle identifier but to just explicitly set it com.apple.mail
After further investigation it looks like the rename is not the issue. You need to set and exception breakpoint to see what is going on.
Now run it with the debugger attached and make it crash.

Answer just for ASL
See the exception being thrown:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: ' -[NSURL initFileURLWithPath:]: nil string parameter'
Set a breakpoint at your initFileURLWithPath method and look at it in the Xcode debugger. I bet you'll catch the path being something you weren't expecting it to be.
Original Answer:
As you've discovered, changing the name of your project can indeed be really tricky and if you don't change it properly, catastrophic things can happen.
Do you have a Time Machine backup of your project? If so, you can easily get back to last night's version of your project before you attempted to do the name change.
Then, changing the name of your app can be as simple as changing the "Bundle display name" in the info.plist file:
This is the lightweight, easy way to do it.
And yes, it doesn't change the underlying project name, but it does change the display name and for your customers, that's all that really matters.
2)
Now, to change the underlying project name, you need to have some time and patience.
I start by typing in the new name for the Xcodeproject file, like this:
Which brings up this sheet:
Then look at your target settings to make sure the old name doesn't exist anymore:
And after all that's done, you might want to change the name of your scheme (via the Xcode scheme editor), since the old name is probably still there as well.

Related

Xcode build products folder won't change to Unique

I don't recall having this problem before I migrated to my Retina MacBook Pro, but since doing so, my projects have insisted on loading in the "old" development location. In years past, before XCode 4, we put all our products in /Development/Products. And, after migrating to the new MacBook Pro, they're going back there again. I can use 4.3 or newer and see the same problem with both, so I'm assuming it's some kind of configurable that's at work here.
Of course, the first thing I did was verify that the Preferences/Locations was set to Build Location = Unique. I confirmed this both in the GUI and by popping open the .plist to check the value of IDEBuildLocationStyle and it was set to Unique.
I tried removing my existing configuration files (everthing in ~/Library/Preferences/ named Xcode) and that succeeded in changing the behavior to putting the output in the build directory of the project itself (really not helpful in my world as I have complex multi-project workspaces). Quitting and checking the settings, they were set for IDEBuildLocationStyle=Unique.
So, I copied the working configuration from another machine I had to this one. Since it too had previously had the /Development/Products destination, but had subsequently been moved to the Unique build style, I expected that to work. It did not. It instead returned the output to /Development/Products.
Thinking it might be something with my Xcode install, I created a new user and built from the same source tree (not a duplicate, not a copy, the exact same files). In this case, the output went to the right place (unique subdirectory of the Derived Products for that user). So, I blew away the ~/Preferences/*Xcode* again and copied in the preferences from the new user. Unfortunately, this took us back to the same behavior that the uninitialized configuration had, which is to say building in the build directory of the project itself.
I restored to my backup configuration files, and now I'm back to working at /Development/Products, but this isn't a good long term solution.
When checking the script output for a test script, I can clearly see that somebody is setting SYMROOT to /Development/Products in the case of the older config, and build in the case of the default configuration file.
Clearly there's something here on this system that's influencing the configuration, but I cannot figure out what it is. Any assistance would be highly appreciated!
Also - When I try to use option-Clean to enable Clean Build Folder, it is never enabled, which makes a certain kind of sense, but I thought it might be another data point.
I tried the solution in Strange behavior of Xcode Build Products Path under Build Locations and that had the same result as deleting the preferences: build products as children of the project directory.
Has anyone else seen such a problem? Have you found a solution?
Well, after a very long time of suffering through this on my laptop, I was finally able to track down the problem.
Inside of:
project.xcworkspace/xcuserdata/<user>.xcuserdatad/
there is a WorkspaceSettings.xcsettings file.
It contained a key BuildLocationStyle, which was set to UseTargetSettings.
Deleting the file and thus resetting this value allowed me to get both the Clean Build Folder... working and to get my project building correctly.
Hopefully this will help somebody else.

Xcode warning of "Unable to read symbols" points to non-existent path under DerivedData

A new Xcode 4.2 project of mine is giving the following warning only when running on the device (as in, not with the Simulator):
warning: Unable to read symbols for /Users/me/Library/Developer/Xcode/DerivedData/MyApp-caubqehwsicqvmfcjxvvwaprgulm/Build/Products/Debug-iphoneos/SomeOtherString.app/MyApp (file not found).
warning: No copy of SomeOtherString.app/MyApp found locally, reading from memory on remote device. This may slow down the debug session.
I do not know where this "SomeOtherString.app" is coming from, but I would like to tell Xcode to stop looking for it. Trouble is, I cannot find where it is being set. I have looked in all the project settings, opened project.pbxproj and looked in there -- nothing.
I finally did a recursive grep for "SomeOtherString" inside my project folder -- the string was not found!
And yes, I have done many "cleans" and have cleared out my DerivedData directory. But Xcode insists that MyApp belongs under "SomeOtherString.app"!
So, my question is: where on earth is this path being stored?
The closest other SO issue I could find was this one, but no one ever posted a solution.
Thanks for any suggestions!
Actually, I found out what was going on here. Even though SomeOtherString was in fact nowhere in my project, I had apparently chosen a bundle ID that was identical to another app whose name was SomeOtherString that Xcode knew about.
I guess this could be an issue if one clones a project -- make sure you use a bundle ID that you have not already used before.

Xcode not predicting

Am new to objective-c and xcode, and i love programming with them. But am facing a problem with xcode this has occurred quite a few times before, i.e the xcode's Auto-Suggestion mode is not working.
By Auto-Suggestion i mean- when i type say two letters 'UI..' xcode predicts the remaining word to be "UIColor, UIButton, .. etc".
Same for the instance methods eg. you type 'init ' and a list is shown as "initWithFrame,
initWithNibName, .." and so on, which makes coding so easy.
But after i performed some operation like undo or delete i don't remember what i did exactly, this auto-prediction is not working and this is happening only on a particular file.
Any idea what i did wrong to make this happen?
Thanks
Xcode sometimes freaks out and exhibits this behavior. Best you can do in this case is clean your project (cmd-shift-K), close Xcode, then re-open it.
I have noticed this behavior especially when using #defined macros extensively.
I know this post is old, but the correct way to resolve this issue is to clear your derived data. After cleaning the derived data and restarting Xcode, your project will say "Indexing" which is the process of setting up everything required to make this feature work. After that, everything should work again.
To clear derived data go to Xcode->Preferences. Then click the little arrow next to the path to the derived data folder. Finder will open with the projects in derived data. Simply select and delete the one specific to your project giving the issue (Don't worry, this will not affect your project).
If there are any compile errors, then also prediction doesn't work properly. try resolving them first.

Deleting Derived Data from Xcode 4.2 project doesn't re-index project

Indexing, code completion, & coloring disappear from my projects on a fairly regular basis, usually right after I add a file. And then it returns hours or days later, usually for unknown reasons (I've tried keeping a record but it's pretty random). CMD-clicking on even known terms (like viewDidLoad: or NSLocalizedString) result in a "Symbol Not Found" error.
It happens with Xcode 4.2 (I believe it happened in Xcode 4.0.2, but not as frequent).
I have no build errors, warnings, or static analysis messages.
I've restarted Xcode.
I've tried turning precompile off.
I don't have a case where I've got a circular header file include/import.
It happens if I use gcc, LLVM, CLang (in whatever combo).
It happens if I use iOS 4.3 or 5.0.
I've tried deleting the "derived data.", and even only the Index/ path.
After deletion & re-build I see the .hmap file & .xcindex folder (filled with db.xcodeindexdb* files).
...but I can't get code-completion, symbol detection, or coloring back.
What else can I do? I sincerely appreciate the help.
Have you tried a clean install (sudo /Developer/Library/uninstall-devtools)?
I have exactly the same problem for one particular project. Following workaround works for me: apart from deleting Derived Data , I make an SVN update or revert any file of the project. If the project file itself is changed my Xcode displays wrong target ,so I close the project and re-open it and then indexing starts properly.
The most reliable way I've found to force re-indexing of the project is to change the build settings, specifically 'Run Static Analyzer' - I wish I had a real answer though.
This might seem like a silly response, but have you tried to repair file permissions under disk maintenance?
Your thread is old, but anyway...
Deleting the derived data folder helps me everytime. I have to do it quite regularly, which is very annoying. Your find the path in the xCode-Settings(cmd+,) in the locations-tab.
I just had this issue. What worked for me is clearing the derived data, then closing the project and re-opening it. It didn't reindex until I closed and re-opened the project. The project never compiled fully, so it didn't even have to finish building to work.

Xcode 4 - created new target, got problems with duplicate interface declarations

I'm new to Xcode, and I'm working on my first project in this environment. I have come across a real head scratcher.
My project is soon ready to be launched. So I wanted to change the product name from a silly work name to the actual name of the soon to be launched product. So I created a new Target with the real name.
When I try to compile the new target I get like 90 errors telling me that I have duplicate interface declaration. All errors occurs in cocos2d framework header files, that I use for my game.
Obviously I missed out on something creating the new target.
My first thought was that there was some kind of conflict with the old target, so I deleted it. Which wasn't the smartest thing since I now can't compare the build settings between the two targets to see what went wrong.
Is there anyone out there who can enlighten a poor sod like myself on whats wrong?
Thank you!
I think what you want is to change how the app is named in the App store and on devices. You configure the app name in iTunes Conect, and to configure how the target appears on a device, go to Target > Info > Bundle Display name and change that to what you want to appear on a device. Build and deploy, and you should see your results in the simulator.

Resources