Use CMake to find IOS provisioning profiles
If you use xcodebuild to export your archive - you have to specify the provisioning profile to use. And if you have multiple of those (e.g. on a build server), you might run into trouble selecting the proper one from within CMake. This small and easy code snippet might help you to make this a little bit easier.
macro(cp_ios_get_provisioning_profiles PROFILE_NAME PROVISIONG_PROFILES_DIR RESULT)
file(GLOB FILES ${PROVISIONG_PROFILES_DIR}/*.mobileprovision)
set(LIST "")
foreach(FILE ${FILES})
file(STRINGS "${FILE}" NAME REGEX "${PROFILE_NAME}")
if (NAME)
list(APPEND LIST ${FILE})
endif()
endforeach()
if (LIST)
list(APPEND ${RESULT} ${LIST})
endif()
endmacro()
You can use this macro e.g. like this:
set(IOS_PROVISIONG_PROFILES_DIR "$ENV{HOME}/Library/MobileDevice/Provisioning Profiles/")
set(RESULTS "")
cp_ios_get_provisioning_profiles("The name in your profile" "${IOS_PROVISIONG_PROFILES_DIR}" RESULTS)
if (NOT RESULTS)
message("Could not find matching provisioning profile in ${IOS_PROVISIONG_PROFILES_DIR}")
else()
message(STATUS "Found provisioning profile hash ${RESULTS}")
endif()
macro(cp_ios_get_provisioning_profiles PROFILE_NAME PROVISIONG_PROFILES_DIR RESULT)
file(GLOB FILES ${PROVISIONG_PROFILES_DIR}/*.mobileprovision)
set(LIST "")
foreach(FILE ${FILES})
file(STRINGS "${FILE}" NAME REGEX "${PROFILE_NAME}")
if (NAME)
list(APPEND LIST ${FILE})
endif()
endforeach()
if (LIST)
list(APPEND ${RESULT} ${LIST})
endif()
endmacro()
You can use this macro e.g. like this:
set(IOS_PROVISIONG_PROFILES_DIR "$ENV{HOME}/Library/MobileDevice/Provisioning Profiles/")
set(RESULTS "")
cp_ios_get_provisioning_profiles("The name in your profile" "${IOS_PROVISIONG_PROFILES_DIR}" RESULTS)
if (NOT RESULTS)
message("Could not find matching provisioning profile in ${IOS_PROVISIONG_PROFILES_DIR}")
else()
message(STATUS "Found provisioning profile hash ${RESULTS}")
endif()
Kommentare
Kommentar veröffentlichen