Skip to content

Commit 5a4fcb9

Browse files
committed
Adds ExtensionKit support
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]>
1 parent 8f527c9 commit 5a4fcb9

File tree

5 files changed

+94
-1
lines changed

5 files changed

+94
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
load("@build_bazel_rules_apple//apple:apple.bzl", "local_provisioning_profile")
2+
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_extension")
3+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
4+
load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcode_provisioning_profile")
5+
load(
6+
"//:xcodeproj_targets.bzl",
7+
"IOS_BUNDLE_ID",
8+
"TEAMID",
9+
)
10+
11+
config_setting(
12+
name = "device_build",
13+
values = {
14+
"cpu": "ios_arm64",
15+
},
16+
)
17+
18+
ios_extension(
19+
name = "ExtensionKitExtension",
20+
bundle_id = "{}.extensionkit-extension".format(IOS_BUNDLE_ID),
21+
extensionkit_extension = True,
22+
families = ["iphone"],
23+
infoplists = [":Info.plist"],
24+
minimum_os_version = "15.0",
25+
provisioning_profile = select({
26+
":device_build": ":xcode_profile",
27+
"//conditions:default": None,
28+
}),
29+
version = "//iOSApp:Version",
30+
visibility = ["//iOSApp:__subpackages__"],
31+
deps = [
32+
"ExtensionKitExtension.library",
33+
],
34+
)
35+
36+
xcode_provisioning_profile(
37+
name = "xcode_profile",
38+
managed_by_xcode = True,
39+
provisioning_profile = ":xcode_managed_profile",
40+
tags = ["manual"],
41+
)
42+
43+
local_provisioning_profile(
44+
name = "xcode_managed_profile",
45+
profile_name = "iOS Team Provisioning Profile: {}.extensionkit-extension".format(IOS_BUNDLE_ID),
46+
tags = ["manual"],
47+
team_id = TEAMID,
48+
)
49+
50+
swift_library(
51+
name = "ExtensionKitExtension.library",
52+
srcs = glob(["**/*.swift"]),
53+
module_name = "ExtensionKitExtension",
54+
tags = ["manual"],
55+
visibility = ["//:__subpackages__"],
56+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleName</key>
6+
<string>$(PRODUCT_NAME)</string>
7+
<key>CFBundleVersion</key>
8+
<string>1.0</string>
9+
<key>CFBundleShortVersionString</key>
10+
<string>1.0</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundlePackageType</key>
14+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
15+
<key>EXAppExtensionAttributes</key>
16+
<dict>
17+
<key>EXExtensionPointIdentifier</key>
18+
<string>com.apple.generic-extension</string>
19+
</dict>
20+
</dict>
21+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Foundation
2+
3+
public class main {
4+
public init() {}
5+
public func main() { print("Hello world") }
6+
}

examples/integration/iOSApp/Source/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ ios_application(
5252
":device_build": None,
5353
"//conditions:default": "iOSApp_ExecutableName",
5454
}),
55-
extensions = ["//WidgetExtension"],
55+
extensions = [
56+
"//ExtensionKitExtension",
57+
"//WidgetExtension",
58+
],
5659
families = ["iphone"],
5760
frameworks = [
5861
"//iOSApp/Source/CoreUtilsObjC:FrameworkCoreUtilsObjC",

tools/extension_point_identifiers_parser/extension_point_identifiers_parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ def _main(
2828
extension_point_identifier = (
2929
plist.get("NSExtension", {}).get("NSExtensionPointIdentifier")
3030
)
31+
32+
# Supports ExtensionKit
33+
if not extension_point_identifier:
34+
extension_point_identifier = (
35+
plist.get("EXAppExtensionAttributes", {}).get("EXExtensionPointIdentifier")
36+
)
37+
3138
if not extension_point_identifier:
3239
continue
3340

0 commit comments

Comments
 (0)