We’ve got a swift package for a cli tool in our repo with our iOS app. It seems like sometimes when we build the tool, it will take ~30 seconds even if no files for the swift package changed. When this happens, there's no console output, so it appears to confirm that it isn't recompiling any of the dependencies or our code. Rebuilding again immediately after takes usually a fraction of a second which is what we would expect when there have been no changes to the package.
Running the build command with -v
shows a bunch of commands (shown below) that seem to be rebuilding each of the dependancies' Package.swift
file.
We've been trying to narrow down when it happens but so far it feels a little random. It frequently seems to happen when switching between git branches with no changes to the swift package, other say it happens if a certain amount of time has past between builds. Any suggestions for what the cause could be or further steps we could try to troubleshoot it?
➜ xcrun -sdk macosx swift build --package-path "./scripts/neo-tools" -c release -v
/usr/bin/xcrun --sdk macosx --show-sdk-platform-path
/usr/bin/xcrun --sdk macosx --find xctest
/Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -print-target-info
/Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -print-target-info
xcrun vtool -show-build /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2/libPackageDescription.dylib
/Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -L /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.15 -swift-version 5 -I /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -sdk /Applications/Xcode-12-4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -package-description-version 5.3.0 /Users/craig/code/work/neo-ios/scripts/neo-tools/Package.swift -o /var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/T/TemporaryDirectory.F3UF3n/neo-tools-manifest
sandbox-exec -p '(version 1)
(deny default)
(import "system.sb")
(allow file-read*)
(allow process*)
' /var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/T/TemporaryDirectory.F3UF3n/neo-tools-manifest -fileno 8
/Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -L /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.15 -swift-version 5 -I /Applications/Xcode-12-4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -sdk /Applications/Xcode-12-4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -package-description-version 5.2.0 /Users/craig/code/work/neo-ios/scripts/neo-tools/.build/checkouts/swift-argument-parser/Package.swift -o /var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/T/TemporaryDirectory.6VFJcz/swift-argument-parser-manifest
sandbox-exec -p '(version 1)
(deny default)
(import "system.sb")
(allow file-read*)
(allow process*)
(allow sysctl*)
(allow file-write*
(regex #"^/private/var/tmp/org\.llvm\.clang.*")
(regex #"^/var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/T/org\.llvm\.clang.*")
(regex #"^/private/var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/T/org\.llvm\.clang.*")
(regex #"^/private/var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/C/org\.llvm\.clang.*")
(subpath "/Users/craig/code/work/neo-ios/scripts/neo-tools/.build")
)
' /var/folders/hf/wtv9mp5d2ysdhz_ndpx3jf7c0000gn/T/TemporaryDirectory.6VFJcz/swift-argument-parser-manifest -fileno 8
... truncated due to post size limit