Giter VIP home page Giter VIP logo

podtobuild's People

Contributors

asatti-pins avatar bolsinga avatar crazyfanfan avatar dependabot[bot] avatar dgcoffman avatar fuegofro avatar garrettmoon avatar jerrymarino avatar johndpope avatar jparise avatar kerrmarin avatar maicki avatar mstoreytr avatar rahul-malik avatar segiddins avatar stristr avatar thii avatar vphamdev avatar woshimaliang avatar xinzhengzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

podtobuild's Issues

In copts attribute of objc_library rule $(BUILD_DIR) not defined

Hi guys,
I have transfer pod to build, but i got this error. I think it is cause by the "$(BUILD_DIR)" from Pod inner, but I do not have any idea to fix it.

Analyzing: target //mediapipe/examples/ios/facedetectioncpu:FaceDetectionCpuApp (1 packages loaded, 0 targets configured)
ERROR: /private/var/tmp/_bazel_ali/18ba3966ddbbfd8096433355d3c643f4/external/xxx/BUILD:790:11: in copts attribute of objc_library rule @xxx//:aarch64_cxx: $(BUILD_DIR) not defined

Use rules_pods as a source dependency

I tried to use git_repository with rules_pods to have the latest fixes from the master branch but it looks like Bazel always looked for the pre-compiled Compiler and RepoTools under the bin directory, which only exists in a release tarball. The current workaround is to do a manual build of rules_pods and upload the release tarball somewhere.

Is the any way to use this as a host dependency of new_pod_repository so that Bazel will build rules_pods first and then use the build results as the build tools for the new_pod_repository targets?

Producing pods

rules_pods can add pods as dependencies to a Bazel workspace. How about the other way around:

How do I compile an Obj-C++ library into a pod that can be imported into an already existing XCode project?

Thanks

Remove the required dependency on `CocoaPods`

We currently use cocoa pods to deserialize a Podspec into the json representation.

If the json is provided in the podspec_url, then we don't need to rely on CocoaPods, and it's associated dependencies.

This would make a lot simpler to install PodToBUILD!

Make source files readonly

When a user opens a file in Xcode or other editor, it may be possible to change the file.

The source files should be set to readonly by default, which will at least give them some warning.

Most of the time I am getting "in objc_library rule XXX: target YYY is not visible from target XXX. Check the visibility declaration of the former target if you think the dependency is legitimate." error

WORKSPACE

...
new_pod_repository(
    name = "NotificationBannerSwift",
    url = "https://github.com/Daltron/NotificationBanner/archive/3.0.4.zip",
)

new_pod_repository(
    name = "MarqueeLabel",
    url = "https://github.com/cbpowell/MarqueeLabel/archive/4.0.2.zip",
)

new_pod_repository(
    name = "SnapKit",
    url = "https://github.com/SnapKit/SnapKit/archive/5.0.1.zip",
)

BUILD

load(
	"@build_bazel_rules_swift//swift:swift.bzl", 
	"swift_library",
)

swift_library(
	name = "MyLib",
	srcs = glob(
		[
			"MyLib/**/*.swift",
		]
	),
	deps = [
        "@SnapKit//:SnapKit",
        "@NotificationBannerSwift//:NotificationBannerSwift",
    ],
)

Output of bazel build

ERROR: /private/var/tmp/_bazel_<redacted>/external/NotificationBannerSwift/BUILD.bazel:64:13: in objc_library rule @NotificationBannerSwift//:NotificationBannerSwift_cxx: target '@MarqueeLabel//:MarqueeLabel' is not visible from target '@NotificationBannerSwift//:NotificationBannerSwift_cxx'. Check the visibility declaration of the former target if you think the dependency is legitimate

ERROR: /private/var/tmp/_bazel_<redacted>/external/NotificationBannerSwift/BUILD.bazel:64:13: in objc_library rule @NotificationBannerSwift//:NotificationBannerSwift_cxx: target '@SnapKit//:SnapKit' is not visible from target '@NotificationBannerSwift//:NotificationBannerSwift_cxx'. Check the visibility declaration of the former target if you think the dependency is legitimate

Anyone has some idea how to solve this instead of import both Pods manually in Bazel? Thanks

bazel query fails after cloning PodToBuild

I can no longer run bazel query, perhaps due to versioning conflicts. Is there a set of skylib/rules_apple/rules_swift that need to be consistent to work with PodToBuild?

08:45 $ bazel query ...
ERROR: error loading package 'Vendor/rules_pods/bazel-rules_pods/external/build_bazel_rules_apple/tools/realpath': Extension file not found. Unable to load package for '//apple:apple_genrule.bzl': BUILD file not found on package path

Header Finding Issue

Hey all, thanks for making such a neat tool.

It's possible I'm missing something silly here, but I'm having issues with includes in what seems like it should be a relatively straightforward case.

I'm trying to use the GBDeviceInfo /Core podspec.

bazel build @GBDeviceInfo//:Core --keep_going fails because it can't find the pod's headers

bazel-out/apl-darwin_x86_64-fastbuild/bin/external/GBDeviceInfo/GBDeviceInfo_module_map/../../../../../../external/GBDeviceInfo/GBDeviceInfo/GBDeviceInfo.h:33:9: fatal error: 'GBDeviceInfo_OSX.h' file not found
#import "GBDeviceInfo_OSX.h"
        ^~~~~~~~~~~~~~~~~~~~
external/GBDeviceInfo/GBDeviceInfo/ GBDeviceInfo_iOS.m:20:9: fatal error: could not build module 'GBDeviceInfo'
#import "GBDeviceInfo_iOS.h"
 ~~~~~~~^~~~~~~~~~~~~~~~~~~~

I see two issues there. First, that it's not finding the GBDeviceInfo_OSX.h header--which should be in there. And second it seems strange that it's trying to compile GBDeviceInfo_iOS.m on mac, when that source is marked as iOS-only in the podspec.

Is there something straightforward I'm missing here? It feels like this should be mostly parallel to PINOperation, but that example works fine.

Thanks so much,
Chris

P.S. For reference, my WORKSPACE just has the basics added. The only change from your example is moving to the latest release of this repo (PodToBUILD):

http_archive(
    name = "rules_pods",
    urls = ["https://github.com/pinterest/PodToBUILD/releases/download/0.25.2-8a5efa0/PodToBUILD.zip"],
)

