Xcode有一个名为" Clean Build Folder ..."的构建选项。 (⌥ ⇧ ⌘ K ),删除构建文件夹中的所有文件。
xcodebuild
有一个名为clean
的构建选项,它与Xcode"" Clean"完全相同。 (⌘ ⇧ K ),留下了一些东西。
有没有办法通过可编写脚本的命令删除build文件夹中的所有文件?
到目前为止我已尝试过:
xcodebuild clean -workspace "My Workspace.xcworkspace" -scheme "My Scheme"
正如我所说,这并没有真正清理一切。为此,我将这个bodge添加到我的构建脚本中:
export IS_XCODE_CACHE_FOLDER_PRESENT="`ls -la ~/Library/Developer/ | grep -x "Xcode"`"
if [ 0 -ne "$IS_XCODE_CACHE_FOLDER_PRESENT" ]; then
echo "Xcode cache folder should not be present at build time! Attempting to delete..."
rm -rf "~/Library/Developer/Xcode"
RM_RESULT=$?
if [ 0 -ne "$RM_RESULT" ]; then
echo "FAILED to remove Xcode cache folder!"
exit $RM_RESULT
fi
fi
答案 0 :(得分:0)
我面临类似的要求。因此,尝试了几个小时后,我决定使用自定义脚本,而不使用Xcode的运行脚本。
因此,不是使用Xcode在模拟器上运行应用程序,而是使用脚本,该脚本依次清理构建文件夹,然后构建项目,然后安装并最终在模拟器中启动应用程序。
以下是我用作快速脚本的内容:
# Delete Build directory
rm -rf ./build/Build
# pod install
pod install
# Build project
xcrun xcodebuild -scheme Example -workspace Example.xcworkspace -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max,OS=13.1' -derivedDataPath build
# Install App
xcrun simctl install "iPhone 11 Pro Max" ./build/Build/Products/Debug-iphonesimulator/Example.app/
# Launch in Simulator
xcrun simctl launch "iPhone 11 Pro Max" com.ihak.arpatech.Example
注意:请参阅this question I posted以了解我面临的问题。
答案 1 :(得分:-1)
您可以添加clean
操作。
xcodebuild clean build -workspace "My Workspace.xcworkspace" -scheme "My Scheme"
在man xcodebuild
中查看更多
action ...
Specify one or more actions to perform. Available actions are:
build Build the target in the build root (SYMROOT). This is the default action, and is used if no action is given.
build-for-testing Build the target and associated tests in the build root (SYMROOT). This will also produce an xctestrun file in the build root. This requires speci-
fying a scheme.
analyze Build and analyze a target or scheme from the build root (SYMROOT). This requires specifying a scheme.
archive Archive a scheme from the build root (SYMROOT). This requires specifying a scheme.
test Test a scheme from the build root (SYMROOT). This requires specifying a scheme and optionally a destination.
test-without-building Test compiled bundles. If a scheme is provided with -scheme then the command finds bundles in the build root (SRCROOT). If an xctestrun file is
provided with -xctestrun then the command finds bundles at paths specified in the xctestrun file.
installsrc Copy the source of the project to the source root (SRCROOT).
install Build the target and install it into the target's installation directory in the distribution root (DSTROOT).
clean Remove build products and intermediate files from the build root (SYMROOT).