bazel-ios / rules_ios

Bazel rules for building iOS applications and frameworks
Apache License 2.0
276 stars 84 forks source link

Error `failed: error executing ObjcLink command` after update to Bazel 7 #869

Closed lucasromanomr closed 4 months ago

lucasromanomr commented 4 months ago

After updating the rules to support Bazel 7, I am no longer able to run the App or the App tests, I don't have any problems with modules, they are using testOnly and it doesn't run on a testHost, but the apps end up having problems.

I believe it has to be directly linked to #850, but I'm not sure. I also don't know what I could be seeing or having to configure to support Bazel 7

If you have a suggestion of what I could be doing, or something I didn't do

Showing All Messages
(09:33:09) ERROR: /Users/[REDACTED]/Projetos/ios/[REDACTED]/[REDACTED]/BUILD.bazel:85:16: Linking [REDACTED]/[REDACTED]_bin failed: (Exit 1): wrapped_clang failed: error executing ObjcLink command (from target //[REDACTED]:[REDACTED])
  (cd /private/var/tmp/_bazel_REDACTED]/3fb273394dca648b60229d6f0827235d/rules_xcodeproj.noindex/build_output_base/execroot/REDACT && \

  exec env - \
    APPLE_SDK_PLATFORM=iPhoneSimulator \
    APPLE_SDK_VERSION_OVERRIDE=17.4 \
    PATH=/bin:/usr/bin \
    RELATIVE_AST_PATH=true \
    XCODE_VERSION_OVERRIDE=15.3.0.15E204a \
    ZERO_AR_DATE=1 \
  external/local_config_apple_cc/wrapped_clang @bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min13.0-applebin_ios-ST-d04e18724a43/bin/[REDACTED]/[REDACTED]_bin-2.params)
luispadron commented 4 months ago

Can you provide some more details:

lucasromanomr commented 4 months ago

Can you provide some more details:

  • Does this happen using just bazel? I see your error is coming from rules_xcodeproj
  • What rules_xcodeproj version are you using?
  • What Bazel version are you using?

It happens both when running with rules_xcodeproj and when running normally through the terminal (bazel test //...) It also happens when I try to run the app

Bazel version: 7.1.0 rules_ios: 4.4.0 rules_xcodeproj: 2.2.0

luispadron commented 4 months ago

Hmm our project builds fine with those versions. There might be some issues in Bazel 7 with import_middleman do you know if that's used in your project at all?

lucasromanomr commented 4 months ago

Yes, it is enabled, I am using apple.arm64_simulator_use_device_deps.

However, looking a little more, I ended up missing a small part of the Log (a single line), and after running it more than once, I ended up seeing this single line.

It just happened that a cocoapods dependency had the wrong settings (I'm using cocoapods-bazel), when used the bazel settings were being declared wrong for the Pod, after fixing this, being able to compile the application and run the tests. (Something has changed for the better with this, as before there were no errors and now they are)

What happened was that in apple_framework an item was being passed in the sdk_frameworks list that does not exist, and this gave the error, saying that it was not possible to locate this dependency, by chance I had not seen this line that said that it had not been possible to link the dependency, because it was not an sdk_frameworks.

I'm sorry, I should have insisted a little more before opening the issue referencing the update.

luispadron commented 4 months ago

No worries! Thanks for following up and I'm glad it's working now.

I'd also look into removing the use of that arm device deps flag if possible. It'll make your builds simpler. You should be able to get rid of it if all your prebuilt dependencies define the correct simulator slices