load("@rules_pods//BazelExtensions:workspace.bzl", "new_pod_repository")

new_pod_repository(
  name = "GBDeviceInfo",
  url = "https://github.com/lmirosevic/GBDeviceInfo/archive/6.3.0.zip",
)

Support in-tree podspecs

This enables people to use local podspecs as the source of truth for target
definition and build settings instead of a BUILD file.

It introduces a single repository_rule to generates a BUILD files for
every podspec in the source tree adjacent to the podspec.

Example repository_rule

# WORKSPACE
gen_pod_build_files()

Considerations:

  • the rule must be a repository rule, to fit into bazels evaluation
    model

  • it may glob all the *.podspecs as an input and use these inputs for cache
    invalidation

  • the BUILD file compiler needs to be updated to manage the local podspecs

  • </> and @ import support needs to be updated to hmaps or symlinking to
    the right directory.

Time for a new release?

Hello! There have been quite a few bugfixes merged since the 2018-10-31 pre-release 0.18.0-95fd009. Can we please get a new pre-release up on GitHub?

I'm using local_repository with a locally-built checkout with my project right now, and because the Git repository doesn't store the Swift binaries (Compiler and RepoTools), I think we can't use git_repository on its own.

[Swift] Consider moving to Bazel module system

On Bazel 0.18 module maps are now supported by default and are working quite nicely with rules_swift. In earlier Bazel releases, we were required to create custom module maps, and propagate them through headers. This isn't ideal for several reasons.

Mixed language / Swift support

Add support for Swift / mixed languages.

I think this is pretty straight forward. The main difference between Xcode and Bazel is that Xcode allows mixed language targets, and Bazel does not. The PodSpec format is heavily influenced by this feature.

Logic for swift could work out like this:

  • Determine if a given Spec contains swift. We need to search the possible source files in glob patterns: possibly evaluating all permutations of the globs.
  • If the glob does contain swift, then split out a swift_library which is fused onto the dependency graph. The name of the Spec should point to a bazel target that links either Swift or Objc deps.
    The base objc_library should depend on the swift_library if needed.

The same logic should apply for other languages, or subsets of a pod which contain settings that only work with a subset of the source code, like C++ conditional options used in Texture. This logic should fix the recent query to bazel-discuss and workarounds for Texture.

Error on broken cocoapods installation

We currently check if there is some program called pod on the user machine and error out if there is not.

If a cocoapods installation is corrupted, we fail at PodSpec conversion time producing an error message that would lead the user to believe the podspec is invalid. _exec failed 4 fatal error: Invalid JSON Podspec:

Simply check pod --version or similar to get a better sense of if the program is correctly installed, and print a nice error if it isn't.

Update to Swift 5

With the 10.2 release of Xcode, Swift 5 is now out of beta and we should update our projects and CI soon.

"empty segment not permitted" when a podspec defines its source_files with trailing slash

As the title says, when you have a podspec that defines its source files with a trailing slash, you get the error empty segment not permitted. For example, trying to build the Moya (I realise this is a Swift library, but bear with me) yields:

ERROR: /path/to/project/ios/Vendor/Moya/BUILD:165:10: Traceback (most recent call last):
	File "/path/to/project/ios/Vendor/Moya/BUILD", line 162
		objc_library(name = "Core_cxx", enable_modules ..., <8 more arguments>)
	File "/path/to/projectios/Vendor/Moya/BUILD", line 165, in objc_library
		glob(["Sources/Moya//**/*.cc", "Sourc..."], <2 more arguments>)
empty segment not permitted

You'll notice that the glob's path is Sources/Moya//**/*.cc which yields the error. The Moya podspec defines its source files as:

  s.subspec "Core" do |ss|
    ss.source_files  = "Sources/Moya/", "Sources/Moya/Plugins/"
    ss.dependency "Alamofire", "5.0.0-rc.2"
    ss.framework  = "Foundation"
  end

I've tested this with a simple spec for an obj-c project and the same error occurs when the trailing slash is added to the source_files. The error disappears if the podspec is updated to remove the trailing slash.

Header file not found

Hey, Thank you so much for developing such a great tool!

Probably because I am not familiar with bazel, I just want to simply use the open source library "FBMemoryProfiler" in the project, but when I execute the command bazel build //:PodToBuild-Example --sandbox_debug --keep_going, the following error will be reported:
截屏2020-02-27上午10 11 08

While building module 'FBRetainCycleDetector' imported from bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler/FBMemoryProfiler_module_map/../../../../../../external/FBMemoryProfiler/FBMemoryProfiler/FBMemoryProfiler.h:22:
In file included from <module-includes>:1:
bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBRetainCycleDetector/FBRetainCycleDetector_module_map/../../../../../../external/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/Parser/BaseType.h:12:9: fatal error: 'string' file not found
#import <string>
        ^~~~~~~~
While building module 'FBMemoryProfiler' imported from external/FBMemoryProfiler/FBMemoryProfiler/RetainCycles/FBRetainCyclePresenter.m:9:
In file included from <module-includes>:1:
bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler/FBMemoryProfiler_module_map/../../../../../../external/FBMemoryProfiler/FBMemoryProfiler/FBMemoryProfiler.h:22:9: fatal error: could not build module 'FBRetainCycleDetector'
#import <FBRetainCycleDetector/FBObjectGraphConfiguration.h>
 ~~~~~~~^
external/FBMemoryProfiler/FBMemoryProfiler/RetainCycles/FBRetainCyclePresenter.m:9:9: fatal error: could not build module 'FBMemoryProfiler'
#import "FBRetainCyclePresenter.h"
 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
ERROR: /private/var/tmp/_bazel_bytedance/f40f007aea084906eed728c98ae31477/external/FBMemoryProfiler/BUILD.bazel:234:1: Couldn't build file external/FBMemoryProfiler/_objs/FBMemoryProfiler/arc/FBMemoryProfilerViewController.o: C++ compilation of rule '@FBMemoryProfiler//:FBMemoryProfiler' failed (Exit 1) sandbox-exec failed: error executing command
  (cd /private/var/tmp/_bazel_bytedance/f40f007aea084906eed728c98ae31477/sandbox/darwin-sandbox/163/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=iPhoneSimulator \
    APPLE_SDK_VERSION_OVERRIDE=13.2 \
    DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
    PATH='/Users/bytedance/.rvm/gems/ruby-2.5.0/bin:/Users/bytedance/.rvm/gems/ruby-2.5.0@global/bin:/Users/bytedance/.rvm/rubies/ruby-2.5.0/bin:/usr/local/sbin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/bin:/opt/puppetlabs/bin:/usr/local/munki:/bin:/usr/local/opt/fzf/bin:/Users/bytedance/go/bin:/Users/bytedance/.rvm/bin:/Users/bytedance/bin:/Users/bytedance/.rvm/bin' \
    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk \
    TMPDIR=/var/folders/2d/glwc0r6d3lv498516d9yqyl80000gp/T/ \
    XCODE_VERSION_OVERRIDE=11.3.1.11C504 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_bytedance/f40f007aea084906eed728c98ae31477/sandbox/darwin-sandbox/163/sandbox.sb /var/tmp/_bazel_bytedance/install/7afe40059062a3d2a6e3d7dae41ab49a/process-wrapper '--timeout=0' '--kill_delay=15' external/local_config_cc/wrapped_clang -arch x86_64 '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -iquote external/FBMemoryProfiler -iquote bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler -iquote bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin -Iexternal/FBAllocationTracker/pod_support/Headers/Public -Ibazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBAllocationTracker/FBAllocationTracker_module_map -Iexternal/FBAllocationTracker/FBAllocationTracker_module_map -Iexternal/FBRetainCycleDetector/pod_support/Headers/Public -Ibazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBRetainCycleDetector/FBRetainCycleDetector_module_map -Iexternal/FBRetainCycleDetector/FBRetainCycleDetector_module_map -Iexternal/FBMemoryProfiler/pod_support/Headers/Public -Ibazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler/FBMemoryProfiler_module_map -Iexternal/FBMemoryProfiler/FBMemoryProfiler_module_map -MD -MF bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler/_objs/FBMemoryProfiler/arc/FBMemoryProfilerViewController.d -DOS_IOS -fno-autolink -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -fobjc-arc '-mios-simulator-version-min=9.0' -fexceptions -fasm-blocks '-fobjc-abi-version=2' -fobjc-legacy-dispatch -Wnon-modular-include-in-framework-module -g '-stdlib=libc++' '-DCOCOAPODS=1' '-DOBJC_OLD_DISPATCH_PROTOTYPES=0' -fdiagnostics-show-note-include-stack -fno-common -fembed-bitcode-marker '-fmessage-length=0' -fpascal-strings -fstrict-aliasing '-Wno-error=nonportable-include-path' '-DPOD_CONFIGURATION_RELEASE=0' -Iexternal/FBMemoryProfiler/pod_support/Headers/Public/FBMemoryProfiler/ '-fmodule-name=FBMemoryProfiler_pod_module' -fmodules '-fmodules-cache-path=bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/_objc_module_cache' -O0 '-DDEBUG=1' -c external/FBMemoryProfiler/FBMemoryProfiler/Controllers/FBMemoryProfilerViewController.m -o bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler/_objs/FBMemoryProfiler/arc/FBMemoryProfilerViewController.o)
While building module 'FBMemoryProfiler' imported from external/FBMemoryProfiler/FBMemoryProfiler/Controllers/FBMemoryProfilerViewController.m:9:
While building module 'FBRetainCycleDetector' imported from bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBMemoryProfiler/FBMemoryProfiler_module_map/../../../../../../external/FBMemoryProfiler/FBMemoryProfiler/FBMemoryProfiler.h:22:
In file included from <module-includes>:1:
bazel-out/ios-x86_64-min9.0-applebin_ios-ios_x86_64-fastbuild/bin/external/FBRetainCycleDetector/FBRetainCycleDetector_module_map/../../../../../../external/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/Parser/BaseType.h:12:9: fatal error: 'string' file not found
#import <string>

The example project I used is as follows:
Example.zip

Is there something straightforward I'm missing here? It feels like this should be mostly parallel to PINOperation, but that example works fine.

Thanks so much !

support for tar.xz

Error message
Fatal error: Cannot extract files other than .zip or .tar

BUILD rule

new_pod_repository(
    name = "VLCKit",
    url = "https://download.videolan.org/pub/cocoapods/prod/MobileVLCKit-3.3.9-1a7bd97-03d4f115e0.tar.xz",
    podspec_url = "Packaging/podspecs/MobileVLCKit.podspec"
)

Crash when updating PINOperation

I got the following crash when running ./Vendor/rules_pods/bin/update_pods.py:

Updating Pod PINOperation...
_exec failed 4  Fatal error: Download of PINOperation failed: file Sources/RepoToolsCore/RepoActions.swift, line 391
2018-07-19 17:39:15.495 RepoTools[10065:5088584] Received signal: 4

I have PinOperation defined in Pods.WORKSPACE as:

new_pod_repository(
  name = "PINOperation",
  url = "https://github.com/pinterest/PINOperation/arhive/1.0.3.zip"
)

Module Maps for Obj-C/C/C++ include too many files

I noticed this with https://github.com/facebook/yoga

filegroup(
  name = "yoga_hdrs",
  srcs = glob(
    [
      "pod_support/Headers/Public/**/*.h"
    ],
    exclude_directories = 1
    ),
  visibility = [
    "//visibility:public"
  ]
  )
gen_module_map(
  "yoga",
  "yoga_module_map",
  "yoga",
  [
    "yoga_hdrs"
  ]
  )

It seems like pod_support/Headers/Public/ contains too many files (every yoga header, public or private), given that the podspec lists only three public headers: https://github.com/facebook/yoga/blob/master/Yoga.podspec#L28.

An error occurred during the fetch of repository

Failed to resolve dependencies.

Environment

  • bazel 2.0.0 or 1.1.0
  • Xcode 11.3
ERROR: An error occurred during the fetch of repository 'SlackTextViewController':
   Not a regular file: /private/var/tmp/_bazel_noppe/593d550ebb7d3789479ed80d0a5c34d7/external/rules_pods/bin/RepoTools

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

# ----

git_repository(
    name = "build_bazel_rules_apple",
    remote = "https://github.com/bazelbuild/rules_apple.git",
    tag = "0.19.0",
)

# ----

git_repository(
    name = "build_bazel_rules_swift",
    remote = "https://github.com/bazelbuild/rules_swift.git",
	tag = "0.13.0",
)
load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)
swift_rules_dependencies()

# ----

git_repository(
    name = "build_bazel_apple_support",
    remote = "https://github.com/bazelbuild/apple_support.git",
	tag = "0.7.2",
)
load(
    "@build_bazel_apple_support//lib:repositories.bzl",
    "apple_support_dependencies",
)
apple_support_dependencies()

# ----

git_repository(
    name = "bazel_skylib",
    remote = "https://github.com/bazelbuild/bazel-skylib.git",
    tag = "0.9.0",
)

# ----

load(
    "@com_google_protobuf//:protobuf_deps.bzl",
    "protobuf_deps",
)

protobuf_deps()

# ----

git_repository(
    name = "rules_pods",
    remote = "https://github.com/pinterest/PodToBUILD.git",
    branch = "master",
)
load("@rules_pods//BazelExtensions:workspace.bzl", "new_pod_repository")

new_pod_repository(
    name = "SlackTextViewController",
    url = "https://github.com/slackhq/SlackTextViewController/archive/v1.9.6.zip",
    inhibit_warnings = True,
    generate_module_map = False,
)

BUILD

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@rules_pods//BazelExtensions:workspace.bzl", "new_pod_repository")

swift_library(
    name = "Sources",
    srcs = glob(["*.swift"]),
    data = [
        "Base.lproj/LaunchScreen.storyboard",
        "Base.lproj/Main.storyboard",
    ],
    deps = [
        "@SlackTextViewController//:SlackTextViewController"
    ]
)



ios_application(
    name = "App",
    bundle_id = "be.tulipemoutarde.appa",
    families = ["iphone"],
    infoplists = [":Info.plist"],
    visibility = ["//visibility:public"],
    minimum_os_version = '13.0',
    deps = [
        ":Sources"
    ],
)

Implement a Podfile workspace generator

When developers add CocoaPods, they need to know the transitive dependencies, and make sure those can all be built with Bazel.

Additionally, it's a lot of work for people to maintain the WORKSPACE, and know how to use this tool. We should support a WORKSPACE generator where the user just gives it a Podfile and then it handles the rest.

Consider minimal ways to support a Podfiles that will still allow a user to customize new_pod_repository.

OTHER_LDFLAGS wrongly split

http_archive(
    name = "rules_pods",
    sha256 = "db4256e80fda350bff752f70385f3a332ac8b93d63c3ef677b11dca075dbe1ff",
    url = "https://github.com/pinterest/PodToBUILD/releases/download/0.25.2-8a5efa0/PodToBUILD.zip",
)
load("@rules_pods//BazelExtensions:workspace.bzl", "new_pod_repository")
new_pod_repository(
    name = "LibTorch",
    # More versions at https://github.com/CocoaPods/Specs/tree/master/Specs/1/3/c/LibTorch
    podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/075e9679993ae4798982fe55acb95f99486cc963/Specs/1/3/c/LibTorch/1.4.0/LibTorch.podspec.json",
    url = "https://ossci-ios.s3.amazonaws.com/libtorch_ios_1.4.0.zip",
)

This podspec's OTHER_LDFLAGS contains quoted -force_load "...some path..." which get truncated in such a way that the generated BUILD.bazel file is invalid:

# bazel build @LibTorch//:LibTorch
ERROR: …/external/LibTorch/BUILD.bazel:85:7: syntax error at 'external': expected ',', 'for' or ']'
ERROR: …/external/LibTorch/BUILD.bazel:201:7: syntax error at 'external': expected ',', 'for' or ']'
ERROR: …/external/LibTorch/BUILD.bazel:317:7: syntax error at 'external': expected ',', 'for' or ']'
ERROR: …/external/LibTorch/BUILD.bazel:421:7: syntax error at 'external': expected ',', 'for' or ']'

Generated code looks like:

objc_library(
  # …
  copts = [
    ""external/LibTorch/install/lib/libtorch.a"",
    "-force_load",
    "-Wnon-modular-include-in-framework-module",
    "-g",
    "-stdlib=libc++",
    "-DCOCOAPODS=1",
    # …
  ],
  # …
)

I'm not sure what -force_load means nor why there is even a OTHER_LDFLAGS but I bet just splitting this string on spaces is the issue and the generated code should actually look like:

objc_library(
  # …
  copts = [
    "-force_load \"external/LibTorch/install/lib/libtorch.a\"",
    "-Wnon-modular-include-in-framework-module",
    "-g",
    "-stdlib=libc++",
    "-DCOCOAPODS=1",
    # …
  ],
  # …
)

Moreover I'd say these ldflags should be put under linkopts = [...] instead of copts = [...] but again I'm not familiar with this.

cc #111
Note: one of the example uses this flag

Replace uncommon operators with named functions and remove obscure symbols

It is hard for me to contribute to the PodToBUILD source code because I don't regularly use operators in this project, and don't have a reason to memorize them. Additionally many are too hard to type.

Any symbols that don't exist on an Apple laptop on should be removed and linted against. I can't / don't want to use special shortcuts to type these characters in order to contribute to PodToBUILD.

The presence of these operators and symbols increases the barrier to entry to working on this for me, despite the fact that I'm somewhat familiar with the source code.

FBSDKCoreKit requires additional copts

Currently, this pod requires additional copts for internal includes. Find out why and fix the issue.

new_pod_repository(
  name = "FBSDKCoreKit",
  url = "https://github.com/facebook/facebook-ios-sdk/archive/sdk-version-4.16.0.zip",
  inhibit_warnings = True,
  user_options = ["FBSDKCoreKit.copts += -IVendor/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal"]
)

Cannot build `nanopb`

Hey esteemed PodToBUILD authors,

I get the following errors when attempting to build nanopb:

