diff --git a/platform/ios/BUILD.bazel b/platform/ios/BUILD.bazel
index ca8becfee..ef926f00d 100644
--- a/platform/ios/BUILD.bazel
+++ b/platform/ios/BUILD.bazel
@@ -9,7 +9,7 @@ load(
"xcodeproj",
)
load("bazel/macros.bzl", "info_plist")
-load("bazel/config.bzl", "APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID")
+load("bazel/config.bzl", "APPLE_MOBILE_PROVISIONING_PROFILE_NAME", "APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID", "BUNDLE_ID_PREFIX")
# This list of public headers is from what Mapbox vendors with their dynamic framework
# If we forget one the build will fail, and if we add too many there will be a warning
@@ -456,7 +456,7 @@ _IOS_APPLICATION_RESOURCES = [
ios_application(
name = "App",
- bundle_id = "com.maplibre.app",
+ bundle_id = "{}.maplibre.app".format(BUNDLE_ID_PREFIX),
families = [
"iphone",
"ipad",
@@ -508,7 +508,7 @@ genrule(
local_provisioning_profile(
name = "provisioning_profile",
- profile_name = "iOS Team Provisioning Profile: *",
+ profile_name = APPLE_MOBILE_PROVISIONING_PROFILE_NAME,
team_id = APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID,
)
diff --git a/platform/ios/bazel/example_config.bzl b/platform/ios/bazel/example_config.bzl
index 54da9a270..533bdae5d 100644
--- a/platform/ios/bazel/example_config.bzl
+++ b/platform/ios/bazel/example_config.bzl
@@ -1 +1,3 @@
APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "TC45MCF93C"
+APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *"
+BUNDLE_ID_PREFIX = "com.firstnamelastname"
diff --git a/platform/ios/platform/ios/README.md b/platform/ios/platform/ios/README.md
index 2b93e3395..3d48afd73 100644
--- a/platform/ios/platform/ios/README.md
+++ b/platform/ios/platform/ios/README.md
@@ -14,6 +14,49 @@ MapLibre Native for iOS is distributed using the [Swift Package Index](https://s
3. Choose "Next". Xcode should clone the distribution repository and download the binaries.
+4. To create a minimal app, update `ContentView.swift` (which should have been automatically created when you initalized the new XCode project) with the following contents:
+
+```swift
+import SwiftUI
+import Mapbox
+
+struct ContentView: View {
+ var body: some View {
+ MapView().edgesIgnoringSafeArea(.all)
+ }
+}
+
+struct ContentView_Previews: PreviewProvider {
+ static var previews: some View {
+ ContentView()
+ }
+}
+
+struct MapView: UIViewRepresentable {
+ func makeUIView(context: Context) -> MGLMapView {
+ // Build the style URL
+ let styleURL = URL(string: "https://demotiles.maplibre.org/style.json")
+
+ // Create the map view
+ let mapView = MGLMapView(frame: .zero, styleURL: styleURL)
+
+ mapView.logoView.isHidden = true
+
+ mapView.setCenter(
+ CLLocationCoordinate2D(
+ latitude: 23.16, longitude: -109.50), animated: false)
+
+ mapView.setZoomLevel(4, animated: false)
+ return mapView
+
+ }
+
+ func updateUIView(_ mapView: MGLMapView, context: Context) {
+ // Update the view if needed
+ }
+}
+```
+
There is a an open bounty to extend this Getting Started guide ([#809](https://github.com/maplibre/maplibre-native/issues/809)). In the meantime, refer to one of these external guides:
- [Get Started with MapLibre Native for iOS using SwiftUI](https://docs.maptiler.com/maplibre-gl-native-ios/ios-swiftui-basic-get-started/)
@@ -21,19 +64,28 @@ There is a an open bounty to extend this Getting Started guide ([#809](https://g
## Developing
-### CMake
+The following are instructions on how to build MapLibre Native for development purposes.
-The main build tool generator supported by MapLibre Native is CMake. There is a `Makefile` which calls CMake and `xcodebuild` under the hood to complete various development tasks, including building with various kinds of configurations and running tests. This `Makefile` can also can set up an Xcode project for MapLibre Native development by copying a `.xcodeproj` file part of the source tree and combining that with the output of CMake.
+### Downloading Source
-To set up an Xcode project and open Xcode, use the following command.
+Download the source and install all submodules if you have not already, by running the following from the root of the repository.
```
-make iproj
+git clone --recurse-submodules git@github.com:maplibre/maplibre-native.git
+cd maplibre-native
```
+Next run the following to generate some files that are needed:
+
+```
+cd platform/ios
+make style-code
+```
+
+
### Bazel
-The above setup is quite fragile and relies on the `.xcodeproj` files part of the source tree (making changes hard to review). We are looking into a better way to set up an Xcode project for MapLibre Native iOS development. As of May 2023 we are experimenting with [Bazel](https://bazel.build/) together with [rules_xcodeproj](https://github.com/MobileNativeFoundation/rules_xcodeproj). Please [share your experiences](https://github.com/maplibre/maplibre-native/discussions/1145).
+[Bazel](https://bazel.build/) together with [rules_xcodeproj](https://github.com/MobileNativeFoundation/rules_xcodeproj) is the preferred build system. Please [share your experiences](https://github.com/maplibre/maplibre-native/discussions/1145).
You need to install bazelisk, which is a wrapper around Bazel which ensures that the version specified in `.bazelversion` is used.
@@ -41,20 +93,74 @@ You need to install bazelisk, which is a wrapper around Bazel which ensures that
brew install bazelisk
```
-Next, you can generate an Xcode project for MapLibre Native development using:
+#### Creating `config.bzl`
+
+You need to configure Bazel. Copy the example config from `platform/ios`.
```
-bazel run //platform/ios:xcodeproj
+cp bazel/example_config.bzl bazel/config.bzl
```
-You can now open `platform/ios/MapLibre.xcodeproj` with Xcode to get started.
+You need to set your `BUNDLE_ID_PREFIX` to be unique (ideally use a domain that you own in reverse domain name notation).
+
+```
+APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "FFNX6834U8"
+APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *"
+BUNDLE_ID_PREFIX = "com.firstnamelastname"
+```
+
+You can keep leave the `APPLE_MOBILE_PROVISIONING_PROFILE_NAME` alone.
+
+Set the Team ID to the Team ID of your Apple Developer Account (paid or unpaid both work). If you do not know your Team ID, enter the following command in the terminal:
+
+```
+cd ~/Library/MobileDevice/Provisioning\ Profiles && open .
+```
+
+Then select one of the profiles and click spacebar. Your Team ID is the string between parentheses in the value of "Team".
+
+If there are no provisioning profiles available, continue this guide and let Xcode generate a provisioning profile for you. You will need to update the Team ID after this happened.
+
+#### Create the Xcode Project
+
+_These instructions are for XCode 14.3.1_
+
+From `platform/ios`:
+
+```
+bazel run xcodeproj
+xed MapLibre.xcodeproj
+```
+
+Then once in Xcode, click on "MapLibre" on the left, then "App" under Targets, then "Signing & Capabilities" in the tabbed menu.
+Confirm that no errors are shown:
+
+
+
+Try to run the example App in the simulator and on a device to confirm your setup works.
+
+#### Using Bazel from the Command Line
It is also possible to build and run the test application in a simulator from the command line without opening Xcode.
```
bazel run //platform/ios:App
+
+# run the iOS tests
+bazel test //platform/ios/platform/ios/test:ios_test --test_output=errors
```
+### CMake (deprecated)
+
+The original build tool generator supported by MapLibre Native is CMake. There is a `Makefile` which calls CMake and `xcodebuild` under the hood to complete various development tasks, including building with various kinds of configurations and running tests. This `Makefile` can also can set up an Xcode project for MapLibre Native development by copying a `.xcodeproj` file part of the source tree and combining that with the output of CMake.
+
+To set up an Xcode project and open Xcode, use the following command from `platform/ios`:
+
+```
+make iproj
+```
+
+
## Documentation
- [MapLibre Native for iOS API Reference](https://maplibre.org/maplibre-native/ios/api/)
diff --git a/platform/ios/test/common/BUILD.bazel b/platform/ios/test/common/BUILD.bazel
index ef7df159f..147ae6d1b 100644
--- a/platform/ios/test/common/BUILD.bazel
+++ b/platform/ios/test/common/BUILD.bazel
@@ -1,4 +1,5 @@
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
+load("//platform/ios:bazel/config.bzl", "BUNDLE_ID_PREFIX")
cc_library(
name = "ios_test_runner_lib",
@@ -31,7 +32,7 @@ objc_library(
ios_application(
name = "RenderTestApp",
- bundle_id = "org.maplibre.RenderTestApp",
+ bundle_id = "{}.maplibre.RenderTestApp".format(BUNDLE_ID_PREFIX),
families = ["iphone"],
infoplists = [
"//render-test/ios:Info.plist",
diff --git a/render-test/ios/Info.plist b/render-test/ios/Info.plist
index 91046744a..844346be3 100644
--- a/render-test/ios/Info.plist
+++ b/render-test/ios/Info.plist
@@ -8,8 +8,6 @@
${PRODUCT_NAME}
CFBundleExecutable
RenderTestApp
- CFBundleIdentifier
- org.maplibre.RenderTestApp
CFBundleGetInfoString
org.maplibre.RenderTestApp
CFBundleInfoDictionaryVersion