I am sort of trying to do the opposite of what others are doing. I have a target called CopyFramework
that creates a CopyFramework.framework
within my main xcproj file.
I set up this target because a specific framework (we can call it Tools.xcframework) is distributed as a binary. That framework file lives within the code.
Tools.xcframework is structured like so
Tools.xcframework (Coding/testBuild/DynamicToolFrameworks/Tools.xcframework)
info.plist
ios-arm64/
Tools.xcframework/
Tools (executable file)
Tools.bundle
Headers/
Info.plist
Modules/
Tools.swiftmodule/
arm64-apple-ios.abi.json
arm64-apple-ios.private.swiftinterface
arm64-apple-ios.swiftdoc
arm64-apple-ios.swiftinterface
module.modulemap
module.private.modulemap
PrivateHeaders/
ios-arm64_x86_64-simulator/
When the CopyFramework target is run xcode does a few steps which copy the correct version of this framework to derived data.
Process Tools.xcframework (iOS)
Coding/testBuild/DynamicToolFrameworks/Tools.xcframework
/Library/Developer/Xcode/DerivedData/testBuild-sha/Build/Products/Debug-iphoneos/Tools.framework ios
cd /Users/calebkierum/Coding/testBuild
builtin-process-xcframework --xcframework Coding/testBuild/DynamicToolFrameworks/Tools.xcframework --platform ios --target-path Library/Developer/Xcode/DerivedData/testBuild-sha/Build/Products/Debug-iphoneos
Meaning essentially that the Tools.xcframework
for the proper platform is taken from Tools.xcframework/ios-arm64
and copied to Library/Developer/Xcode/DerivedData/testBuild-sha/Build/Products/Debug-iphoneos/Tools.xcframework
I am writing a Swift Package that needs to be able to reference the correct Tools.xcframework
. I have set it up like so:
let package = Package(
name: "CoreObjC",
platforms: [.iOS(.v17), .macCatalyst(.v17)],
products: [
.library(name: "CoreObjC", targets: ["CoreObjC"]),
],
dependencies: [
// Does something to here ???
//.package(path: "../testBuild")
],
targets: [
.target(
name: "CoreObjC",
dependencies: [
// Here I would like to be referencing the CopyFramework.framework target within my buildTest.xcproj file
.product(name: "CopyFramework", package: /*??? its not in a swift package its a part of an xcproj file*/)
],
path: "CoreObjC",
publicHeadersPath: "Headers",
linkerSettings: [
.linkedFramework("Tools", .when(platforms: [.iOS])),
.linkedLibrary("c++")
]
),
],
cxxLanguageStandard: CXXLanguageStandard.gnucxx14
)
Now obviously this does not work. I do not know how to communicate to the Package.swift
file that the binary dependency is a framework target within my xcproj file. If I do run the target CopyFramework
followed by building CoreObjC
it works though (so long as you comment out the bits trying to reference CopyFramework). Running the CopyFramework
target processes the Tools.xcframework
and copies the proper xcframework
sub folder to Derived data and the Swift Package build system seems to be able to see it.
Is there a way I can get rid of this manual step? Make it so that when I build the CoreObjC
target (swift package) that either CopyFramework
is run or some other process is run to get the proper xcframework out of Coding/testBuild/DynamicToolFrameworks/Tools.xcframework
and into DerivedData
?
Is it even theoretically possible to have a Swift Package reference a target in a normal xcproj file?