Hi!
I've been dealing with mergeable libraries quite some time. However I can't achieve the following scenario:
I have 2 xcframeworks A and B that are merged as part of a third xcframework called C. And my app needs to import something from A and B.
As per the documentation we have to remove the references from A and B from the final app and replace it with C. If I work on the same xcodepoj it works like a charm (maybe because of caches), but if I try to compile C as a separate XCFramework and distribute it as a packed library, the app is not able to resolve the symbols to A and B classes.
This C xcframework is compiled with BUILD_LIBRARY_FOR_DISTRIBUTION se to true and if I check its swiftinterface files it is not declaring the symbols from A and B. However the size of the binary seems to have A and B.
Is there any way to export A and B symbols as part of C's swiftinterface? If I add @_exported, it is forcing me to declare the import of A and B wherever I use them and therefore I'm going to have duplicated symbols
Thanks!
Meet mergeable libraries
RSS for tagDiscuss the WWDC23 SessionMeet mergeable libraries
Posts under wwdc2023-10268 tag
2 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello,
In Xcode 15 beta 3, if a project embedded a Swift package (no matter static or dynamic), and the package has its own dependencies, the linker will always emit following warning:
ld: warning: duplicate -rpath '/Users/.../Library/Developer/Xcode/DerivedData/MyApp.../Build/Products/Debug-iphonesimulator/PackageFrameworks' ignored
The warning is not appeared on beta 2 and beta 1.
Reproduce Steps
[1] Create a new iOS project in Xcode 15 beta 3
[2] Create a new Swift package MyLibrary, and add any dependency in the Package.swift. Example:
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "MyLibrary",
platforms: [.iOS(.v16)],
products: [
.library(name: "MyLibrary", targets: ["MyLibrary"]),
],
dependencies: [
// 👀 Add any dependency to this package.
// Here I use "Version" which is a simple pure swift package:
.package(url: "https://github.com/mxcl/Version.git", .upToNextMajor(from: "2.0.0")),
],
targets: [
.target(name: "MyLibrary", dependencies: ["Version",]),
]
)
[3] In the project page, embed MyLibrary into the iOS app target.
[4] Build the project. It will succeed but with link warnings.
In addition, if you create a dynamic framework and embed MyLibrary, the warnings also reproduce. And this is only a simple case. In my real project, the linker will also emit a lot of warnings like this:
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$__TtP10SPConfetti18SPConfettiDelegate_
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$__TtP10SPConfetti18SPConfettiDelegate_
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionTaskDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDataDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDownloadDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSObject
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionTaskDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDataDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDownloadDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSObject