Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/multiplatform/AppClip/AppClip.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SwiftUI

@main
struct AppClip: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
106 changes: 106 additions & 0 deletions examples/multiplatform/AppClip/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
load("@build_bazel_rules_apple//apple:apple.bzl", "local_provisioning_profile")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_app_clip")
load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_group")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load(
"@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:experimental.bzl",
"xcode_provisioning_profile",
)
load(
"//examples/multiplatform:xcodeproj_targets.bzl",
"APP_CLIP_BUNDLE_ID",
"IOS_BUNDLE_ID",
"TEAMID",
)

config_setting(
name = "release_build",
values = {
"compilation_mode": "opt",
},
)

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

ios_app_clip(
name = "AppClip",
app_icons = glob(["Assets.xcassets/AppIcon.appiconset/**"]),
bundle_id = APP_CLIP_BUNDLE_ID,
bundle_name = "AppClip",
entitlements = ":entitlements",
families = ["iphone"],
infoplists = [":Info.plist"],
minimum_os_version = "15.0",
provisioning_profile = select({
":device_build": ":xcode_profile",
"//conditions:default": None,
}),
resources = [":ResourceGroup"],
version = "//examples/multiplatform/iOSApp:Version",
visibility = ["//visibility:public"],
deps = [":AppClip.library"],
)

genrule(
name = "entitlements",
srcs = ["Entitlements.entitlements"],
outs = ["Entitlements.withbundleid.plist"],
cmd = """
sed \
-e 's/APP_CLIP_BUNDLE_ID/{}/g' \
-e 's/IOS_BUNDLE_ID/{}/g' \
-e 's/TEAMID/{}/g' $< > $@
""".format(
APP_CLIP_BUNDLE_ID,
IOS_BUNDLE_ID,
TEAMID,
),
)

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: {}".format(APP_CLIP_BUNDLE_ID),
tags = ["manual"],
team_id = TEAMID,
)

apple_resource_group(
name = "ResourceGroup",
resources = glob(
[
"Assets.xcassets/**",
],
exclude = ["Assets.xcassets/AppIcon.appiconset/**"],
),
)

swift_library(
name = "AppClip.library",
srcs = glob(["**/*.swift"]),
data = select({
":release_build": [],
"//conditions:default": [":PreviewContent"],
}),
module_name = "AppClip",
tags = ["manual"],
deps = [
"//examples/multiplatform/Lib",
],
)

filegroup(
name = "PreviewContent",
srcs = glob(["PreviewContent/**"]),
)
15 changes: 15 additions & 0 deletions examples/multiplatform/AppClip/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Lib
import SwiftUI

struct ContentView: View {
var body: some View {
Text(greeting)
.padding()
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
12 changes: 12 additions & 0 deletions examples/multiplatform/AppClip/Entitlements.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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>application-identifier</key>
<string>TEAMID.APP_CLIP_BUNDLE_ID</string>
Comment on lines +5 to +6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to set this for BwB, but not BwX, continues to stump me. Ideally rules_apple would handle that, but then you would have to know info from your parent app, which is tricky. Maybe even just failing to build if it's not defined...

Copy link
Contributor

@BalestraPatrick BalestraPatrick Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this. We have a macro/rule that works around this annoying issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<key>com.apple.developer.parent-application-identifiers</key>
<array>
<string>TEAMID.IOS_BUNDLE_ID</string>
</array>
</dict>
</plist>
16 changes: 16 additions & 0 deletions examples/multiplatform/AppClip/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
1 change: 1 addition & 0 deletions examples/multiplatform/iOSApp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ apple_bundle_version(

ios_application(
name = "iOSApp",
app_clips = ["//examples/multiplatform/AppClip"],
app_icons = glob(["Assets.xcassets/AppIcon.appiconset/**"]),
bundle_id = IOS_BUNDLE_ID,
bundle_name = "iOSApp",
Expand Down
3 changes: 2 additions & 1 deletion examples/multiplatform/xcodeproj_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ XCODEPROJ_TARGETS = [
"//examples/multiplatform/Tool",
]

IOS_BUNDLE_ID = "io.buildbuddy.example"
TEAMID = "V82V4GQZXM"

IOS_BUNDLE_ID = "io.buildbuddy.example"
APP_CLIP_BUNDLE_ID = "{}.app-clip".format(IOS_BUNDLE_ID)
IMESSAGE_APP_BUNDLE_ID = "{}.imessage-app".format(IOS_BUNDLE_ID)
TVOS_BUNDLE_ID = IOS_BUNDLE_ID
WATCHOS_BUNDLE_ID = "{}.watch".format(IOS_BUNDLE_ID)
Loading