project always running with old code - iphone

I was trying to try out and create a .app file for my application and so I followed a tutorial.
After doing this and running the app again on the simulator it always runs with the old code that I have. Why is this? I tried reverting everything back again, but it just won't.
I tried printing something when the app loads, but the app that runs didn't print anything
UPDATE:
I found a fix which is to revert back my bundle identifier to the old one. Why does this work? What if I want to create a binary again to be distributed in the app store, what should I do from this point?

You probably have two apps with the same bundle identifier on the simulator, and Xcode starts the wrong one.
Try to delete everything from the simulator.
Open the iOS Simulator menu in the main menu and select Reset Content and Settings...

I've had the same problem before and for some reason it just didn't update all the files in the bundle that it deployed to the device/simulator. Just delete the app from the device/simulator and redeploy. When it happened to me it didn't create a second app it just didn't completely update the bundle.

Related

Finished running <App> on iPhone 6.1 Simulator

I'm developing a new application for Iphone, using Xcode (Version 4.6 (4H127)) and the iPhone 6.1 simulator (VersiĆ³n 6.0 (369.2)).
At the beginning everything was great: every time I pressed the "run" button, the application was loaded into the simulator and I was able to test it. But sometimes it is not working: when I press the run button, I only get the message "Finished running on iPhone 6.1 Simulator". The code successfully compiles (only minor warnings).
The main problem is that when I get this message, the only way I can use the simulator again (in this project, the rest of the xcode projects seems to work properly) is by starting a new project and adding every file to it.
I've tried to delete de derived data, restart de simulator, restart de computer, etc. Even I made a snapshot when the simulator was working, but when I go back to the snapshot state, the simulator still don't work.
What can I do? Any idea?
1.Manually launch the iOS Simulator.
2.From the "iOS Simulator" menu, click "Reset content and settings",
3.Close and rebuild your app.
This problem may arise when you have problems with your project's plist's target membership. Select your info plist file from project navigator folder structure's Supporting Files, go to interface builder pane(Utilities Section under View in Top Bar), then look for Target Membership in File Inspector pane, if it is checked, uncheck it. Clean & Build, Hope it helps.
Library > Application Support > iPhone Simulator > 6.1 (or whichever you're using) > Applications > Your Application and delete it.
Rebuild your app and relaunch.
I had the same problem, with the same "failed to attach to process ID 0" (I actually didn't notice that error until I saw that you said you had that error). In one of my projects the 6.0 simulator didn't work, but works in my other projects. Also my 5.1 simulator worked.
What worked for me was based off this other answer for a similar question: https://stackoverflow.com/a/12423912/159758
Go to the Product menu and find the Edit Scheme menu there.
While in Edit Scheme window, select the "Run" option on the left hand side of the screen and then on the right hand side, change the debugger from LLDB to GDB.
Run the project, this worked in the simulator.
Then Go back to the Edit Scheme and set back to LLDB.
I noticed you've tried setting the debugger to GDB and not a debugger, but thought I'd mention what helped me, since you're question helped me get to the bottom of my problem (i.e. seeing the "failed to attach to process ID 0" message).
This problem may arise due to presence of more than one info.plist file.
I also faced a similar problem, and eventually found that while adding some resource file from another project I also added its info.plist file.
Once check your Build phases> Copy Bundle Resources, whether another info.plist file exist there or not. If exists then delete it, clean the project and rebuild it.
Hope it helps.....
I ran into the same issue and somehow was able to fix it and almost immediately it went back to being broken. I can tell what broke it though.
I added a couple of folders (folder references) with files in them to the copy bundle resources section. That broke it. If I recall right, I had removed both of those and was messing around with DeploymentTarget. I might have reset the simulator earlier. Regardless, it started working. So,
there is hope for a fix
this thing is caused by folder resources that need to be copied into the bundle
Updated:
I was able to get it working again. Here is what I did..
- Cleared out the derived data folder
- Shut down the simulator app
- Also cleared the deployment in the simulator folders (Users/XXXXXX/Library/Application Support/iPhone simulator/6.1/Applications)
Since last time adding the folders to the bundle caused it to lock up, I tried it step by step adding one folder to the bundle and trying. Turns out one of my folders was named Resources and it dawned on me that particular name could potentially be colliding with something else the app looks for. So I renamed that folder to Res and tried it. It works now.
So there you have it.. Follow the steps above to get out of the problem.
Avoid copying folders called Resources to your bundle.

new iphone - how to delete app off of Developer Device

really simple question. tried googling
I just got a new iPhone 4S and restored from backup. A development app doesn't show up but now that am deploying app to device, the old one shows up (for example, an old display.png is shown). Is there a way to fully delete this from the iPhone? Similar to just rm -rf in the simulator? If I go into the Organizer, I can see that I can 'delete' the application but it clearly lives on with the wrong default.png (and probably wrong sqlite db). How can I fully remove this?
thx
If you are deleting the app from the device only, then you just delete it like any other app, either as you already know through the organizer, or by long pressing and clicking the 'x' on the icon.
If you have an issue with resources persisting after they have been replaced and you are building directly to the device, you may need to remove transient directories from your disk.
Transient directories for building are located in your home directory:
~/Library/Developer/Xcode/DerivedData.
Remove the transient directory for your application and this will guarantee that all old resources are removed from the new build.
Well, you have tried all the way and other answer describe you how to delete the app from device, *and still if you are getting the same issue*, then i would suggest you to use following alternate way :
1 ) Connect your device to your iTunes
2 ) Click on Apps in your LIBRARY section
3 ) Delete your app by right click
It will surely help you. :)
Press-and-hold on the app icon on the device, then click the X button and select delete.
Then in XCode, navigate to the Product menu and select Clean.
Rebuild the app onto your device, and everything should work just fine (provided you perform the steps in this order). :)
Hope this helps!