ERROR: /Volumes/.../Vendor/nanopb/BUILD.bazel:112:13: in non_arc_srcs attribute of objc_library rule //Vendor/nanopb:nanopb: source file '//Vendor/nanopb:pb_common.c' is misplaced here (expected .m or .mm)
ERROR: /Volumes/.../Vendor/nanopb/BUILD.bazel:112:13: in non_arc_srcs attribute of objc_library rule //Vendor/nanopb:nanopb: '//Vendor/nanopb:pb_common.c' does not produce any objc_library non_arc_srcs files (expected .m or .mm)
ERROR: /Volumes/.../Vendor/nanopb/BUILD.bazel:112:13: in non_arc_srcs attribute of objc_library rule //Vendor/nanopb:nanopb: source file '//Vendor/nanopb:pb_decode.c' is misplaced here (expected .m or .mm)
ERROR: /Volumes/.../Vendor/nanopb/BUILD.bazel:112:13: in non_arc_srcs attribute of objc_library rule //Vendor/nanopb:nanopb: '//Vendor/nanopb:pb_decode.c' does not produce any objc_library non_arc_srcs files (expected .m or .mm)
ERROR: /Volumes/.../Vendor/nanopb/BUILD.bazel:112:13: in non_arc_srcs attribute of objc_library rule //Vendor/nanopb:nanopb: source file '//Vendor/nanopb:pb_encode.c' is misplaced here (expected .m or .mm)
ERROR: /Volumes/.../Vendor/nanopb/BUILD.bazel:112:13: in non_arc_srcs attribute of objc_library rule //Vendor/nanopb:nanopb: '//Vendor/nanopb:pb_encode.c' does not produce any objc_library non_arc_srcs files (expected .m or .mm)

From the following declaration:

new_pod_repository(
  name = "nanopb",
  url = "https://github.com/nanopb/nanopb/archive/df0e92f474f9cca704fe2b31483f0b4d1b1715a4.zip",
  podspec_url = "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/6/1/e/nanopb/1.30905.0/nanopb.podspec.json",
  inhibit_warnings = True,
)

Cannot use Texture example in app

Hi I encountered the following error when trying to use Texture example(I update build file to use texture 2.8) in a swift app:

/Users/liwang/Documents/projects/atease/mono/App-iOS/BUILD:14:1: Compiling Swift module App_iOS_Sources failed (Exit 1) sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_liwang/819e8c6e05fda60b9cdfa83fb4ddbefc/sandbox/darwin-sandbox/1/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=iPhoneSimulator \
    APPLE_SDK_VERSION_OVERRIDE=12.1 \
    DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk \
    TMPDIR=/var/folders/25/17gky92x42jg9wykd2770t9w0000gn/T/ \
    XCODE_VERSION_OVERRIDE=10.1.0.10B61 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_liwang/819e8c6e05fda60b9cdfa83fb4ddbefc/sandbox/darwin-sandbox/1/sandbox.sb /var/tmp/_bazel_liwang/install/1a037b6c0d8096293d1eecfde6528fbd/_embedded_binaries/process-wrapper '--timeout=0' '--kill_delay=15' bazel-out/host/bin/external/build_bazel_rules_swift/tools/wrappers/bazel_xcode_wrapper bazel-out/host/bin/external/build_bazel_rules_swift/tools/wrappers/swift_wrapper /usr/bin/xcrun swiftc '-Xwrapped-swift=-ephemeral-module-cache' @bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-fastbuild/bin/App-iOS/App_iOS_Sources.swiftmodule-0.params @bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-fastbuild/bin/App-iOS/App_iOS_Sources.swiftmodule-1.params)
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../../../../../../Vendor/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASAbsoluteLayoutElement.h"
        ^
/private/var/tmp/_bazel_liwang/819e8c6e05fda60b9cdfa83fb4ddbefc/sandbox/darwin-sandbox/1/execroot/__main__/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-fastbuild/bin/Vendor/Texture/Texture_module_map/../../../../../../Vendor/Texture/Source/Layout/ASAbsoluteLayoutElement.h:22:23: error: unknown type name 'CGPoint'; did you mean 'Point'?
@property (nonatomic) CGPoint layoutPosition;
                      ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/MacTypes.h:542:41: note: 'Point' declared here
typedef struct Point                    Point;
                                        ^
<module-includes>:3:9: note: in file included from <module-includes>:3:
#import "../../../../../../Vendor/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASAbstractLayoutController+FrameworkPrivate.h"
        ^
/private/var/tmp/_bazel_liwang/819e8c6e05fda60b9cdfa83fb4ddbefc/sandbox/darwin-sandbox/1/execroot/__main__/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-fastbuild/bin/Vendor/Texture/Texture_module_map/../../../../../../Vendor/Texture/Source/Private/ASAbstractLayoutController+FrameworkPrivate.h:15:10: error: 'vector' file not found
#include <vector>
         ^
App-iOS/Sources/AppDelegate.swift:4:8: error: could not build Objective-C module 'AsyncDisplayKit'
import AsyncDisplayKit

Anyone can give me some pointers on how to fix it. It would be wonderful.

Thank you.

Stabilize BUILD file compiler output

The output of a BUILD file should be stable and idempotent. Mostly there are a few dictionaries that are unsorted.

Consider that sorting should happen in the Skylark code generator, rather than in the implementors of SkylarkConvertible.

Support `repository_rule` / external

PodToBUILD was originally implemented as a WORKSPACE rule and ran during a Bazel build. Due to multiple reasons, it does not use this feature of anymore. Please find the detailed description of why in this commit. e92ba0d

Perhaps with some of the recent changes to Bazel these issues might be resolved. Consider adding this in addition to Vendor

pod add build setting

