문제

I'm using this tutorial to create a simple Settings Bundle in my app. The thing is that I want to hide the settings entirely in the release version and I cannot find a way to do it. I've read this question but it's still not clear to me.

Thanks in advance

I manage to accomplish this removing the Settings.bundle from target and adding this script to Build Phase:

if [ ${CONFIGURATION} == "Debug" ]; then
cp -r ${PROJECT_DIR}/HotelZilla/Classes/Settings/Settings.bundle ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
fi

But there's still a problem. If I remove the app then launch it in Release Scheme mode, the settings bundle doesn't appear. Then, I change into Debug Scheme and rebuild, the settings appear but, if then I switch again to Release, the settings are still there, so it seems that if I add a Setting to the Release app I can never delete the bundle again. Is that right?

도움이 되었습니까?

해결책

If you're using a settings bundle for your settings, you need to exclude it from the build process for your app in the release configuration. A #ifdef DEBUG macro will only help you for code that you want to exclude from compilation - it won't help excluding a settings bundle.

You need to add a build phase to include/exclude your settings bundle based on the build configuration you're using. Check out How can I conditionally include a file based on build configuration in Xcode? for help with doing this.

다른 팁

This can be done by running a script.

  • Choose Project

  • Choose Target

  • Switch to Build Phases Tab

  • Add Build Phase (+) Button

  • Choose Add Run Script

Add Script:

if [ "${CONFIGURATION}" == "Debug" ]; then
cp -r "${PROJECT_DIR}/${PRODUCT_NAME}/Settings/Settings_Debug.bundle/Root.plist" "${PROJECT_DIR}/${PRODUCT_NAME}/Settings.bundle/Root.plist"
echo "Debug settings bundle copied"
else
cp -r "${PROJECT_DIR}/${PRODUCT_NAME}/Settings/Settings_Release.bundle/Root.plist" "${PROJECT_DIR}/${PRODUCT_NAME}/Settings.bundle/Root.plist"
echo "Release settings bundle copied"
fi

NB: You need to create 3 Settings Bundles (Settings.bundle, Settings_Debug.bundle, Settings_Release.bundle). So you can preserve actual file after taking build.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top