Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TARGET_BUILD_DIR for actool output #11762

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akkyie
Copy link

@akkyie akkyie commented Feb 10, 2023

馃寛

This PR changes the copy-resource script to use $TARGET_BUILD_DIR for the output location instead of $BUILT_PRODUCTS_DIR for actool. This aligns with the way other tools such as ibtool and momc operate.

Background

I am using a unique setup with CocoaPods for my app where I call xcodebuild directly on CocoaPods-generated Pods.xcodeproj to prebuild Pods, by overriding some build settings such as SYMROOT. The prebuilt pods are then integrated by adding build phases manually to the app target to run Pods-<target>-frameworks.sh and ...-resources.sh, with an overridden $BUILT_PRODUCTS_DIR that points to the directory containing prebuilt pods.

This setup has been working well with any pod, including ones containing XCFrameworks or resource bundles. However, I encountered a problem when I tried to add a pod that contains xcassets. The copy-frameworks script tries to run actool to write the assets into the app binary, but it fails because ${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH} points to the prebuild directory instead of the app's build directory in my custom setup.

Other tools in the copy-resources script use ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH} for their output (some excerpted below), and in the script it's mkdir -p-ing only ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}. Based on these observations, I believe it is safe to change actool to match with other tools. Also, with the standard setup, $TARGET_BUILD_DIR basically points the same path as $BUILT_PRODUCTS_DIR AFAIK.

Please let me know if any of my assumptions are incorrect. Thank you!

*\.storyboard)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \\"$RESOURCE_PATH\\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \\"$RESOURCE_PATH\\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;

*.xcdatamodel)
echo "xcrun momc \\"$RESOURCE_PATH\\" \\"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\\"" || true
xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
;;

Edited: Tested locally by running bundle exec rake spec:integration with the updated spec CocoaPods/cocoapods-integration-specs#339.

@akkyie akkyie force-pushed the use-target-build-dir-for-actool branch from 08ec375 to 576a4f5 Compare February 28, 2023 03:52
@akkyie
Copy link
Author

akkyie commented Feb 28, 2023

Rebased onto the latest master as it was failing due to Alamofire deprecation.
Also updated CHANGELOG (though I'm not sure if it's an enhancement) and the associated cocoapods-integration-specs PR. I'll update this PR again when the spec change get merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant