Skip to content

Conversation

@hoangnami
Copy link

@hoangnami hoangnami commented Jul 23, 2025

This pull request handle fixes for Swift 6 when archiving the project using xcodebuild

EmitSwiftModule normal arm64 (in target 'VGSLFundamentals' from project 'vgsl')
    cd /Users/.../Project.xcodeproj

/Users/hoang/Library/Developer/Xcode/DerivedData/NamiPairingFramework-cityhsscwcwvukcpuvoswwwvpuir/SourcePackages/checkouts/vgsl/VGSLFundamentals/Zip3.swift:43:5: error: 'let' property '_seq' may not be initialized directly; use "self.init(...)" or "self = ..." instead
    _seq = (seq1, seq2, seq3)
    ^
/Users/hoang/Library/Developer/Xcode/DerivedData/NamiPairingFramework-cityhsscwcwvukcpuvoswwwvpuir/SourcePackages/checkouts/vgsl/VGSLFundamentals/Zip3.swift:39:16: note: '_seq' declared here
  internal let _seq: (Seq1, Seq2, Seq3)
               ^
/Users/hoang/Library/Developer/Xcode/DerivedData/NamiPairingFramework-cityhsscwcwvukcpuvoswwwvpuir/SourcePackages/checkouts/vgsl/VGSLFundamentals/concurrency/AllocatedUnfairLock.swift:18:5: error: 'let' property 'buffer' may not be initialized directly; use "self.init(...)" or "self = ..." instead
    buffer = Buffer.create(minimumCapacity: 1) { buffer in
    ^
/Users/hoang/Library/Developer/Xcode/DerivedData/NamiPairingFramework-cityhsscwcwvukcpuvoswwwvpuir/SourcePackages/checkouts/vgsl/VGSLFundamentals/concurrency/AllocatedUnfairLock.swift:14:7: note: 'buffer' declared here
  let buffer: Buffer
      ^
/Users/hoang/Library/Developer/Xcode/DerivedData/NamiPairingFramework-cityhsscwcwvukcpuvoswwwvpuir/SourcePackages/checkouts/vgsl/VGSLFundamentals/reactive/Lazy.swift:35:3: error: deinitializer can only be '@inlinable' if the class is '@_fixed_layout'
  @inlinable
  ^~~~~~~~~~

/Users/hoang/Library/Developer/Xcode/DerivedData/NamiPairingFramework-cityhsscwcwvukcpuvoswwwvpuir/SourcePackages/checkouts/vgsl/VGSLFundamentals/reactive/Lazy.swift:31:12: error: initializer for class 'Lazy<T>' is '@inlinable' and must delegate to another initializer
  internal init(state: State) {
           ^

SwiftEmitModule normal arm64 Emitting\ module\ for\ SwiftProtobuf (in target 'SwiftProtobuf' from project 'SwiftProtobuf')

EmitSwiftModule normal arm64 (in target 'SwiftProtobuf' from project 'SwiftProtobuf')
    cd /Users/hoang/nami/nami_app_multiplatform/ios/nami_libraries/NamiPairingFramework/NamiPairingFramework.xcodepr

hoangnami added 10 commits June 26, 2025 15:03
- Fix 'let' property initialization in Zip3.swift using self._seq
- Fix 'let' property initialization in AllocatedUnfairLock.swift using self.buffer
- Remove @inlinable from deinit in Lazy.swift (not allowed in Swift 6)
- Remove @inlinable from designated init in Lazy.swift

These changes make VGSL 7.3.1 compatible with Swift 6 / Xcode 16.4+
The @inlinable convenience initializers need to call this internal method,
which requires @usableFromInline in Swift 6.
This reverts commit ed6195f.
…tion instead of direct assignment to resolve Swift 6 compilation errors in Zip3Sequence and AllocatedUnfairLock.
…pattern with helper initializers to resolve Swift 6 compilation errors in Zip3Sequence and AllocatedUnfairLock.
…pattern to resolve remaining Swift 6 compilation errors in OSInfo, Zip3Sequence.Iterator, and AnyAsyncSequence/Iterator.
@hoangnami
Copy link
Author

@morevsavva @lunarstill could you guys help me to review this PR?

@rsbooster
Copy link
Collaborator

Hi. Thanks for this PR.
Looks like that you are trying to build VGSL with BUILD_LIBRARY_FOR_DISTRIBUTION flag.
If this is true, please describe your use case and dependency graph.

@hoangnami
Copy link
Author

hoangnami commented Jul 26, 2025

Hi, thank you for being active and responding to my PR request. We are building SDK but due to nature of protecting our implementation we are distributing our SDK as binary targets and inside SPM that has additional dependencies like DivKit. Our scripts are run on github actions so we rely on xcodebuild to create frameworks and package it as xcframeworks.

This is part where we found compilation errors. Weirdly if I am trying to archive in Xcode there are no errors.

import PackageDescription

let package = Package(
    name: "NamiPairing",
    platforms: [
        .iOS(.v14),
        .macOS(.v10_15),
    ],
    products: [
        .library(
            name: "NamiPairing",
            targets: ["NamiPairingCore", "StandardPairingUI"]),
        .library(
            name: "NamiPairing-NoUI", 
            targets: ["NamiPairingCore"])
    ],
    dependencies: [
        .package(url: "https://github.com/divkit/divkit-ios", from: "32.9.0"),
        .package(url: "https://github.com/namiai/vgsl.git", from: "7.4.2")
        
    ],
    targets: [
        .binaryTarget(name: "NamiPairingFramework", path: "Sources/NamiPairing/NamiPairingFramework.xcframework"),
        .binaryTarget(name: "StandardPairingUI", path: "Sources/NamiPairing/StandardPairingUI.xcframework"),
        .target(
          name: "NamiPairingCore",
          dependencies: [
            "NamiPairingFramework",
            .product(name: "DivKit", package: "divkit-ios"),
            .product(name: "DivKitSVG", package: "divkit-ios"),
            .product(name: "DivKitExtensions", package: "divkit-ios"),
            .product(name: "VGSL", package: "vgsl"),
          ],
          path: "Sources/NamiPairing/NamiPairingCore"
        ),
    ]
)
xcodebuild archive -configuration release -scheme NamiPairingFramework -destination "generic/platform=iOS" -archivePath build/NamiPairingFramework_iOS SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES CODE_SIGN_IDENTITY="$(security find-identity -v -p codesigning | grep -oEi '\b[0-9A-F]{40}\b' | awk 'NR==1')"

@rsbooster
Copy link
Collaborator

Turns out, it's a very complex question.

First of all, as Apple Documentation says BUILD_LIBRARY_FOR_DISTRIBUTION build parameter

should only be used when a framework is going to be built and updated separately from its clients

VGSL and DivKit are not meant to be distributed that way.

Weirdly if I am trying to archive in Xcode there are no errors.

Thats because, explicit passing parameter BUILD_LIBRARY_FOR_DISTRIBUTION=YES in xcodebuild archive command force it for all targets in dependency graph.
Instead, you can set this flag only for root target NamiPairingFramework.
Here is sample Xcode project on which I experimenting on.

Second. When you export framework this way - it gets all dependent static libraries inside. You can check that DivKit actually compiled inside NamiPairingFramework binary.
nm NamiPairingFramework | grep DivKit.
So, you don't need to provide this deps in Package.swift.

And third, as DivKit/VGSL are not meant to distribute as a binary framework you should not expose their types to your public API. Swift now has internal import directive for this.

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.

2 participants