Mac Xcode 11 Generator bug/problem with CODE_SIGN_IDENTITY default
I hit a problem with the CMake/Xcode Generator using Xcode 11. (I think this problem started in Xcode 10 actually, but now I'm blocked really hard and need to solve this.) I am using CMake 3.16.0rc1.
By default, Xcode is now trying to do "Sign to run locally" for the Code Signing Identity (CODE_SIGN_IDENTITY) property, by default.
For trivial apps with no embedded libraries/frameworks, this seems to get through. However, for my real, more complicated projects, I have bundled libraries/frameworks. But since CMake doesn't really have full support for Xcode signing, the embedded libraries/frameworks are not signed, and the code sign process to local sign the .app fails.
So to workaround this, I would like to tell Xcode to disable code signing entirely.
Unfortunately, the only way to disable this seems to be to set the CODE_SIGN_IDENTITY to "", i.e. make the field completely blank. The following link shows all the steps with pictures, but basically you set the box to "Other" and then submit a completely blank input box. This internally in the Xcode project sets CODE_SIGN_IDENTITY to "".
https://stackoverflow.com/a/54296008
But my problem in CMake is that when I try to set the Xcode property to "", it ignores the setting and defer to Xcode's default value of "Sign to run locally".
# This has no effect
set_property(TARGET ${my_app} PROPERTY XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
So this bug really covers several things:
- CMake does not properly Xcode code signing, including the signing of embedded libraries and plugins. (This should be a single atomic step as part of the normal build when the user hits the Build/Run button. And BundleUtilities is fundamentally not correct for Xcode.)
- set_property needs to distinguish between between 'use default value' and 'set explicitly to "" or empty'
As a short term fix, fixing the latter point would bring some milage.