App Crashes Only On Testflight Build - ios

I have created an app on swift and tested it extensively using iPhone 6, iPhone 6 plus and iPhone 5 devices and all the simulators offered in Xcode. The app runs fine and does not crash when uploaded locally. (iOS 8)
I finally submitted a build for Testflight. The app consistently crashes at the same place after downloading the app through the Testflight build.
Is there a known issue where uploaded builds run differently than locally created builds? And how can I debug the issue with the Testflight build?

I guess its a swift compiler issue. To verify first go to Edit Scheme then change the Build configuration to Release mode in Run tab and then install the build locally. You will get to know where exactly its crashing.

I solved the issue by changing the swift compiler optimization from fastest to none. I'm not sure if this is an ideal long term solution, but the build no longer crashes.

In my case this happened after starting to use Xcode 11. It was a UISearchDisplayController (deprecated since iOS 8) that seems to work on a device or simulator in debug mode, but not in the release build. Xcode 11.3 doesn't give any inline warning in the code.
The crash was hard to find, because the search controller wasn't used any more, it was orphaned code.

It might be the Bitcode related issue. Check if your all third-party libraries support bitcode then and then only set bitcode to YES else set to NO.
Actually Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store.

For all those who face this similar issue, can follow these steps
Go to Xcode->widows->organiser then select crashes tab then select your app.
If you have added your apple account in Xcode->preferences-> accounts then you Xcode will download all crash reports even for the testflight build.
It will have the stack trace you don't need to symbloicate it like old times.
PS:- the most common which I have seen is UISearchDisplayController issue

For anyone still having this issue working with React Native, you can run this command to run it in release mode, the same when you archive a build. That way you can debug the issue easier:
react-native run-ios --configuration Release

In my case, changing Legacy Build System to New Build System (for Xcode 10) solves my issue where Testflight build behaves differently. Might be helpful to someone.

I got it (partially!). Actually "release" implementation of UI_USER_INTERFACE_IDIOM() in swift project crashes the app.
However, still I have no clue why our app store app (objective c language based) does NOT crash.
My only guess is that it's a glitch in UI_USER_INTERFACE_IDIOM() API implementation with some language specific coding (swift vs objective c) by Apple.
Anyways, I would replace all UI_USER_INTERFACE_IDIOM() with UIDevice(). userInterfaceIdiom. I hope this helps someone!

If anyone else is having the same problem, here's what my fix was:
I finally got the problem down to a loop with a if statement, akin to this -
while(condition)
{
if (check)
{
code!
}
//There was no code here
}
Notice that there's no code at the end of the loop (where the comment is). Once I added a random bit of code (in this case, incrementing a variable for output), the problem stopped.
while(condition)
{
if (check)
{
code!
}
i += 1;
output statement
}
I think this has to be a compiler error, or else my "fix" shouldn't be a fix at all. But here it is in case it helps anyone else!

Instead of i += 1; in the empty while loops.
I did this in my empty while Loop: RunLoop.current.run(until: Date(timeIntervalSinceNow: 1))
And now the TestFlight App does not bomb!
A shorter time might also work such as: RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.25))

Release build actually takes a different entitlement file than debug build entitlement while debugging in local.
While uploading an archive build it will take release build settings and release entitlement file by default. Make sure you have all the release settings correctly edited in the configurations.

Related

Xcode 9 App installation failed, Could not write to the device

