Skip to content

Commit

Permalink
Add ExtensionKit support
Browse files Browse the repository at this point in the history
ExtensionKit extensions uses EXAppExtensionAttributes in its info.plist. extension_point_identifiers_parser.py didn't support that so that it fails to find the ExtensionKit extensions.
Also adds an ExtensionKit extension to the example iOSAPP.

Signed-off-by: Cong Shi <[email protected]>
  • Loading branch information
congt committed Nov 15, 2024
1 parent 8f527c9 commit e9fe324
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 1 deletion.
56 changes: 56 additions & 0 deletions examples/integration/ExtensionKitExtension/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
load("@build_bazel_rules_apple//apple:apple.bzl", "local_provisioning_profile")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_extension")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcode_provisioning_profile")
load(
"//:xcodeproj_targets.bzl",
"IOS_BUNDLE_ID",
"TEAMID",
)

config_setting(
name = "device_build",
values = {
"cpu": "ios_arm64",
},
)

ios_extension(
name = "ExtensionKitExtension",
bundle_id = "{}.extensionkit-extension".format(IOS_BUNDLE_ID),
extensionkit_extension = True,
families = ["iphone"],
infoplists = [":Info.plist"],
minimum_os_version = "15.0",
provisioning_profile = select({
":device_build": ":xcode_profile",
"//conditions:default": None,
}),
version = "//iOSApp:Version",
visibility = ["//iOSApp:__subpackages__"],
deps = [
"ExtensionKitExtension.library",
],
)

xcode_provisioning_profile(
name = "xcode_profile",
managed_by_xcode = True,
provisioning_profile = ":xcode_managed_profile",
tags = ["manual"],
)

local_provisioning_profile(
name = "xcode_managed_profile",
profile_name = "iOS Team Provisioning Profile: {}.extensionkit-extension".format(IOS_BUNDLE_ID),
tags = ["manual"],
team_id = TEAMID,
)

swift_library(
name = "ExtensionKitExtension.library",
srcs = glob(["**/*.swift"]),
module_name = "ExtensionKitExtension",
tags = ["manual"],
visibility = ["//:__subpackages__"],
)
21 changes: 21 additions & 0 deletions examples/integration/ExtensionKitExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>EXAppExtensionAttributes</key>
<dict>
<key>EXExtensionPointIdentifier</key>
<string>com.apple.generic-extension</string>
</dict>
</dict>
</plist>
6 changes: 6 additions & 0 deletions examples/integration/ExtensionKitExtension/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public class main {
public init() {}
public func main() { print("Hello world") }
}
5 changes: 4 additions & 1 deletion examples/integration/iOSApp/Source/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ ios_application(
":device_build": None,
"//conditions:default": "iOSApp_ExecutableName",
}),
extensions = ["//WidgetExtension"],
extensions = [
"//ExtensionKitExtension",
"//WidgetExtension",
],
families = ["iphone"],
frameworks = [
"//iOSApp/Source/CoreUtilsObjC:FrameworkCoreUtilsObjC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def _main(
extension_point_identifier = (
plist.get("NSExtension", {}).get("NSExtensionPointIdentifier")
)

# Supports ExtensionKit
if not extension_point_identifier:
extension_point_identifier = (
plist.get("EXAppExtensionAttributes", {}).get("EXExtensionPointIdentifier")
)

if not extension_point_identifier:
continue

Expand Down

0 comments on commit e9fe324

Please sign in to comment.