rules_apple icon indicating copy to clipboard operation
rules_apple copied to clipboard

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

Open brentleyjones opened this issue 2 years ago • 0 comments

Here is an example Xcode generated Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>UIApplicationSceneManifest</key>
	<dict>
		<key>UIApplicationSupportsMultipleScenes</key>
		<false/>
		<key>UISceneConfigurations</key>
		<dict>
			<key>UIWindowSceneSessionRoleApplication</key>
			<array>
				<dict>
					<key>UISceneConfigurationName</key>
					<string>Default Configuration</string>
					<key>UISceneDelegateClassName</key>
					<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
					<key>UISceneStoryboardFile</key>
					<string>Main</string>
				</dict>
			</array>
		</dict>
	</dict>
</dict>
</plist>

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.

brentleyjones avatar Jan 27 '22 16:01 brentleyjones