I've just updated to Xcode 9 and am getting App installation failed Could not write to the device error popup every other time. I see there are older questions on the subject, but this one is particular to iOS 11 and Xcode 9. I've never had the issue before.
How do I make sure Xcode 9 can install app to device every time?
In my case this issue was caused by using App Store distribution certificate while iPad was connected wirelessly.
Switching to development certificate fixed the issue.
Xcode 9 seems to have many different manifestations of this problem. Some of the other answers address specific problems, but this definitely occurs when there is nothing wrong with your project. These steps always resolve for me (in order from least painful to most painful):
Try running it again. Sometimes it works on the 3rd or 4th time.
Unplug the device and plug it in again.
Restart Xcode.
Clean build folder (not a regular clean - this is cmd+option+shift+K or hold option in the product menu) and then rebuild.
If all else fails, once a full restart fixed it for me. But probable something else was the root cause.
Hopefully Xcode fixes these problems soon...but I'm not hopeful.
In my case, I want to testing watchOS app and I set the debug provisioning profile to release one. I set to automatic and the issue is gone.
The solution that works for Could not write to the device is clicking the run button again after dismissing this error message.
In some cases I get the error App installation failed: unknown error. In this case I need to do a clean before building.
Deleting the app from device also helps.
I had similar issue and got is solved using below steps :
Delete app from device
Disconnect device from system
Restart iPhone device and Xcode
Delete derived data content
Clean your project (Shortcut key : cmd + shift + k)
Rebuild your project
I am facing same issues on my iPad. It was working fine before. But after some time my development version stop working on iPad. I have tried and search on internet but not able to find solutions. I have tried all above cases but no Luck.
At last, I have found solutions. Some developer has changed DATE/TIME settings for my Ipad. Please check date/time because my Provisional profile for apps has expired for the manual date set on iPad.
Hope the following steps will be useful for others,
Check your provisioning profile is valid.
choose the debug profile for signing in target.
Open you scheme under product in menu toolbar or using Cmd + < shortcut.
Choose debug mode for Run in your product scheme.
Tadaa! now you can run the app in your device flawlessly.
Happy coding! :)
I tried all the method , they didn`t work for me .
And I fixed the problem by removing the soft link file made by ln -s
In my case, this issue appears when I added a folder as reference in the project which contains a symlink. Removing the symlink fixed the issue.
Mine occurred when I had not signed in using my itunes developer portal credentials to sign into XCode. When I did it and cleared all derived data, it worked out.
Everyone is solving this problem in a different way. Mine was changing executable name, building the app (throwing the "You don't have permission etc." problem) and changing the executable name back to the original value.
I don't know why but it worked.
I actually had to reboot the system on the Mac, this gets me rid of the problem for a good while, but it eventually comes back. None of the other solutions mentioned here worked for me.
In my case the problem appears while I use manual signing and try to debug the app in Release mode. Although the fastlane builds and uploads fine in this mode fine, direct XCode debugging fails with the error "Could not write to the device". Temp switching to automatic signing mode fixed this issue.
What worked for me:
delete the app from iPhone
clean the code in Xcode
quit Xcode
re-open Xcode, connect my iPhone, and run it again
I got this issue App installation failed - Could not write to the device and I solved it by doing the below steps
Uninstall the app from device.
Clean the project.
Run the project.
It worked for me.
Xcode 9. iOS 11 SDK. Watch SDK 4.x.x - OPEN THE WATCH APP on the iPhone after failed. My Watch tab->(scroll down to the bottom)-> Install your app. Hope this helps. Just need permissions from the "Watch" app.
I had the same question that could be solved by deleting other debug App from my iPhone, then it worked.
When I choose the Automatically manage signing, my problem fixed.Hope my answer can help you.
Sometimes the problem arises when you removing some pod file reference. The only way to solve this in also your pod-file
eg:
use_frameworks!
pod 'KYDrawerController'
pod 'GoogleMaps'
pod 'GooglePlaces'
pod 'Alamofire'
pod 'Firebase'
pod 'Firebase/Messaging'
remove the unwanted file in this place. And also reinstall the pod-file again and open your project it surely works for you.

Unity Debug log not showing in iOS build

guys I've been struggling with the following issue for couple of days and hope that somebody could help me.
I want to get my app logs from running iOS device. If I run the app from the Xcode, then I see my logs in debug view as expected.
However, when I download a build from my testflight app I'm not able to access the logs anymore. Google suggest that I use Xcode -> Devices -> Log of a device, but there are only system events log and no messages from my app.
Running Unity 5.5.2.p2, Xcode 8.2.1. with ios 10 and 9 tested.
Would appreciate any help, because this issue is really exhausting.
After a bit more searching I found out that it's not possible, unfortunately. But I've managed to make a solution, hope it helps somebody.
Apple's native NSLog prints all the logs to a console app even after the app was downloaded from TestFlight.
I made a simple iOS plugin wich catches all the debug logs and forwards them to a NSLog. Make sure you call
LogManager.Init()
somewhere on app start.
Hope this will help somebody. The plugin is here
https://drive.google.com/open?id=0B7Yn93mXrM82ODZlbDVTNmo0QlU
Archiving for TestFlight means Build Configuration is release.
SO you won't be able to see the dubug log on testflight build.
Follow this link to make a debuggable TestFlight build.
Or simply add DEBUG=1 on Release section under Preprocessor Macros

Internal API error

Since few days, every time I try to run my app on my iPhone, I get get this error message "There was an internal API error".
I'm getting this error just with one application only on my iPhone. In fact, there's no problem with the same app on simulator or on my iPad. No problem too with other apps on my iPhone...
I've tried many things mentioned in those threads:
"There was an internal API error." while running an app on any iPhone/iPod-touch device
Xcode 4.4 - There was an internal API error
like remove/re-run the app, reboot iPhone/mac, clear cache, check plist, check profiles, check build settings, restore iPhone.
I'm using xCode 7.1.1 and iOS 7.1.2
Can someone point me on what I forget to check please ?
As per my work and research I got a solution. Since I was preparing the build in manual way from product. In that case my appname.app was copying in folder from which I have to create a build, that app was not copied properly and I prepared the build and installed in my device, in that case I got this error.
I again clean the Xcode prepare the build properly and installed it, it works.
When I rename my project and delete the special character "ç", xCode success to run the app on my iPhone. It might be related to xCode 7, before there was no problem for compiling.
I also had this problem. The way I solved it was by removing the special characters from the Product Name (in Build Settings) - I had an 'æ'. Indeed, it looks related to Xcode 7, because it used to work on previous versions of Xcode.

App installation failed: Could not write to the device

In Xcode 6.3, I got this error when trying to run an iOS project written in Swift on a real device.
App installation failed
could not write to the device.
I tried to clean the project and run again, but the same error occurs.
How can I fix this error?
Deleting the app on the device and running the project again works for me.
I did a Clean and installed my app successfully.
Product->Clean(Shift-Cmd-K)
I turned off the device and turned it on again after which I did not get such error.
OK, few things you should consider that could guide us to the problem, please check and post the answers:
is your project using capabilities? are they set correctly (should be all green)
did you try with a different project (something really simple)?
are you able to install apps from the App Store?
did you check the amount of free space left in the device?
if not, another suggestion will be using exception breakpoint, there is someone that posted an explanation how to setup it, do it and post the logs
App installation failed
I hope it helps you
Got this problem twice in one week on complete different devices.
One device had no more storage left, after deleting some apps the project installed perfectly.
The other device was fixed after rebooting the device
If you are using a free developer account you may need to uninstall some other apps you have signed.
For me it was the provisioning profile - I used distribution instead of development
My issue was an embedded framework.
Go to "Build Phases" -> "Embed Frameworks" -> Check "Copy only when installing", and it got rid of the issue for me.
For me the following did not work on iOS 11 beta 10, XCode 9 beta 6:
Restart the device
Deleting the app from the device
No symlinks were in the project
There was plenty of storage available
Deleted Derived Data and voilá, it worked again
in my project this problem happened because there was a folder with symbolic link. I removed that folder and it worked properly.
This error has many potential root causes, as can be seen by the large variety of suggested answers. The best approach to troubleshooting app installation issues like this one is usually to inspect the console of the iOS device itself, as that'll often provide much more specific error messages. In Xcode open the 'Devices and Simulators' window and take a peek at the logs of the device where your app is being installed.
In my case, the "Could not write to the device" error was being caused by this:
Feb 27 10:54:58 iPhone-7-110 installd(MobileSystemServices)[46] : 0x16f92f000 -[MIBundle _validateWithError:]: 38: Failed to load Info.plist from bundle at path /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.ebmR6U/extracted/SampleApp.app/Frameworks/SomeFramework.framework
Which clearly hints at what's actually going on. I had forgotten to set an Info.plist file for my dynamic framework target (used by the app).
I had a symlink in my project to a file outside of the project. When I deleted this symlink the install worked fine.
I was having the same error, i just deleted the project and fixed!
Go to Window -> Project and right click, and remove from projects!
In the case of your device have an app with the same bundle identifier, Xcode will throw this error.
Try to delete potential app with the same bundle identifier.
Check your provision profile, maybe you are using the app store provision profile like me. I had to change the app store provision profile to development, now it's working.
Tried all of the above answers: Deleting the app, clearing storage space, cleaning the project...
What finally worked was bumping the build number in info.plist (General > Build)
For anyone still facing this Issue:
There are so many reasons and this is one of them as it happened to me.
I've faced the same problem and I was connected wirelessly and If you are trying to install the application in wireless connecting mode (connected through same network), this might probably because of poor internet connection. Check your internet connection and try again, it works fine...
Get rid of embedded libraries, dont' just throw it in there make sure it is embedded indeed.
If you use your iPhone for debug, maybe, because your iPhone's storage space is less than your debug App.
Clean your iPhone --- Real machine
Clean your Mac --- Simulator
This looks like another time waster courtesy of Apple's amazingly high class development team. On iOS11 Xcode9 (pick your beta, any one works) this will happen randomly. Appears to be more frequent if you dare to switch apps while compiling. Just build again and stare at xcode - it'll work the second time without fail in my experience.
Apparently this message can also appear if the system clock of device where the app is being installed is too far away from the current time.
I was doing some tests with date formatters by changing my iPhone's system clock and eventually forgot to reset it to the current time. Afterwards it always displayed the same message ("could not write to the device.") whenever I attempted to run the app. Simply resetting the clock in Settings fixed the issue.
Nothing helped me. I followed the below steps,
Clean derived data folder
Quit Xcode and disconnect device
Restart Macbook
Restart Device
Open Xcode
Clean and run the project
Finally I got it working!!
I am facing same issue then solved out follow this step and now its working.
Deleting the app from the device
Try to install another application
Remove derived data in X-code.
Restart X-Code then clean and build the project then run.
It's still not working then
Remove un-used application
Restart the device and check the Available and capacity in settings
Again app run in device
I hope its worked, enjoy it.
My problem was I had initially installed the app using a different set of developer credentials on the device. Deleting the app from the device fixed it.
Maybe it can be due to the following error App installation failed. No code signature found. In my case after a project clean the description of the error switched to "No code signature found".
In my case I created two frameworks but they had the same bundle identifier.
This caused the installation to fail, so double check the frameworks bundle identifiers and make sure that each of them have a unique bundle identifier.
Environment: Xcode 10
sometime this error occurs due to wrong certificate.Please make sure your certificate.
Also this the error shown if your machine running Xcode is low on space.
Once I had to load an App Container for debugging purposes into an iPad, said operation failed because the container was too big (18 GB) for this device (16 GB minus the OS), so that I desisted the task and completly forgot about it, leaving the failed installation in the device. Later, when trying to install a different application this error appeared, once I got rid of the failed app installation, everything got back to normal.
Basically, your Ipad might be low in storage.
One reason this can happen is if your app bundle contains broken symlinks.

Gameplay Crashes From ipa file but runs fine from Xcode?

It is somewhat an awkward situation right now.
When I run my project directly from Xcode to my device it runs perfect without any crashs. But when I create an ipa file of that project and install that ipa into my device by using iTunes, only for the first time when I launch my gameplay screen it crashes, later on when I starts my gameplay it runs fine.
Remember, my gameplay starts after the user navigates 2 initial screens which works pretty fine in either conditions. (i.e running from Xcode or from ipa file).
What I dont understand is that if the problem is in my init method of the gameplay class why it does not crashes when I run it directly from Xcode. Is there any code compression or different mechanism of code compilation when running as an ipa or from Xcode.
Any help would be appreciated.
Thanks
I faced the same scenario, the ipa file was crashing after two initial screens. The crashlog did give the line of crash in the code. Debugging the code did not solve the purpose.
But I solved the issue by checking the Archive settings in the Edit Scheme section.
My Build was in Debug mode and the Archive setting was Release, I changed the Archive's build configuration to Debug and created an ipa and the crash was resolved.
Hope this helps someone save productive time. Thanks.
As adig said, get crashlog from device, then symbolicate it. You will see call stack and the line, that caused crash. All differences between release, debug, ad hoc, etc. build configuration you can setup in your project.

Resources