bazelbuild / bazelbuild/rules_apple

`CompileRootInfoPlist` doesn't work with generated Xcode `Info.plist`

Open
#1,337 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
593
Forks
334
Avg merge
16h 48m
Merged PRs (30d)
9

Description

Here is an example Xcode generated Info.plist:
```xml

UIApplicationSceneManifest

UIApplicationSupportsMultipleScenes

UISceneConfigurations

UIWindowSceneSessionRoleApplication


UISceneConfigurationName
Default Configuration
UISceneDelegateClassName
$(PRODUCT_MODULE_NAME).SceneDelegate
UISceneStoryboardFile
Main



```

and here is the build failure when using it:
```
ERROR: /Users/brentley/Developer/example/BUILD:13:16: CompileRootInfoPlist example/Info.plist failed: (Exit 1): plisttool failed: error executing command
(cd /private/var/tmp/_bazel_brentley/3d5821071b04bd5519a8cc5bb33889a1/sandbox/darwin-sandbox/205/execroot/__main__ && \
exec env - \
APPLE_SDK_PLATFORM=iPhoneSimulator \
APPLE_SDK_VERSION_OVERRIDE=15.2 \
XCODE_VERSION_OVERRIDE=13.2.1.13C100 \
bazel-out/darwin_arm64-opt-exec-2B5CBBC6-ST-dedf359489b7/bin/external/build_bazel_rules_apple/tools/plisttool/plisttool bazel-out/applebin_ios-ios_sim_arm64-fastbuild-ST-fb8a95a965e6/bin/example/example-intermediates/Info.plist-root-control)
# Configuration: 4aa8757cb3e86646762b046bc13401f40bf241d343873dc5bd849800b5b84396
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox
ERROR: In target "//example: example"; unknown variable reference "$(PRODUCT_MODULE_NAME)" while merging plists (key: "UIApplicationSceneManifest:UISceneConfigurations:UIWindowSceneSessionRoleApplication[0]:UISceneDelegateClassName", value: "$(PRODUCT_MODULE_NAME).SceneDelegate").
Target //example: example failed to build
```

Ideally, to ease migration to Bazel, we should support Info.plists that Xcode creates. This was also reported in https://github.com/bazelbuild/rules_apple/issues/1016. I necessarily agree with the reasoning provided in `Variables Explicitly Not Supported`, in particular this:
> When using Bazel to build ..., through objc_library and/or swift_library, each of the targets defines a new module, which makes it harder to automatically detect the module name which contains the principal class

I think we should try harder to determine the default here.

---

After addressing that error, it complains of a missing `CFBundleVersion` and `CFBundleShortVersionString`. Those are no longer required when using `-exportOptionsPlist`/`manageAppVersionAndBuildNumber`.

Contributor guide

Open the contributing guide

Research direction

Start by locating the CompileRootInfoPlist rule and the plisttool entry point, then read the “Variables Explicitly Not Supported” guidance and reproduce the failure with the supplied generated Info.plist. Done means generated Xcode plists no longer fail on PRODUCT_MODULE_NAME and the reported missing version keys are handled as described.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.