Deleted XIB files not being replaced - iphone

I'm giving a complete overhaul to an iPhone app. As part of this I'm recreating a lot of the XIBs, by deleting the old one and starting again.
I've noticed that sometimes when I run the app (on either the simulator or a device), it attempts to load the old deleted XIB rather than the new one. This also results in an error "this class is not key value coding-compliant", as you would expect when some of the outlets have changed.
I can fix the problem by cleaning the project, and deleting the app from the simulator/device. Just cleaning the project doesn't seem sufficient. I'm concerned that when I release my app to the world, my users will experience this problem, with the only solution being to delete the app before upgrading.
The alternative would be to create the XIBs with a different name, but this is not ideal. Anyone got any ideas?

Related

Iphone app not showing properly on the device

i have an app which works perfectly on the simulator but on the device in is not as expected.
Animations are misplaced and other bugs. But on the simulator it works fine.
My question is how to fix this bug.
Here is list of things I already tried:
Restart Mac.
Restart Xcode.
Clean Project.
Rename Project.
Delete app from iPhone.
Restart iPhone.
Shut down iPhone.
Clean and build in Xcode.
I really don't know where is the problem.
Thank you for your help.
Would be really appreciated.
Notice: App is correctly signed.
Make sure your files typed correctly and are case sensitive. The Simulator is not case sensitive but the iPhone is.
Did you ever move code/xib files into different groups or directories? Sometimes there is a old copy of the file in the original directory after the move. I've had scenarios in which those old files caused the old code to executed when switching between build settings.
If there are duplicate files, make sure you delete those copies at the old location, or those that you don't intend to be used. For instance, if your original directory as ~/Work/App/Resources and the new directory is ~/Work/App/Resources/xibs then delete the duplicated files from ~/Work/App/Resources
Make sense?
Now, after deletions, if files start to show up as red in XCode, that means XCode cannot find them anymore (maybe you deleted one too many, or who knows the state of your workspace). If this happens, use the "File Inspector" to confirm that the location and path XCode is using for the file is correct.

XCode error "The application bundle does not contain a valid identifier."

Recently, after upgrading to Lion and Xcode 4.2.1 I am getting this error when trying to run my app on my iPhone 4S:
"The application bundle does not contain a valid identifier."
My identifier is indeed valid, and I have been able to run my app with this identifier earlier.
The problem might appear when I change computers.
I have two computers that I am using to code my app, and I am using Dropbox to keep track of my files.
Restarting XCode, my mac and my iPhone does not work.
Cleaning the target and rebuilding does not work.
The only thing I have been able to do to fix it is to create a completely new project and moving my files. This made things work until I swapped computer. Now I am in the same trouble again.
Any idea? Anyone?
Three suggestions:
Check that your developer key is in both computers
Did you try to update the project? There is a strangly-named key in the middle bottom under the project's properties. Try this.
I had similar issues. I found that some things weren't updated when I updated osx and xcode. To get out of the situation, I would suggest creating a new project and copy paste code, files and build settings. This might seem stupid, but you know apple is not good at creating IDE's. You might just get your self lost in the undocumented settings.

XIB actualization problem

I'm facing a weird problem dealing with Xcode. When I run my project using simulator I got the correct xib showing, but when I select my iPhone as target, it shows an older version of that xib... I'm going crazy with this, I have tried to clean targets, deleting and reinstalling the app on iphone, :^S
Please could anybody help me with this issue?
Thanks a lot and sorry for my english.
When Xcode installs development builds of iOS apps on the simulator and on the device, it copies all files from the .app bundle into the target directory for the app in the simulator or on the device. However, it does not remove old files. This can sometimes cause strange effects.
For example:
You have MyView~ipad.xib and MyView.xib for iPhone, you install the app and run it on the device, now you decide to delete the MyView~ipad.xib so that it will just use the MyView.xib same as iPhone, you test this in the simulator and it works fine but when you put it on the device again it still uses the old iPad xib file, but how when it's not even in the project any more? Well the old file still exists in the filesystem on the device until you actually delete the app off the device.
This can happen when you remove files from the project or rename them to something else, the old files will still be there and especially if you have fall-back beaviour or how iOS can look for other suffixes automatically like #2x or ~ipad - this can easily cause confusion. Check for this whenever you notice strange effects like old versions of files seem to resurrect themselves, or it works on one device but not the other.