it is not working when i add xcode build setting flag like this:
s.pod_target_xcconfig = {'METAL_LIBRARY_FILE_BASE' =>, 'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)" "$(PODS_TARGET_SRCROOT)/3rd_party/flatbuffers/include" ''}
s.user_target_xcconfig = { 'OTHER_LDFLAGS' => '-force_load $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME'}

Cannot easily import pods by name

Typically, the pod imports must be mangled with PodToBUILD to reflect the build target (referring to vendored pods here), like so:

Pods.WORKSPACE

new_pod_repository(
  name = "Hue",
  url = "https://github.com/zenangst/Hue/archive/b9d920cee4ba795fefb828d130744eee1e3d2feb.zip",
  inhibit_warnings = True,
)

...later...

BUILD.bzl

ViewController.swift

import Vendor_Hue_Hue_swift

// ...

It would be much cleaner if one could simply:

import Hue

as expected. This would also avoid tightly coupling source code to target paths, which might prevent easy refactoring down the road.

Add integration tests for licenses

Assert the following abilities:

Licenses work end to end:

Create a bundle library, Settings.bundle to exemplify end to end usage and validate such usage.

Transitive license propagation of licenses for all cases

Consider the following case: A pod, Foo has a subspec Bar. Bar depends on the external pod, Baz. Ensure that when a user depends on //Foo:Bar, that the license of Baz is correctly propagated.

The tests should run on the CI.

FBAllocationTracker and related deps create libraries including the same source files

FBMemoryProfiler, FBAllocationTracker, and FBRetainCycleDetector WORKSPACE rules create multiple objective c libraries that reference the same source.

FBAllocationTracker_cxx collides with FBAllocationTracker

Pods.WORKSPACE:

new_pod_repository(
    name = "FBAllocationTracker",
    owner = "@vsolomenchuk",
    generate_module_map = False,
    enable_modules = False,
    url = "https://github.com/facebook/FBAllocationTracker/archive/0.1.3.zip",
)

Here is an example output BUILD file

load(
  "//Vendor/rules_pods/BazelExtensions:extensions.bzl",
  "pch_with_name_hint",
  "acknowledged_target",
  "gen_module_map",
  "gen_includes"
  )
# Add a config setting release for compilation mode
# Assume that people are using `opt` for release mode
# see the bazel user manual for more information
# https://bazel.build/versions/master/docs/bazel-user-manual.html
native.config_setting(
  name = "release",
  values = {
    "compilation_mode": "opt"
  }
  )
filegroup(
  name = "FBAllocationTracker_cxx_hdrs",
  srcs = glob(
    [
      "FBAllocationTracker/**/*.h",
      "FBAllocationTracker/**/*.hpp",
      "FBAllocationTracker/**/*.hxx"
    ],
    exclude_directories = 1
    ),
  visibility = [
    "//visibility:public"
  ]
  )
filegroup(
  name = "FBAllocationTracker_cxx_union_hdrs",
  srcs = [
    "FBAllocationTracker_cxx_hdrs",
    "FBAllocationTracker_hdrs"
  ],
  visibility = [
    "//visibility:public"
  ]
  )
gen_includes(
  name = "FBAllocationTracker_cxx_includes",
  include = [
    "Vendor/FBAllocationTracker/pod_support/Headers/Public/"
  ]
  )
objc_library(
  name = "FBAllocationTracker_cxx",
  enable_modules = 0,
  srcs = glob(
    [
      "FBAllocationTracker/**/*.cc",
      "FBAllocationTracker/**/*.cpp",
      "FBAllocationTracker/**/*.cxx",
      "FBAllocationTracker/FBAllocationTracker.h",
      "FBAllocationTracker/FBAllocationTrackerFunctors.h",
      "FBAllocationTracker/FBAllocationTrackerImpl.h",
      "FBAllocationTracker/FBAllocationTrackerImpl.mm",
      "FBAllocationTracker/FBAllocationTrackerManager.h",
      "FBAllocationTracker/FBAllocationTrackerManager.mm",
      "FBAllocationTracker/FBAllocationTrackerSummary.h",
      "FBAllocationTracker/FBAllocationTrackerSummary.m",
      "FBAllocationTracker/Generations/FBAllocationTrackerGeneration.h",
      "FBAllocationTracker/Generations/FBAllocationTrackerGeneration.mm",
      "FBAllocationTracker/Generations/FBAllocationTrackerGenerationManager.h",
      "FBAllocationTracker/Generations/FBAllocationTrackerGenerationManager.mm"
    ],
    exclude = [
      "FBAllocationTracker/**/*.S",
      "FBAllocationTracker/**/*.c",
      "FBAllocationTracker/**/*.m",
      "FBAllocationTracker/**/*.s"
    ],
    exclude_directories = 1
    ),
  non_arc_srcs = glob(
    [
      "FBAllocationTracker/**/*.mm"
    ],
    exclude = [
      "FBAllocationTracker/**/*.m",
      "FBAllocationTracker/FBAllocationTrackerImpl.mm",
      "FBAllocationTracker/FBAllocationTrackerManager.mm",
      "FBAllocationTracker/FBAllocationTrackerSummary.m",
      "FBAllocationTracker/Generations/FBAllocationTrackerGeneration.mm",
      "FBAllocationTracker/Generations/FBAllocationTrackerGenerationManager.mm"
    ],
    exclude_directories = 1
    ),
  hdrs = [
    ":FBAllocationTracker_cxx_union_hdrs"
  ],
  pch = pch_with_name_hint(
    "FBAllocationTracker",
    [
      "FBAllocationTracker/**/*.pch"
    ]
    ),
  sdk_frameworks = [
    "Foundation"
  ],
  sdk_dylibs = [
    "c++"
  ],
  deps = [

  ] + [
    "FBAllocationTracker_cxx_includes"
  ],
  copts = [
    "-Wnon-modular-include-in-framework-module",
    "-g",
    "-stdlib=libc++",
    "-DCOCOAPODS=1",
    "-DOBJC_OLD_DISPATCH_PROTOTYPES=0",
    "-fdiagnostics-show-note-include-stack",
    "-fno-common",
    "-fembed-bitcode-marker",
    "-fmessage-length=0",
    "-fpascal-strings",
    "-fstrict-aliasing",
    "-Wno-error=nonportable-include-path"
  ] + select(
    {
      "//conditions:default": [
        "-DPOD_CONFIGURATION_RELEASE=0"
      ],
      ":release": [
        "-DPOD_CONFIGURATION_RELEASE=1",
        "-DNS_BLOCK_ASSERTIONS=1"
      ]
    }
    ) + [
    "-IVendor/FBAllocationTracker/pod_support/Headers/Public/FBAllocationTracker/"
  ] + [
    "-fmodule-name=FBAllocationTracker_pod_module"
  ],
  visibility = [
    "//visibility:public"
  ]
  )
acknowledged_target(
  name = "FBAllocationTracker_cxx_acknowledgement",
  deps = [

  ],
  value = "//Vendor/FBAllocationTracker/pod_support_buildable:acknowledgement_fragment"
  )
filegroup(
  name = "FBAllocationTracker_hdrs",
  srcs = glob(
    [
      "pod_support/Headers/Public/**/*"
    ],
    exclude_directories = 1
    ) + glob(
    [
      "FBAllocationTracker/**/*.h",
      "FBAllocationTracker/**/*.hpp",
      "FBAllocationTracker/**/*.hxx"
    ],
    exclude_directories = 1
    ) + [
    ":FBAllocationTracker_cxx_hdrs"
  ],
  visibility = [
    "//visibility:public"
  ]
  )
gen_includes(
  name = "FBAllocationTracker_includes",
  include = [
    "Vendor/FBAllocationTracker/pod_support/Headers/Public/"
  ]
  )
gen_module_map(
  "FBAllocationTracker",
  "FBAllocationTracker_module_map",
  "FBAllocationTracker",
  [
    "FBAllocationTracker_hdrs"
  ]
  )
objc_library(
  name = "FBAllocationTracker",
  enable_modules = 0,
  srcs = glob(
    [
      "FBAllocationTracker/**/*.S",
      "FBAllocationTracker/**/*.c",
      "FBAllocationTracker/**/*.s",
      "FBAllocationTracker/FBAllocationTracker.h",
      "FBAllocationTracker/FBAllocationTrackerFunctors.h",
      "FBAllocationTracker/FBAllocationTrackerImpl.h",
      "FBAllocationTracker/FBAllocationTrackerImpl.mm",
      "FBAllocationTracker/FBAllocationTrackerManager.h",
      "FBAllocationTracker/FBAllocationTrackerManager.mm",
      "FBAllocationTracker/FBAllocationTrackerSummary.h",
      "FBAllocationTracker/FBAllocationTrackerSummary.m",
      "FBAllocationTracker/Generations/FBAllocationTrackerGeneration.h",
      "FBAllocationTracker/Generations/FBAllocationTrackerGeneration.mm",
      "FBAllocationTracker/Generations/FBAllocationTrackerGenerationManager.h",
      "FBAllocationTracker/Generations/FBAllocationTrackerGenerationManager.mm"
    ],
    exclude_directories = 1
    ),
  non_arc_srcs = glob(
    [
      "FBAllocationTracker/**/*.m"
    ],
    exclude = [
      "FBAllocationTracker/FBAllocationTrackerImpl.mm",
      "FBAllocationTracker/FBAllocationTrackerManager.mm",
      "FBAllocationTracker/FBAllocationTrackerSummary.m",
      "FBAllocationTracker/Generations/FBAllocationTrackerGeneration.mm",
      "FBAllocationTracker/Generations/FBAllocationTrackerGenerationManager.mm"
    ],
    exclude_directories = 1
    ),
  hdrs = [
    ":FBAllocationTracker_hdrs"
  ],
  pch = pch_with_name_hint(
    "FBAllocationTracker",
    [
      "FBAllocationTracker/**/*.pch"
    ]
    ),
  sdk_frameworks = [
    "Foundation"
  ],
  sdk_dylibs = [
    "c++"
  ],
  deps = [
    ":FBAllocationTracker_cxx"
  ] + [
    "FBAllocationTracker_includes"
  ],
  copts = [
    "-Wnon-modular-include-in-framework-module",
    "-g",
    "-stdlib=libc++",
    "-DCOCOAPODS=1",
    "-DOBJC_OLD_DISPATCH_PROTOTYPES=0",
    "-fdiagnostics-show-note-include-stack",
    "-fno-common",
    "-fembed-bitcode-marker",
    "-fmessage-length=0",
    "-fpascal-strings",
    "-fstrict-aliasing",
    "-Wno-error=nonportable-include-path"
  ] + select(
    {
      "//conditions:default": [
        "-DPOD_CONFIGURATION_RELEASE=0"
      ],
      ":release": [
        "-DPOD_CONFIGURATION_RELEASE=1",
        "-DNS_BLOCK_ASSERTIONS=1"
      ]
    }
    ) + [
    "-IVendor/FBAllocationTracker/pod_support/Headers/Public/FBAllocationTracker/"
  ] + [
    "-fmodule-name=FBAllocationTracker_pod_module"
  ],
  visibility = [
    "//visibility:public"
  ]
  )
acknowledged_target(
  name = "FBAllocationTracker_acknowledgement",
  deps = [

  ],
  value = "//Vendor/FBAllocationTracker/pod_support_buildable:acknowledgement_fragment"
  )

Acknowledgements merger rules fails due to lack of "command"

Traceback (most recent call last):
File "/Users/rmalik/dev/ios/Vendor/GoogleToolboxForMac/BUILD", line 1618
acknowledgement_merger(name = 'NSDictionary_URLArguments_acknowledgement')
File "/Users/rmalik/dev/ios/Vendor/rules_pods/BazelExtensions/extensions.bzl", line 23, in _acknowledgement_merger_impl
ctx.actions.run_shell(inputs = concat, arguments = args, e...], ...])
parameter 'command' has no default value, for call to method run_shell(outputs, inputs = [], tools = unbound, arguments = [], mnemonic = None, command, progress_message = None, use_default_shell_env = False, env = None, execution_requirements = None, input_manifests = None) of 'actions'

