diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml index 171bd92cd..0f751fdde 100644 --- a/.github/workflows/ios-ci.yml +++ b/.github/workflows/ios-ci.yml @@ -95,10 +95,6 @@ jobs: - name: npm install run: npm ci --ignore-scripts - - - name: Generate app plists - working-directory: ./ - run: bash platform/ios/scripts/bazel-generate-plists.sh - run: cp bazel/example_config.bzl bazel/config.bzl diff --git a/platform/BUILD.bazel b/platform/BUILD.bazel index a467439a2..7f77fff1c 100644 --- a/platform/BUILD.bazel +++ b/platform/BUILD.bazel @@ -123,9 +123,7 @@ objc_library( "//platform/ios:ios_sdk_hdrs", ] + select({ "//:metal_renderer": [], - "//conditions:default": [ - "//platform/darwin:darwin_objc_opengl_hdrs", - ], + "//conditions:default": [], }), data = ["//platform/ios:resources"], module_name = "MapLibre", @@ -242,8 +240,6 @@ sh_binary( ] + select({ "//:metal_renderer": [], "//conditions:default": [ - "//platform/darwin:darwin_private_opengl_hdrs", - "//platform/darwin:darwin_objc_opengl_hdrs", "//platform/darwin:darwin_objcpp_opengl_srcs", ], }), diff --git a/platform/darwin/BUILD.bazel b/platform/darwin/BUILD.bazel index 03fda5a8d..08f809b56 100644 --- a/platform/darwin/BUILD.bazel +++ b/platform/darwin/BUILD.bazel @@ -3,9 +3,7 @@ load( "bazel/files.bzl", "MLN_DARWIN_OBJCPP_HEADERS", "MLN_DARWIN_OBJC_HEADERS", - "MLN_DARWIN_OBJC_OPENGL_HEADERS", "MLN_DARWIN_PRIVATE_HEADERS", - "MLN_DARWIN_PRIVATE_OPENGL_HEADERS", "MLN_DARWIN_PUBLIC_OBJCPP_SOURCE", "MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE", "MLN_DARWIN_PUBLIC_OBJC_SOURCE", @@ -24,22 +22,12 @@ filegroup( srcs = MLN_DARWIN_PRIVATE_HEADERS, visibility = ["//visibility:public"], ) -filegroup( - name = "darwin_private_opengl_hdrs", - srcs = MLN_DARWIN_PRIVATE_OPENGL_HEADERS, - visibility = ["//visibility:public"], -) filegroup( name = "darwin_objc_hdrs", srcs = MLN_DARWIN_OBJC_HEADERS, visibility = ["//visibility:public"], ) -filegroup( - name = "darwin_objc_opengl_hdrs", - srcs = MLN_DARWIN_OBJC_OPENGL_HEADERS, - visibility = ["//visibility:public"], -) filegroup( name = "darwin_objcpp_hdrs", @@ -342,8 +330,6 @@ exports_files( MLN_DARWIN_PUBLIC_OBJCPP_SOURCE + MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE + MLN_DARWIN_PRIVATE_HEADERS + - MLN_DARWIN_PRIVATE_OPENGL_HEADERS + MLN_DARWIN_OBJC_HEADERS + - MLN_DARWIN_OBJC_OPENGL_HEADERS + MLN_DARWIN_OBJCPP_HEADERS, ) diff --git a/platform/darwin/bazel/files.bzl b/platform/darwin/bazel/files.bzl index 27ad8c90d..9932ab5ac 100644 --- a/platform/darwin/bazel/files.bzl +++ b/platform/darwin/bazel/files.bzl @@ -100,8 +100,6 @@ MLN_DARWIN_OBJC_HEADERS = [ "src/NSPredicate+MLNAdditions.h", "src/NSValue+MLNAdditions.h", ] -MLN_DARWIN_OBJC_OPENGL_HEADERS = [ -] MLN_DARWIN_OBJCPP_HEADERS = [ "src/MLNConversion.h", @@ -156,8 +154,6 @@ MLN_DARWIN_PRIVATE_HEADERS = [ "src/NSExpression+MLNPrivateAdditions.h", "src/NSPredicate+MLNPrivateAdditions.h", ] -MLN_DARWIN_PRIVATE_OPENGL_HEADERS = [ -] MLN_DARWIN_PUBLIC_OBJCPP_SOURCE = [ "src/MLNAttributionInfo.mm", diff --git a/platform/ios/BUILD.bazel b/platform/ios/BUILD.bazel index c21665e69..5332440c5 100644 --- a/platform/ios/BUILD.bazel +++ b/platform/ios/BUILD.bazel @@ -63,9 +63,27 @@ filegroup( visibility = ["//visibility:public"], ) +info_plist( + name = "info_plist", + out = "Info.plist", + base_info_plist = "framework/Info.plist", +) + +info_plist( + name = "info_static_plist", + out = "Info-static.plist", + base_info_plist = "framework/Info-static.plist", +) + +info_plist( + name = "info_app_plist", + out = "Info-app.plist", + base_info_plist = "app/Info.plist", +) + apple_static_xcframework( - name = "Mapbox.static", - bundle_name = "Mapbox", + name = "MapLibre.static", + bundle_name = "MapLibre", ios = { "simulator": [ "x86_64", @@ -81,28 +99,13 @@ apple_static_xcframework( "//platform/darwin:darwin_objcpp_hdrs", ] + select({ "//:metal_renderer": [], - "//conditions:default": [ - "//platform/darwin:darwin_objc_opengl_hdrs", - "//platform/darwin:darwin_objcpp_opengl_hdrs" - ], + "//conditions:default": [], }), umbrella_header = "src/Mapbox.h", visibility = ["//visibility:public"], deps = ["//platform:ios-sdk"], ) -info_plist( - name = "info_plist", - out = "Info.plist", - base_info_plist = "framework/Info.plist", -) - -info_plist( - name = "info_static_plist", - out = "Info-static.plist", - base_info_plist = "framework/Info-static.plist", -) - apple_xcframework( name = "MapLibre.dynamic", bundle_id = "com.maplibre.mapbox", @@ -127,10 +130,7 @@ apple_xcframework( "//platform/darwin:darwin_objcpp_hdrs", ] + select({ "//:metal_renderer": [], - "//conditions:default": [ - "//platform/darwin:darwin_objc_opengl_hdrs", - "//platform/darwin:darwin_objcpp_opengl_hdrs" - ], + "//conditions:default": [], }), umbrella_header = "src/Mapbox.h", visibility = ["//visibility:public"], @@ -183,7 +183,7 @@ ios_application( "iphone", "ipad", ], - infoplists = ["build/Info-app.plist"], + infoplists = ["info_app_plist"], minimum_os_version = "12.0", provisioning_profile = "xcode_profile", resources = _IOS_APPLICATION_RESOURCES, @@ -220,7 +220,7 @@ ios_application( "iphone", "ipad", ], - infoplists = ["build/Info-benchmark.plist"], + infoplists = ["//platform/ios/benchmark:info_benchmark_plist"], minimum_os_version = "12.0", provisioning_profile = "xcode_profile", resources = ["//platform/ios/benchmark:bundle_resources"], diff --git a/platform/ios/bazel/example_config.bzl b/platform/ios/bazel/example_config.bzl index e61a9bafc..3c406f9ea 100644 --- a/platform/ios/bazel/example_config.bzl +++ b/platform/ios/bazel/example_config.bzl @@ -1,3 +1,4 @@ +# Find your team ID inside a .mobileprovision file or in your keychain (Apple development: your@email -> Get Info -> Organizational Unit) APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "TC45MCF93C" APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *" BUNDLE_ID_PREFIX = "com.firstnamelastname" @@ -6,3 +7,8 @@ BUNDLE_ID_PREFIX = "com.firstnamelastname" # not finding a provisioning profile when building. # https://github.com/MobileNativeFoundation/rules_xcodeproj/blob/main/docs/bazel.md#xcodeproj-build_mode BUILD_MODE = "bazel" + +# Enter your API key for MapTiler here, if you have one. +API_KEY = "0000000000" +# Semantic version number to include in plist files. +SEM_VER = "0.0.0" \ No newline at end of file diff --git a/platform/ios/bazel/macros.bzl b/platform/ios/bazel/macros.bzl index 4ee50978d..fc5dfdb9e 100644 --- a/platform/ios/bazel/macros.bzl +++ b/platform/ios/bazel/macros.bzl @@ -1,3 +1,5 @@ +load("//platform/ios/bazel:config.bzl", "API_KEY", "SEM_VER") + def info_plist(name, base_info_plist, out, **kwargs): native.genrule( name = name, @@ -8,13 +10,14 @@ def info_plist(name, base_info_plist, out, **kwargs): outs = [ out, ], - cmd = """ + cmd = (""" cp $(location {}) $@ plutil -replace MLNCommitHash -string $$(cat $(location //:git_hash)) $@ - # TODO: move to file - sem_version=0.0.0 + sem_version=\"""" + SEM_VER + """\" + token=\"""" + API_KEY + """\" plutil -replace MLNSemanticVersionString -string $$sem_version $@ - """.format(base_info_plist), + plutil -replace MLNApiKey -string $$token $@ + """).format(base_info_plist), **kwargs ) diff --git a/platform/ios/benchmark/BUILD.bazel b/platform/ios/benchmark/BUILD.bazel index f6cb42192..5094e7566 100644 --- a/platform/ios/benchmark/BUILD.bazel +++ b/platform/ios/benchmark/BUILD.bazel @@ -1,3 +1,5 @@ +load("//platform/ios/bazel:macros.bzl", "info_plist") + filegroup( name = "ios_benchmark_srcs", srcs = [ @@ -31,6 +33,11 @@ filegroup( visibility = ["//platform/ios:__pkg__"], ) -exports_files([ - "Info.plist", -]) \ No newline at end of file +info_plist( + name = "info_benchmark_plist", + out = "Info-benchmark.plist", + base_info_plist = "Info.plist", + visibility = ["//platform/ios:__pkg__"], +) + +exports_files(["Info.plist"]) diff --git a/platform/ios/scripts/bazel-generate-plists.sh b/platform/ios/scripts/bazel-generate-plists.sh deleted file mode 100755 index c154dee38..000000000 --- a/platform/ios/scripts/bazel-generate-plists.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -echo "Generating plist files..." - -sem_version="0.0.0" -hash="" -teamid="0000000000" # Provisioning profile team ID, required for targeting physical devices -bundleidprefix="org.maplibre.app" # bundle id prefix - -while [[ $# -gt 0 ]]; do - case $1 in - --sem-ver) - shift - sem_version="$1" - shift - ;; - --hash) - shift - hash="$1" - shift - ;; - --token) - shift - token="$1" - shift - ;; - --team-id) - shift - teamid="$1" - shift - ;; - --bundleidprefix) - shift - bundleidprefix="$1" - shift - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - esac -done - -# Move and configure the info plists with the semantic version and hash. -temp_info_static_plist="platform/ios/build/Info-static.plist" -temp_info_plist="platform/ios/build/Info.plist" -# Move and configure the app plist -temp_app_info_plist="platform/ios/build/Info-app.plist" -# Move and configure the BenchmarkApp plist -temp_benchmark_info_plist="platform/ios/build/Info-benchmark.plist" - -if [ ! -d platform/ios/build ]; then - mkdir platform/ios/build -fi - -cp platform/ios/framework/Info-static.plist "$temp_info_static_plist" -cp platform/ios/framework/Info.plist "$temp_info_plist" -cp platform/ios/app/Info.plist "$temp_app_info_plist" -cp platform/ios/benchmark/Info.plist "$temp_benchmark_info_plist" - -# Replace semver and hash -plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_static_plist" -plutil -replace MLNCommitHash -string "$hash" "$temp_info_static_plist" -plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_plist" -plutil -replace MLNCommitHash -string "$hash" "$temp_info_plist" - -# Insert API Key -echo "Inserting MapLibre API key..." -if [ "$token" ]; then - plutil -replace MLNApiKey -string $token "$temp_app_info_plist" - plutil -replace MLNApiKey -string $token "$temp_benchmark_info_plist" - echo "API key insertion successful" -else - echo "Warning: Missing API key." -fi - -# Generate the team ID for Xcode device provisioning -echo "Updating bazel/config.bzl..." -cat > platform/ios/bazel/config.bzl < Get Info -> Organizational Unit) +# Example invocation: bazel-xcodeproj.sh flavor split bazel run //platform/ios:xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags="--//:renderer=$flavor --//:maplibre_platform=ios" diff --git a/platform/ios/test/BUILD.bazel b/platform/ios/test/BUILD.bazel index 9667794d5..a29bf7461 100644 --- a/platform/ios/test/BUILD.bazel +++ b/platform/ios/test/BUILD.bazel @@ -68,7 +68,6 @@ ios_unit_test( "//platform/darwin:shared_tests_swift_srcs", "//platform/darwin:darwin_objc_hdrs", "//platform/darwin:darwin_objcpp_hdrs", - "//platform/darwin:darwin_objc_opengl_hdrs", ], )