bazel-xcode / PodToBUILD

An easy way to integrate CocoaPods into Bazel
Apache License 2.0
323 stars 69 forks source link

Cannot build SwiftNIO library #220

Open tgprojet opened 2 years ago

tgprojet commented 2 years ago

I am having issues with building the SwiftNIO module.

Here is my WORKSPACE file:

new_pod_repository(
  name = "CNIOWindows",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/e/b/2/CNIOWindows/2.40.0/CNIOWindows.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "CNIOAtomics",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/1/c/3/CNIOAtomics/2.40.0/CNIOAtomics.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)

new_pod_repository(
  name = "CNIODarwin",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/5/e/6/CNIODarwin/2.40.0/CNIODarwin.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "CNIOLinux",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/9/2/6/CNIOLinux/2.40.0/CNIOLinux.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)

new_pod_repository(
  name = "SwiftNIOCore",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/2/d/SwiftNIOCore/2.40.0/SwiftNIOCore.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "_NIODataStructures",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/9/8/_NIODataStructures/2.40.0/_NIODataStructures.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "SwiftNIOFoundationCompat",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/2/d/3/SwiftNIOFoundationCompat/2.40.0/SwiftNIOFoundationCompat.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "SwiftNIOEmbedded",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/1/2/2/SwiftNIOEmbedded/2.40.0/SwiftNIOEmbedded.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "SwiftNIOWebSocket",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/2/4/6/SwiftNIOWebSocket/2.40.0/SwiftNIOWebSocket.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)
new_pod_repository(
  name = "SwiftNIOConcurrencyHelpers",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/e/f/SwiftNIOConcurrencyHelpers/2.40.0/SwiftNIOConcurrencyHelpers.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)

new_pod_repository(
  name = "SwiftNIOPosix",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/3/6/7/SwiftNIOPosix/2.40.0/SwiftNIOPosix.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)

new_pod_repository(
  name = "SwiftNIO",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/e/8/6/SwiftNIO/2.40.0/SwiftNIO.podspec.json",
  url = "https://github.com/apple/swift-nio/archive/2.40.0.zip",
)

When I try to build the project, I get this error:

could not build Objective-C module 'NIOConcurrencyHelpers'

And it generates the following module file:

module NIOConcurrencyHelpers [system]  {
    export * 
}

module NIOConcurrencyHelpers.Swift {
    header "../NIOConcurrencyHelpers-Swift.h"
    requires objc
}

The SwiftNIOConcurrencyHelpers module itself builds without any errors. This error happens when the SWIFTNioCore module is being built.

Here is the full stacktrace:

warning: Unsupported field in Podspec version warning: Unsupported field in Podspec authors warning: Unsupported field in Podspec platforms warning: Unsupported field in Podspec documentation_url warning: Unsupported field in Podspec swift_version warning: Unsupported field in Podspec swift_versions warning: Unsupported field in Podspec cocoapods_version warning: Unsupported field in Podspec homepage warning: Unsupported field in Podspec summary /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/external/SwiftNIOCore /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/external/SwiftNIOCore Analyzing: target //MyProject:MyProject (303 packages loaded, 4672 targets configured) Analyzing: target //MyProject:MyProject (310 packages loaded, 20134 targets configured) note: Analyzed target //MyProject:MyProject (310 packages loaded, 20134 targets configured). note: Found 1 target... [9 / 309] [Prepa] BazelWorkspaceStatusAction stable-status.txt [3,709 / 4,306] Compiling Swift module NIOCore; 5s remote-cache, local /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/external/SwiftNIOCore/BUILD.bazel:47:14: error: Compiling Swift module NIOCore failed: (Exit 1): worker failed: error executing command (cd /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__ && \ exec env - \ APPLE_SDK_PLATFORM=iPhoneSimulator \ APPLE_SDK_VERSION_OVERRIDE=15.2 \ XCODE_VERSION_OVERRIDE=13.2.1.13C100 \ bazel-out/host/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc @bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOCore/NIOCore.swiftmodule-0.params) Execution platform: @local_config_platform//:host /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__/bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOConcurrencyHelpers/NIOConcurrencyHelpers_extended_module_map/module.modulemap:6:12: error: header '../NIOConcurrencyHelpers-Swift.h' not found header "../NIOConcurrencyHelpers-Swift.h" ^ /Volumes/Work/Development/iOS/MyProject/:0: error: could not build Objective-C module 'NIOConcurrencyHelpers' Aspect @tulsi//:tulsi/tulsi_aspects.bzl%tulsi_outputs_aspect of //MyProject:MyProject up-to-date: bazel-out/applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/MyProject/MyProject.tulsiouts error: /Volumes/Work/Development/iOS/MyProject/MyProject/BUILD:207:14 Compiling Swift module MyProject_Lib failed: (Exit 1): worker failed: error executing command (cd /private/var/tmp/_bazel_myuser/5a4211b0776ffc168b8e9297ac8b46fe/execroot/__main__ && \ exec env - \ APPLE_SDK_PLATFORM=iPhoneSimulator \ APPLE_SDK_VERSION_OVERRIDE=15.2 \ XCODE_VERSION_OVERRIDE=13.2.1.13C100 \ bazel-out/host/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc @bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-dbg-ST-6cb99487ae90/bin/external/SwiftNIOCore/NIOCore.swiftmodule-0.params) Execution platform: @local_config_platform//:host note: Elapsed time: 44.972s, Critical Path: 9.98s note: 2 processes: 2 internal. error: Build did NOT complete successfully <*> Running Bazel completed in 45103.149 ms /Volumes/Work/Development/iOS/MyProject/build-input/gen/project/MyProject.xcodeproj/.tulsi/Scripts/bazel_build.py:581: error: Bazel build failed with exit code 1. Please check the build log in Report Navigator (⌘9) for more information. <*> Everything completed in 45125.032 ms

Please help to solve this issue

tgprojet commented 2 years ago

I have found the issue. The problem that it takes the module name from a podspec file and generates header for module mapping using this name.

For example if we open CocoaPods

This file contains "module_name": "NIOConcurrencyHelpers", However the Pod name is SwiftNIOConcurrencyHelpers so it generates file with the following name SwiftNIOConcurrencyHelpers-Swift.h So to solve issue I need to copy the SwiftNIOConcurrencyHelpers-Swift.h file to NIOConcurrencyHelpers-Swift.h.

The same issue with Secp256k1Kit.swift" this pod contains . dot in the name.

Please suggest how to solve the issue without manual copying header files?