dyld: Library not loaded: @executable_path/testdylib.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/TSArm
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib: mmap() error 1 at address=0x00178000, size=0x00001000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib
/private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib: mmap() error 1 at address=0x0017B000, size=0x00001000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/TSArm
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib: mmap() error 1 at address=0x00178000, size=0x00001000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib
/private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib: mmap() error 1 at address=0x0017B000, size=0x00001000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/79BEC832-780C-4AFE-9018-04833F140108/TSArm.app/testdylib.dylib
原因:dylib库文件不会在打包时签名,而iPhone6安全机制改变,强制检查动态库签名问题。
可以使用命令查看:
$ codesign -dvvv /xxx/xxxx
解决方案:
A、使用静态库
B、在Build Phase中添加如下签名的脚本
install_name_tool -change testdylib.dylib @loader_path/testdylib.dylib ${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}
echo 'path: ' ${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}
#this is the list of binaries we have to sign for beeing able to run un-jailbroken
LIST_BINARY_EXTENSIONS= "dylib so 0 vis pvr"
export CODESIGN_ALLOCATE=`xcodebuild -find codesign_allocate`
GEN_ENTITLEMENTS= "/Users/zhangjg/src/gen_entitlements.py"
if [ ! -f ${GEN_ENTITLEMENTS} ]; then
echo "error: $GEN_ENTITLEMENTS not found. Codesign won't work."
exit -1
fi
if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
${GEN_ENTITLEMENTS} "com.trustmobi.TSArm" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" ;
codesign -v -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
#if user has set a code_sign_identity different from iPhone Developer we do a real codesign (for deployment on non-jailbroken devices)
if ! [ -z "${CODE_SIGN_IDENTITY}" ] && [ "${CODE_SIGN_IDENTITY}" != "iPhone Developer" ] && [ "${CODE_SIGN_IDENTITY}" != "Don't Code Sign" ]; then
echo Doing a full bundle sign using genuine identity "${CODE_SIGN_IDENTITY}"
for binext in $LIST_BINARY_EXTENSIONS
do
codesign -fvvv -s "${CODE_SIGN_IDENTITY}" -i com.trustmobi.TSArm `find ${CODESIGNING_FOLDER_PATH} -name "*.$binext" -type f` ${CODESIGNING_FOLDER_PATH}
done
echo In case your app crashes with SIG_SIGN check the variable LIST_BINARY_EXTENSIONS in tools/darwin/Support/Codesign.command
fi
fi
echo 'path: ' ${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}
#this is the list of binaries we have to sign for beeing able to run un-jailbroken
LIST_BINARY_EXTENSIONS= "dylib so 0 vis pvr"
export CODESIGN_ALLOCATE=`xcodebuild -find codesign_allocate`
GEN_ENTITLEMENTS= "/Users/zhangjg/src/gen_entitlements.py"
if [ ! -f ${GEN_ENTITLEMENTS} ]; then
echo "error: $GEN_ENTITLEMENTS not found. Codesign won't work."
exit -1
fi
if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
${GEN_ENTITLEMENTS} "com.trustmobi.TSArm" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" ;
codesign -v -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
#if user has set a code_sign_identity different from iPhone Developer we do a real codesign (for deployment on non-jailbroken devices)
if ! [ -z "${CODE_SIGN_IDENTITY}" ] && [ "${CODE_SIGN_IDENTITY}" != "iPhone Developer" ] && [ "${CODE_SIGN_IDENTITY}" != "Don't Code Sign" ]; then
echo Doing a full bundle sign using genuine identity "${CODE_SIGN_IDENTITY}"
for binext in $LIST_BINARY_EXTENSIONS
do
codesign -fvvv -s "${CODE_SIGN_IDENTITY}" -i com.trustmobi.TSArm `find ${CODESIGNING_FOLDER_PATH} -name "*.$binext" -type f` ${CODESIGNING_FOLDER_PATH}
done
echo In case your app crashes with SIG_SIGN check the variable LIST_BINARY_EXTENSIONS in tools/darwin/Support/Codesign.command
fi
fi