Why isn't my iPhone app bundle replacing the old one during an update?

I'm starting with an app that has foo.png as a resource, and the app is installed (either in the simulator or on the device). If I delete foo.png, do a clean build, etc., and install, then it still shows up in the bundle on the simulator or device!
But I know the file isn't in the bundle before copying to the simulator or device (for example:
I can see it's not there in the build folder.
If I delete the app from the simulator or device, and then install, then foo.png doesn't show up on the simulator or device.
So it seems that when updating, it doesn't replace the app bundle; instead, it only copies new files and replaces updated ones. (I can confirm that it does, in fact, copy and replace files properly.)
Why isn't it replacing the entire app bundle?
If you update your application through iTunes using an ad hoc build you will see that your .app bundle will be replaced completely and old resources, such as the foo.png file described in the original post will be removed.
Reset the simulator, go up to the menu and then click reset simulator. I always have that problem with databases on the device. You will have to delete it on the device. Just a quirk that I've experienced as well.

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.

How to force application Settings bundle get updated?

Application Settings.bundle contains a version number, which is automatically generated during build. From build log I can see that new value is written there, also when looking inside the file itself in MacOS X Finder I see correct updated value.
Settings in iPhone simulator or in real iPhone shows me the old value. Removing application and reinstalling is so far the only way I've managed to get the new updated value visible.
Question: how can I force iPhone Settings application to read my new latest updated bundle file?
Some background info, which might or might not be related: I install application only via Xcode into both simulator and iPhone. Is this the problem? Just found this in Apple docs, not sure what it actually says. Seems to contradict itself (last chapter)...
Each time you reinstall your application, iPhone OS performs a clean install, which deletes any previous preferences. In other words, building or running your application from Xcode always installs a new version, replacing any old contents. To test preference changes between successive executions, you must run your application directly from the simulator interface and not from Xcode.
So Xcode always replaces old content, but to test changes I cannot use Xcode? What was that? Done both (after installation via Xcode) and didn't see new values in settings. Any ideas how does it actually work? Do I always have to make non-Xcode installation?
Try cleaning and building. It seems that xcode caches dates and doesn't notice the change that your script is making. I've had similar things happen, clean always fixes it, but it is indeed a nuisance.
Make sure to shut down the Settings app running in the background on device. It looks like Settings caches settings while it's running - but pulls the updated values when the Settings app is re-launched.
In my case, it seems that my modified root.plist, created/edited via the Xcode property list editor, just wasn't being saved.
There was no problem at all with the Settings Bundle being copied over to the iPad. A quick cmd-S followed by a rebuild and go/debug updated Settings on the iPad straight away - no app uninstall/reinstall even needed. You'd think there'd at least be a haven't-saved-it warning from Xcode, as there always is for code source files.
I just tried this and it worked.
In Xcode go to : Window->Organizer,
then view installed apps on the connected iPad/iPhone, remove the app, then recompile and run your app on the device.
I think the issue has something to do with the iPad's cache.