Skip to content

Commit 957a336

Browse files
Add App Clip example (#732)
1 parent e5d9b4b commit 957a336

File tree

27 files changed

+2023
-7
lines changed

27 files changed

+2023
-7
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SwiftUI
2+
3+
@main
4+
struct AppClip: App {
5+
var body: some Scene {
6+
WindowGroup {
7+
ContentView()
8+
}
9+
}
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
}
93+
],
94+
"info" : {
95+
"author" : "xcode",
96+
"version" : 1
97+
}
98+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

examples/multiplatform/AppClip/BUILD

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
load("@build_bazel_rules_apple//apple:apple.bzl", "local_provisioning_profile")
2+
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_app_clip")
3+
load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_group")
4+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
5+
load(
6+
"@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:experimental.bzl",
7+
"xcode_provisioning_profile",
8+
)
9+
load(
10+
"//examples/multiplatform:xcodeproj_targets.bzl",
11+
"APP_CLIP_BUNDLE_ID",
12+
"IOS_BUNDLE_ID",
13+
"TEAMID",
14+
)
15+
16+
config_setting(
17+
name = "release_build",
18+
values = {
19+
"compilation_mode": "opt",
20+
},
21+
)
22+
23+
config_setting(
24+
name = "device_build",
25+
values = {
26+
"cpu": "ios_arm64",
27+
},
28+
)
29+
30+
ios_app_clip(
31+
name = "AppClip",
32+
app_icons = glob(["Assets.xcassets/AppIcon.appiconset/**"]),
33+
bundle_id = APP_CLIP_BUNDLE_ID,
34+
bundle_name = "AppClip",
35+
entitlements = ":entitlements",
36+
families = ["iphone"],
37+
infoplists = [":Info.plist"],
38+
minimum_os_version = "15.0",
39+
provisioning_profile = select({
40+
":device_build": ":xcode_profile",
41+
"//conditions:default": None,
42+
}),
43+
resources = [":ResourceGroup"],
44+
version = "//examples/multiplatform/iOSApp:Version",
45+
visibility = ["//visibility:public"],
46+
deps = [":AppClip.library"],
47+
)
48+
49+
genrule(
50+
name = "entitlements",
51+
srcs = ["Entitlements.entitlements"],
52+
outs = ["Entitlements.withbundleid.plist"],
53+
cmd = """
54+
sed \
55+
-e 's/APP_CLIP_BUNDLE_ID/{}/g' \
56+
-e 's/IOS_BUNDLE_ID/{}/g' \
57+
-e 's/TEAMID/{}/g' $< > $@
58+
""".format(
59+
APP_CLIP_BUNDLE_ID,
60+
IOS_BUNDLE_ID,
61+
TEAMID,
62+
),
63+
)
64+
65+
xcode_provisioning_profile(
66+
name = "xcode_profile",
67+
managed_by_xcode = True,
68+
provisioning_profile = ":xcode_managed_profile",
69+
tags = ["manual"],
70+
)
71+
72+
local_provisioning_profile(
73+
name = "xcode_managed_profile",
74+
profile_name = "iOS Team Provisioning Profile: {}".format(APP_CLIP_BUNDLE_ID),
75+
tags = ["manual"],
76+
team_id = TEAMID,
77+
)
78+
79+
apple_resource_group(
80+
name = "ResourceGroup",
81+
resources = glob(
82+
[
83+
"Assets.xcassets/**",
84+
],
85+
exclude = ["Assets.xcassets/AppIcon.appiconset/**"],
86+
),
87+
)
88+
89+
swift_library(
90+
name = "AppClip.library",
91+
srcs = glob(["**/*.swift"]),
92+
data = select({
93+
":release_build": [],
94+
"//conditions:default": [":PreviewContent"],
95+
}),
96+
module_name = "AppClip",
97+
tags = ["manual"],
98+
deps = [
99+
"//examples/multiplatform/Lib",
100+
],
101+
)
102+
103+
filegroup(
104+
name = "PreviewContent",
105+
srcs = glob(["PreviewContent/**"]),
106+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Lib
2+
import SwiftUI
3+
4+
struct ContentView: View {
5+
var body: some View {
6+
Text(greeting)
7+
.padding()
8+
}
9+
}
10+
11+
struct ContentView_Previews: PreviewProvider {
12+
static var previews: some View {
13+
ContentView()
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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>application-identifier</key>
6+
<string>TEAMID.APP_CLIP_BUNDLE_ID</string>
7+
<key>com.apple.developer.parent-application-identifiers</key>
8+
<array>
9+
<string>TEAMID.IOS_BUNDLE_ID</string>
10+
</array>
11+
</dict>
12+
</plist>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
</dict>
16+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

examples/multiplatform/iOSApp/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ apple_bundle_version(
3636

3737
ios_application(
3838
name = "iOSApp",
39+
app_clips = ["//examples/multiplatform/AppClip"],
3940
app_icons = glob(["Assets.xcassets/AppIcon.appiconset/**"]),
4041
bundle_id = IOS_BUNDLE_ID,
4142
bundle_name = "iOSApp",

0 commit comments

Comments
 (0)