问题
Whenever I try to run the unit tests on device. Everything seems to build and install onto the device but I get the following error in a dialog when it is about to run:
The executable was signed with invalid entitlements. The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016).
Unit testing on simulator works fine. However I would like to get unit tests to work on the device, because it will work a bit faster.
My project has the following warning:
Provisioning profile "match Development com.example.app" for "Example" contains entitlements that aren't in the entitlements file: com.apple.developer.healthkit.access. To use these entitlements, add them to your entitlements file. Otherwise, remove unused entitlements from your provisioning profile.
But everything else works, I can run the target and publish it to appstore. Only unit testing on device fails to start. I looked inside the development provisioning profile and found it contains the com.apple.developer.healthkit.access
key which is not in the appstore provisioning profile. But when I add this key to the entitlements file, it still does not run the unit tests.
I have tried deleting the entitlements file and letting Xcode regenerate it, but that does not work. My project has 5 different app targets each with their own unit testing bundle.
I have also tried regenerating the development provisioning profile, but it always has a com.apple.developer.healthkit.access
key in it.
I looked in the project file as suggested here. All I found was that all the app targets were using the same entitlements file. So I changed it so that all the apps use their own entitlements, but unit testing still fails to start. And the com.apple.developer.healthkit.access
warning stays there
Is there a way I can get unit testing on device to work with healthkit turned on? Unit testing on device without HealthKit will also be an improvement, but then everything else should also work (distribution etc...)
回答1:
For Ionic/Cordova Developers Goto Xcode -> File -> Project Settings -> Build System and select "Legacy Build System" Screenshot
回答2:
Make sure the test target uses automatic signing and make sure it uses the same team as the app target. Also make sure they are using the same certificates.
The com.apple.developer.healthkit.access
warning seems to be unrelated
This answer might be an answer to this question for problems related to unit testing on device.
来源:https://stackoverflow.com/questions/52253833/ios-on-device-unit-testing-fails-to-start-healthkit-entitlements-error