When I use the build button in xcode to run my cordova app on the phone, if the build process take too long I get a "Device locked" error.
Is there a way or any hack I can do to keep my iphone unlocked when it's building? Is there a way to tell xcode to keep my phone unlocked?
The easiest fix for this is to disable sleep mode (for up until ~1hr) for your phone. Then you won't have to worry about it locking.
Open the Settings app.
Tap Display & Brightness.
Tap Auto-Lock.
If this option is grayed out, visit this Lock screen settings tip to
learn what to do. Set the lock feature to a time that works for you.
To fiddle with the phone's auto lock duration whenever you're working, and then changing it back to normal is not ideal for me since I use my primary phone for testing apps too. My workaround was to run a youtube video on silent and let iOS switch it to my testing app whenever the build is ready!
Related
Whenever I re-run my application by selecting the run button in xcode for, it says simulator already in use. So I have to stop it every time before re-running.
So my question is, is there any option or setting to avoid this. I want to run the application without stopping it like we used to do in xcode 3.
The issue is that pressing the Home button, even in the simulator, does not stop your app under iOS 4. You can either stop your app in the debugger, or in the simulator, or you can modify your app such that it doesn't run in the background. See Opting Out of Background Execution.
In Application PLIST file, we have a flag of “Application does not run in background”.
If you set this flag to “YES” and press home button, application will not maintain its status or perform any background tasks.
This is a bug in Xcode 4 which occurs sometimes. Usually you can make it go away by quitting the Simulator and restarting Xcode. If that still doesn't fix the problem, I would report the issue at bugreport.apple.com and see if the engineers at Apple can help.
I was wondering what happens if a user updates an app (through the app store/update) while the app is still in the background on iOS 4.x
I am planning a big update for my next release and I wanted to know if it is a special case I have to handle to avoid a crash.
Or can I trust the OS to restart the application on the next launch (or to kill the background process during the update), detecting that the application has changed instead of just doing a "applicationWillEnterForeground"?
iOS / Apple take care of that use-case for you, you don't need to worry about it. Your app will get terminated, so when the user next taps its icon you will have a relaunch.
Any app in suspended in the iOS "background" can get terminated by the OS at any time. The OS knows to do the "right thing" when the app's icon is tapped on again next. An app update would just be another case of that same thing happening.
I'm trying to get the following functionality in my iPhone app:
When backgrounded, stays running (doesn't have to do any background work)
When resumed, app picks up where it was left off
I'm mainly wanting the same screen on my app still up, as there are several UINavigationControllers within a UITabBarController.
I have done all of the following:
Made sure I'm compiling with 4.1 SDK
Set UIApplicationExitsOnSuspend to false
Handle DidEnterBackground and WillEnterForeground in my AppDelegate
Call BeginBackgroundTask in DidEnterBackground, to attempt to keep my app open
I'm using MonoTouch, but that it probably beside the point. I can take answers in Obj-C, for sure.
I've tested my app on a jailbroken phone with Backgrounder, and I see the "app in background" badge disappear immediately after pushing the home button. I also tried setting UIBackgroundModes in my Info.plist, but to no avail.
Is there anything I'm missing?
Or is this something I would have to implement on my own to resume the previous state of my app? Everywhere I've read talks like it should just work automatically.
If you don't want to be doing work in background, don't call beginBackgroundTask. That call is for situations where you want to do some kind of work in the background. And if you don't finish that work fast enough, iOS will terminate your app.
When I upgraded to iOS 4.x, my MT application started exhibiting this behavior without me having to do anything. iOS should take care of it for you.
I finally got in touch with someone on MonoTouch's irc.
In MonoDevelop there is an option to make a dual iPad/iPhone project, which I used. This is causing my app to behave as if it's running with the 3.2 SDK when deployed to the device.
I think my solution is to install the iOS 4.2 SDK that just came out, since this ads the new multi-tasking feature on iPad.
Not only do you need to support going into the background, you also need to support cases where your app has been terminated. In your app’s initialization code, you should resume the state that it was in. For instance, when you push a view controller, use NSUserDefaults to store a value for the currently-displayed screen, and then when you start read that value and display the associated screen.
Example: My Default.png image shows the start screen of my app with an empty interface. When the app is launched from scratch the first time, this is cool. It appears like it started quickly. But when the user quits it and the app just goes to background, and then the user opens it, this sucks. Then I always end up with a wrong "snapshot" as launch image and my app then looks completely different after launch because it is like it was left the last time.
I would have to disable the Default.png when my app just goes to background, or I would have to enable it when it gets really terminated. Any way to do this?
It sounds to me like your app isn't being suspended. Every app that I've used that supports fast-app switching hasn't shown its default png when I open it after suspending it.
Are you sure your app is supporting fast-app switching and that it is being suspended?
Just updating my answer for some clarity that was revealed in the comments:
In order to take advantage of fast-app switching, the following conditions need to be met:
App needs to be compiled against the 4.0 SDK
App needs to be running on a multitasking-capable device such as:
iPhone 4
iPhone 3GS
iPod touch 3rd Generation
info.plist must not contain the UIApplicationExitsOnSuspend key.
Is there a way to programmatically set the iPad to run the iPhone app at 2x as it is launched (yet keep the iPhone app native). I understand I can create NIB files for each hardware platform, but for ease, I just would rather the app launch as if the user had tapped the 2x on the iPad. Thanks...R.J.
No. The pixel-doubling malarkey is not under your app's control, and is pretty much a crutch for apps that weren't designed for the iPad. If you didn't go nuts with specific pixel measurements in the original code, it shouldn't be difficult to move to the larger screen.
It's not quite program control, but you can get an app to start up in 2x mode on iOS 4.2.
I've had a couple of apps that have always started up in 2x mode, and very nice it was too, but I only worked out why this was today!
Steps:
Run iPhone app (e.g., from Xcode)
Use '1x' and '2x' buttons to select desired zoom level
Press home button to get back to launcher
Double tap home button to bring up task manager
Kill your app (hold finger down until icons start to dance, then press the '-' button on your app's icon)
(If you ran under the debugger in step 1, Xcode will tell you the program got a SIGKILL, and might stop somewhere random in the call stack; you can ignore this.)
Now next time you run the program, it will start up with the zoom level you selected in step 2!
I didn't test absolutely every method of closing the program, but this preference doesn't get saved if you stop it from Xcode (e.g., using Run|Stop menu item), and it doesn't get saved if your program terminates using exit. Closing it using the launcher is the only way I've found so far...