Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake and Code Signing in XCode 8 for iOS projects

Tags:

xcode

ios

cmake

CMake was able to configure automatic code signing for XCode <=7 and iOS projects with a target property setting like

set_target_properties(app PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "PROPER IDENTIFIER")

XCode 8 changed the signing process. It now is required that the option "Automatically manage signing" in the project settings "General tab -> Signing" is checked. If I check this options manually for a cmake generated project, signing works well. But I did not find a way to enable this option from cmake project by default. Can this be done for cmake (>=3.7.0)?

like image 917
Frank Avatar asked Nov 17 '16 20:11

Frank


Video Answer


2 Answers

If you want automatic signing in CMakeLists.txt

SET_XCODE_PROPERTY(MyTarget CODE_SIGN_IDENTITY "iPhone Developer")
SET_XCODE_PROPERTY(MyTarget DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID})

DEVELOPMENT_TEAM_ID - is your TeamID Eg. 2347GVV3KC


If you want manual signing:

SET_XCODE_PROPERTY(MyTarget CODE_SIGN_IDENTITY ${CODESIGNIDENTITY})
SET_XCODE_PROPERTY(MyTarget DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID})
SET_XCODE_PROPERTY(MyTarget PROVISIONING_PROFILE_SPECIFIER ${PROVISIONING_PROFILE_NAME})

CODESIGNIDENTITY - Set to your preferred code sign identity, to see list: /usr/bin/env xcrun security find-identity -v -p codesigning

eg. AAAAAAC9F10573BBBBBBBBBBBF25F7445951F3D8

Or you can just write: "iPhone Distribution" but I'm not sure is it general rule :)

PROVISIONING_PROFILE_NAME - file name without extension eg. My full name: Game_AppStore.mobileprovision so here I write Game_AppStore

Provisioning profile previosly should be added to Xcode cache so it will be available in ~/Library/MobileDevice/Provisioning\ Profiles More info You can simply do it from Xcode by clicking Provisioning Profile: Name and pick Import Profile... then select it. Remember when you invalidate it you need to remove it from cache.


SET_XCODE_PROPERTY is a macro:

# This little macro lets you set any XCode specific property
macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
    set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
endmacro (set_xcode_property)
like image 84
Dawid Avatar answered Oct 17 '22 15:10

Dawid


You can disable "Automatically manage signing" option by setting XCODE_ATTRIBUTE_CODE_SIGN_STYLE to Manual:

set_property (TARGET MyTarget PROPERTY XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID})
set_property (TARGET MyTarget PROPERTY XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODESIGNIDENTITY})
set_property (TARGET MyTarget PROPERTY XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual)
like image 1
Osama Avatar answered Oct 17 '22 15:10

Osama