How to reduce the size of my iPhone application?

前端 未结 7 764
天涯浪人
天涯浪人 2020-11-28 02:49

Alternative Titles (to aid searches)

Compressing PNGs

Reduce the size of an iPhone Archive (.ipa)

Adding a build rule to compress images i

相关标签:
7条回答
  • 2020-11-28 03:35

    @rjstelling has a really nice answer, and I couldn't begin to say it better, but there is one small problem with it. It won't work with localized images. This is only a problem if you embed text in images, which is something I highly recommend never doing if you can avoid it. However, if you have to use localized images, follow all of rjstelling 's steps except instead of using:

    if [ "${BUILD}" == "DISTRIBUTION_BUILD" ]; then
    echo "COMPRESS" >> "${DERIVED_FILES_DIR}/pngout-log.txt"
    "${PROJECT_DIR}/build-process/pngout" -y -q -force "${INPUT_FILE_PATH}" "${DERIVED_FILES_DIR}/${INPUT_FILE_NAME}"
    else
    echo "COPY" >> "${DERIVED_FILES_DIR}/pngout-log.txt"
    cp -f "${INPUT_FILE_PATH}" "${DERIVED_FILES_DIR}/${INPUT_FILE_NAME}"
    fi
    

    use the code below:

    if [ "${BUILD}" == "DISTRIBUTION_BUILD" ]; then
    echo "COMPRESS" >> "${DERIVED_FILES_DIR}/pngout-log.txt"
    "${PROJECT_DIR}/build-process/pngout" -y -q -force "${INPUT_FILE_PATH}" "${DERIVED_FILES_DIR}/${INPUT_FILE_REGION_PATH_COMPONENT}${INPUT_FILE_NAME}"
    else
    echo "COPY" >> "${DERIVED_FILES_DIR}/pngout-log.txt"
    cp -f "${INPUT_FILE_PATH}" "${DERIVED_FILES_DIR}/${INPUT_FILE_REGION_PATH_COMPONENT}${INPUT_FILE_NAME}"
    fi
    

    Note the only change is to the export file path. You have to prepend INPUT_FILE_REGION_PATH_COMPONENT to the export path to get localization of image to work properly. INPUT_FILE_REGION_PATH_COMPONENT is empty normally unless there is localized folder for the specific file. That being the case, it provides the folder name and a trailing slash, so you don't have to.

    You must also change your Output Files setting to ${DERIVED_FILES_DIR}/${INPUT_FILE_REGION_PATH_COMPONENT}${INPUT_FILE_NAME} in order for this to work.

    Not sure if I'm the only one who's ever had that problem, but hopefully it helps someone.

    0 讨论(0)
提交回复
热议问题