tvOS Difference Between TestFlight Installed App and Direct USB Run App on AppleTV Hardware - ios

I am working to add a TopShelf implementation to my tvOS app. I am also working to create a Collection View implementation that has a similar functionality from within the app. Both work fine in the simulator on my Mac but don't work when deploying to my Apple TV using TestFlight. I tried using the USB-C cable to try to capture some logs or see what is going on when the UIActivityIndicator just spins. I thought it could be related to trying to download too many images or some other networking issue. I started caching the images and again that works well in the simulator but not on the device.
When I plugged into the device and ran the app it worked as it should, even with a higher number of downloads. I later updated the version via TestFlight and was back at the same position. Right now I am in a position where the app works every time with my own view controller and the TopShelf part, but does not work at all if deployed via TestFlight. I can't get any logs to figure out what is going on because when I connect the USB cable and run the app, it starts working.
Has anyone seen similar behavior or know of any way to troubleshoot what is going on?

I was able to determine there were a couple of things going on. The first was that the simulator was setup for a build configuration of debug. I went in to Edit Scheme and changed the Build Configuration for Run to "Release." This allowed me to recreate on the simulator what I was seeing on the device. It also made it a lot easier to debug as I could easily add logs to track down where the code was hanging.
The root of the problem was that I had a while loop doing nothing while I waited for a network block to update a flag. I've used this hack in other situations and have never run into a problem. If I added one NSLog command to the while loop it would flow through fine, but with nothing in the loop it just hung even though the network dispatch was done downloading data.
To fix this, I read up on using
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
which solved my problem (and I'm assuming made my code a lot more reliable too).

Related

How to debug react-native iOS app crashing on startup after a week or so

I started messing around with react-native. I've built a small application and it seems to work fine (package.json). I can work on it in Debug or Release mode, using the simulator or my iPhone 6S device, and all is well.
This app is just for me so I don't pay for the Apple Developer thing, and I just run the app in Release mode on my device, and it...seems to be fine? I can quit xcode and go places and the app works fine.
After a week or so, it's hard to tell, the app stops loading. It'll display the splash screen for a split second and then it's gone back to the home screen.
I setup Rollbar, but it doesn't catch anything. I look in the Privacy -> Analytics area and don't see anything there either.
I'm not really looking for an answer to my exact problem since various SO questions and other places suggest it's probably something weird and specific. My main problem is I don't know even where to look/how to debug this kind of thing. If I build the app and run it on device again, it'll run fine. I need to try to debug without loading new code, and have no idea how that works on iOS. I've tried poking around at the Debug -> Attach to Process by Name, but the app never gets far enough to do anything with that.
Alternatively, I throw react-native in the garbage and use something that works...
App provisioning with a free developer license (?) is 7 days. See: Why does my free XCode Provisioning Profile only last 7 days?
You can likely verify this by looking at error messages in the console window. Connect your device, and in Xcode go to Window/Devices and Simulators/Open Console, then launch your app.

NSURLSessionDelegate methods not called in TestFlight installs

I am building an app targeting iOS 8.0 that needs to download files that are up to 250Mb. I had a version of the download code roughly working using Alamofire but I recently replaced that with a pure NSURLSession implementation. This new implementation is working as expected in the simulator and on my iPhone 5S running iOS 9.2 (13C75). It works on my phone whether I install through XCode and a physical connection or through TestFlight. I have deleted the app, restarted the phone, and reinstalled and it always completes downloads correctly. One of my colleagues pulled the code and was able to successfully simulate it from XCode.
However, downloads fail on all of my collaborators' devices. They are installing the app through TestFlight and are set up as internal testers. One collaborator also has a iPhone 5S running iOS 9.2 (13C75). The Alamofire-based implementation worked as intended when deployed through TestFlight to those same devices and very little other code has changed.
I have added some remote logging and I can see that on the failing devices, downloads are correctly triggered and the download tasks I create each have a taskIdentifier which I can log. However, none of the NSURLSessionDelegate or NSURLSessionDownloadDelegate methods are called.
What suggestions do you have for troubleshooting?
Is it possible that this could be related to a TestFlight problem? My current next step is to try an alternative to TestFlight. Ultimately, I would like to be able to deploy betas through TestFlight if possible.
I'm using Swift 2.1.1 in XCode 7.2 (7C68).
The problem turned out to be that I had set the NSURLSessionConfiguration discretionary property to true. The docs state the following which sounded good to me:
When transferring large amounts of data, you are encouraged to set the
value of this property to true.
But I failed to appreciate the consequences of the rest of the text:
For example, the system might delay transferring large files until the device is plugged in and connected to the network via Wi-Fi.
The reason that installations through XCode were working was presumably that the phone was either being charged because it was connected to my computer when I started a download or had just been charged.
I initially suspected that the problem came from either TestFlight or something about the state of the phone. Remote logging with Sentry (which I already use for the backend) was very helpful for getting some insights into what was different when my collaborators ran the app. I eventually added in implementations for all the NSURLSessionDownloadDelegate methods to log which ones were called. This led me to see that didReceiveChallenge was the only delegate method being called and I then spent some time thinking that it could be an auth-related problem and troubleshooting in that general area.
Finally, I started noticing that my own install would fail sometimes and one collaborator had a successful download. That made me start thinking about the kind of phone state that could prevent a download. I went back to the NSURLSession configuration that I had and that's when I read about the discretionary property.
In retrospect, carefully checking the configuration would have been a good step to do earlier. Another good thing to do would have been to log the state property of the download tasks that were created.

ios app-on-device debugging events

Newbie here, so apologies if this is stupid question:
Are there any applications or solutions out there that would allow you access to debugging events on an app installed on your iphone? To be clear, this isn't an app I've developed, it's just on my iphone and is used as part of another solution which we are developing. Curious if there's a way to just watch the events on an app to help with debugging process.
Thanks.
If you make an app, and build it with a development release, and development signing, you can select to build+run it on a device. Then, you can use the Xcode debugger to see your logs / errors etc.
Steps:
Plug in iPhone
Start Xcode
Hit Build + run
Watch debugger
Logs are either made by the OS for certain things (NSinconsistency, bad constraints, race conditions in view presentation) or by you with NSLog.
Or did you mean when the app is not tethered to your computer? There are other tools for that - including just plugging the phone back in and downloading the logs off the device.

Debugging - Capture The State Of An iOS App

My app has a bug, which I am unable to replicate when it is run when plugged into the computer.
I see it three times a day and it is quite annoying.
Is there any way to capture the state of the app (when not connected to the computer) and see what's going on? Kind of like what XCode does when you use a breakpoint, but somehow send the data to it (or some order tool that I am unaware of) wirelessly.
UPDATE:
The app does not crash. It's just that certain UITableViewCells don't work as they should at certain times.
Try using Crashlytics its awesome for crashes. You should also use TestFlight which will give you live sessions/logs of your app. These both combined will tell you many things.

Strange "error" trying to connect to my server from iOS devices

I have an app which connects to my server to fetch scores, register users etc - the usual stuff.
If I run it on the simulator, it works fine.
If I run it on the device using xcode it works fine, and continues to work fine even once I disconnect the device from xcode and use the app directly from the phones desktop.
However when I build an .ipa file and use that, the app does not connect to my server - it just timeouts.
Does anyone have an idea about what could be causing a difference between how it works on the phone when it was put there directly via an xcode build + run, and when it is dropped on as an .ipa using organizer/iTunes?
As far as I am concerned they should be exactly the same, so I have no idea about where to even start looking.
I am building with the dev target as iOS3.2, using xcode4.2 and iOS sdk5.0. Have tried it out on a 3GS and iPod Touch 4th gen both with the same result.
If any more info is needed then I can give that, but fundamentally everything works, so I suspect that maybe there is a permissions error or a file I need to include that I'm not aware of. This project was originally designed by someone else and they are no longer around, other projects I have made connected to my server without any issues so I'm really hoping someone can help.
See my last comment above, the error was simply down to release builds attempting to look for an incorrect server address.

Resources