Build top N Cocoapods with PodToBUILD/Bazel

As a stress test, we should have a way to build the top N Cocoapods with Bazel. Additionally, we should vet all changes against this list.

Consider, that a dependency of this is sorting out swift support #11.

hardcoded copts

some copts are hardcoded, e.g. NS_BLOCK_ASSERTIONS. It would be great to have a way to change them.

Fails to find cocoapod installation

Although I have cocoapods installed, I get the following error when trying to build:

Fatal error: RepoTools requires a cocoapod installation on host: file Sources/RepoToolsCore/RepoActions.swift, line 197

[React] Validate C++ default standard

In React, JSInspector requires C++ 14 standard. If this is the expected behavior in cocoapods for CppLike sources, then make sure to set this as the default value.

  name = "React",
  url = 'https://github.com/facebook/react-native/archive/v0.57.0.zip',
  user_options = [
    "jsinspector.copts += -std=c++14",
  ],

Fails to update Pod if repository is renamed

If the source repo for a pod changes names, attempting to update the pod throws a fatalError("Missing podspec ( \(podspecPath) )"). See here in RepoActions.swift. Not a huge issue, but it could become annoying. In the meantime, a temporary workaround is to manually update the source URL to the new repo name and path.

Should enforce the framework style import

Today, both import styles work when import framework headers:

#import "SomeFrameworkHeader.h"

#import <SomeFramework/SomeFrameworkHeader.h>

And ideally only the framework style import should be allowed.

Cannot rely on React Native pod from Swift