iphone app upgrade and moved xibs/nibs leads to stale resources

I have an unlocalized shipping app which has foo.xib in the main project directory. In preparation for localization, I moved this to en.lproj/foo.xib. Now, when I build my app and install on my test device, it ends up using the stale old foo.nib which must be there from before (the installation process must not remove old files in the app's bundle). Deleting the app from the test device and re-installing fixes it -- but I don't want my existing customers to have to do that.
Some of these are coming from calls to UIViewController's -initWithNibName:bundle method (to which I'm currently passing nil for the nibBundle). I can probably create an NSBundle instance here which points at the correct localized directory. The others are specified in Info.plist or in the "NIB Name" section in interface builder and I don't see a way to specify a bundle for those.
It might just be easier to rename all my xibs to (e.g.) en.lproj/newfoo.xib, then I presume it will find the correct nib at runtime. (And I'll have to remember to never again use the old "foo.xib" name in a new version.) Is there a more clever solution here though? (Other than going back in time and starting with en.lproj directories from the beginning ;-)
Thanks!
-Mike
Answering my own question in case anyone else runs into this issue. It appears that this is an artifact of the Xcode build-publish cycle, and it isn't a problem when user's upgrade via the App Store. I went ahead and published my update and no one has noticed problems that would result from stale resources.
As a speedup to development, it appears that Xcode only copies over resources that it detects have changed when you build and install to the simulator or a test device. (To prevent a game with 500MB of resources from having to be re-copied each and every time you build and test.) When you (re)move a resource from a project though, it does not detect this and (re)move the old copy. I will file a bug with Apple about it.
However, the App store does appear to do a clean install with each upgrade (copying over the user's documents directory) so this is not a problem from the App Store. I'm not sure if it is a problem when emailing beta testers an .ipa file or not.
I'm having the same issue. The problem is that the phone keeps a cache of the nibs. Somehow thus cache needs to be cleared for you to see the new localized nibs. I also don't want my users to have to delete the app since it stores data.
I just had the same issue but found a solution which works, even with Xcode's deployment quirkiness: Prevent UIViewController loading stale XIB from app bundle

New iPhone app as update to old app, same Bundle identifier, Xcode gives error

I currently have an app in the App Store and on my device, called, for the sake of this post, MyApp1, with bundle identifier com.myname.myapp.
Over the last couple of weeks I have been rewriting the entire app from scratch, also adding lots of new features, as a new Xcode project alongside the old one. As far as iTunes Connect and iOS are concerned though, it should still be an update do the old (version of the) app.
During testing I had both apps running alongside each other on my device and in the simulator, with the new app using bundle identifier com.myname.myapp2, and everything worked fine.
But now that the app's finished, I want it to overwrite/update the old app on my device and in the simulator, to see if the code importing the data from the old app works as expected.
So, I changed the bundle identifier of the new app in its Info.plist to com.myname.myapp, and chose Build and Debug in Xcode. But instead of the new app overwriting the old app while still using the same Documents folder, so it could import the old data, as I expected it to, I got an error.
This is what I'm doing and what happened:
Simulator: Reset cache
Xcode for MyApp1: Clean All Targets
Xcode for MyApp1: Build and Run (using Release configuration)
MyApp1: Change some NSUserDefaults data using the app, changes that should later be imported by MyApp2, which uses a different data model
Xcode for MyApp1: Stop
Xcode for MyApp2: Clean All Targets
Xcode for MyApp2: Build and Run (using Release configuration)
What happens is the following error shows up 3 times, each time for a different classs in MyApp2's Console:
Unknown class [class referenced in the MyApp1 MainWindow.xib file] in Interface Builder file.
So it looks like for some reason not all files are overwritten, as the error is caused by the old version's MainWindow.xib being loaded.
(Relatively uninteresting stack frame: http://cl.ly/1F1w1J1u3t1C2U2o2D2C)
Would anyone happen to know how I can make this work, how I can have an essentially new app overwrite the old one on my device and in the simulator, so it will still use the same Documents folder?
Thanks in advance!
Things I already tried, as suggested by others, but didn't help:
Restarting Xcode
Restarting computer
Deleting build folder from Xcode project folder
Touching MainWindow.xib
Download the old app's Documents folder to your Mac using the Xcode organizer window. Then remove the old app completely, install the new one. Finally restore the Documents folder backup using the Xcode organizer.