Embedded binary is not signed with the same certificate as the parent app#
Background#
After Xcode 10, the New Build System became the default. After compiling, there was always an error:
Error message: Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's.
For example:
However, there was no problem when using the Legacy Build System. At first, I directly switched back to the Legacy Build System without investigating the specific reason. Recently, I had some free time, so I carefully looked into it.
Process#
I found that many people said it was because the trust status of the certificate in the keychain was incorrect and should be set to the system default instead of being forced to always trust. However, after checking, I found that my certificate was indeed in the system default state.
On Stack Overflow, in the post iOS error "Embedded binary is not signed with the same certificate as the parent app", I found the following:
- The accepted answer was: the Code Sign Identity of the widget target was not set or was set differently from the main app target. However, in my case, I checked and found that it was different. In the error message, there was a difference in the Embedded Binary Signing Certificate: one was "Not Code Signed" and the other was "Software Signing". So, this solution was not applicable to me.
- The second most upvoted answer was: the trust status of the certificate in the keychain was incorrect and should be set to the system default instead of being forced to always trust. I have already verified this, and it is not the correct solution for me.
- The third most upvoted answer suggested switching back to the Legacy Build System... I have been using this method before, but I wanted to solve this problem instead of avoiding it. Additionally, I wanted to see how much faster the compilation time would be with the New Build System.
- Another suggestion was that the deployment target of the widget was higher than that of the main app, but I passed on this solution.
- Another suggestion was to change the "Valid Architectures" in the Watch target's "Build Settings" to "$(ARCHS_STANDARD)". I haven't verified this because I directly used the solution from the next post, but I did use the answer from this post to eliminate some compilation warnings in another blog post.
- Finally, another post suggested in the main app target's Build Phases, under Embed App Extensions, to check "Copy only when installing". Finally, this post provided the correct solution for me.
Result#
When encountering an error, don't panic. First, look at the error message and understand its meaning. When searching for solutions from others, carefully observe if the error message is the same. Try the solutions, and if the results are not suitable, don't be discouraged. Keep looking at the subsequent posts, one by one, and there will always be a suitable solution... Hahaha.