I want to prefix this by saying that I'm not super familiar with Swift/Objective-C compilation or Clang modules, so there may be some misconceptions/mistakes below; please feel free to point those out if you see them.

The issue

I'm attempting to rely on the React Native pod via a Swift file. This is causing React Native to be included as a module, and is trying to compile the React Native headers using modulemaps. It looks like the modulemaps generated for this pod are incorrect, both those generated by Bazel when generate_module_map = False and those generated by PodToBUILD when generate_module_map = True. Notably when generate_module_map = True it can't even compile the .m files in React Native (though that seems to be known already, as it is set to False in the "React" example).

A minimal example of this can be found here (which is a slight modification of the existing "React" example in this repo): https://github.com/FuegoFro/PodToBUILD/commit/b07429485557489482adc8c15ad8a3fe744210c0

The error I get when running make in that example is:

ERROR: .../PodToBUILD/Examples/React/BUILD:4:1: Compiling Swift module swift_lib failed (Exit 1)
Test.swift:1:2: error: expected an attribute name
@import Vendor_React_Core
 ^
.../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/React/Core.modulemaps/../../../../../../Vendor/React/pod_support/Headers/Public/yoga/RCTConvert.h:17:9: note: while building module 'Vendor_yoga_yoga' imported from .../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/React/Core.modulemaps/../../../../../../Vendor/React/pod_support/Headers/Public/yoga/RCTConvert.h:17:
#import <yoga/Yoga.h>
        ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../../../../../../Vendor/yoga/pod_support/Headers/Public/yoga/Utils.h"
        ^
.../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/Utils.h:9:10: note: in file included from .../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/Utils.h:9:
#include "YGNode.h"
         ^
.../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/YGNode.h:10:10: note: in file included from .../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/YGNode.h:10:
#include "YGLayout.h"
         ^
.../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/YGLayout.h:9:10: note: in file included from .../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/YGLayout.h:9:
#include "Yoga-internal.h"
         ^
.../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/yoga/yoga.modulemaps/../../../../../../Vendor/yoga/yoga/Yoga-internal.h:9:10: error: 'algorithm' file not found
#include <algorithm>
         ^
<module-includes>:8:9: note: in file included from <module-includes>:8:
#import "../../../../../../Vendor/React/React/Base/RCTConvert.h"
        ^
.../sandbox/darwin-sandbox/137/execroot/__main__/bazel-out/apl-ios_x86_64-fastbuild/genfiles/Vendor/React/Core.modulemaps/../../../../../../Vendor/React/pod_support/Headers/Public/yoga/RCTConvert.h:17:9: error: could not build module 'Vendor_yoga_yoga'
#import <yoga/Yoga.h>
        ^
Test.swift:1:9: error: could not build Objective-C module 'Vendor_React_Core'
@import Vendor_React_Core
        ^

It looks like in this particular instance it's missing requires cplusplus in the modulemap for Yoga. I've tried manually specifying a modulemap for the module that includes this and run into other issues that seem maybe related to including an overly-broad set of headers in the modulemap (#13).

I've also tried adding a bridging header and using "-import-objc-header" in the swift_library's copts, but this still tries to compile the pod as a module.

It's also unclear to me if this would be present if trying to use the React pod via an Objective-C module (eg something like @import Vendor_React_Core; in Objective-c). I wasn't able to test this since I couldn't figure out how to make that work - it couldn't find a module with that name, presumably because generate_module_map = False (and, as mentioned, other things break if that's switched to True).

Other similar issues I've found

#13
#58
bazelbuild/bazel#1870
bazelbuild/rules_apple#416
bazelbuild/rules_apple#240

Location of this issue

In the course of looking into this, it wasn't clear to me if this is something that can be fixed on the PodToBUILD side, or if this issue (and potential fix) would be better suited in one of https://github.com/bazelbuild/rules_swift, https://github.com/bazelbuild/rules_apple/ or https://github.com/bazelbuild/bazel. Would love some advice/guidance if you think this belongs somewhere else 🙂

I know that on the README for this repo it says that Swift likely won't work, but it seemed that this is more about how the Objective-C code is described, and not about compiling pods with Swift in them. However, I understand if this falls out of the scope of this repo/project.

Potential fixes

The main workaround that I've found that looks viable so far is to manually specify module.modulemap files for each module, though not all Pods follow semantics that work with modules (eg some have headers that rely on being imported by other headers in the library and don't, for instance, re-import Foundation on their own).

Another potential fix would likely lie on the https://github.com/bazelbuild/rules_swift side is to mimic what Xcode does in this scenario, which is to point at the header include paths rather than at auto-generated modulemaps.

I would love it if there's any other thoughts/potential fixes on this issue. Thank you ahead of time!

Producing Bitcode

Hi all,

It's totally possible I'm missing something, but I'm having trouble getting PodToBuild deps to compile with bitcode.

I'm passing --apple_bitcode=embedded --copt=-fembed-bitcode into the build, so all the other parts of the project are building bitcode. But the linker informs me that the PodToBuild-based deps were "built without full bitcode," causing the linker to error. It's a matter of "-fembed-bitcode-marker" rather than "-fembed-bitcode", I'm assuming, based on the "full bitcode" part of the warning.

Is building with bitcode indeed not work currently, or am I missing something? And if it is indeed missing, any chance I could ask you to consider adding it?

Thanks so much,
Chris

Edit: I should have noted:
The example I first ran into is GoogleToolboxForMac--which doesn't seem to do any bitcode disabling in their podspec.
This is with the latest release of PodToBuild.

resources not converted to globs

Resources don't seem to get converted into glob patterns. I get errors like this:

invalid label 'Source/**/*.{js,css}' in element 0 of attribute 'resources' in 'objc_library' rule: invalid target name 'Source/**/*.{js,css}': target names may not contain '*'

Add missing features in React 0.61.5

I'm hitting a few issues in attempting to build React 0.61.5 with PodToBUILD on the following archive:
'https://github.com/facebook/react-native/archive/v0.61.5.zip'

The following situations are occurring which make this tricky to handle

  • Aliasing doesn't alias all subspecs, only the top level one. This requires manually aliasing right now.
  • Header namespaces are mixed up for a child pod. For example, RCTText and RCTImage.
  • There is a convention of importing pods into the Podfile from a subspec? e.g. pod 'React-Core/DevSupport', :path => "#{prefix}/"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.