commit da700f3c9eb4035d74276e86065d5fbe9cf452d5
parent b0e09cb601315106f3cf0acbda281fbf55ec2d23
Author: Jean Schurger <jean@schurger.org>
Date: Sat, 14 Nov 2026 13:48:39 -0500
iCloud backup of the cards behind a switch until the container exists
The iCloud container can only be created by the account holder in the
developer portal (an App Store Connect API key cannot). CardsICloudBackup in
project.yml, with the entitlements, turns the copy on once it exists; until
then the cards stay on the iPhone and the screen says so. fastlane
icloud_setup turns the iCloud capability on for the app identifier.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYG3yp7VDUZJzSBkvTc
Diffstat:
5 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/App/Localizable.xcstrings b/App/Localizable.xcstrings
@@ -3071,6 +3071,16 @@
}
}
},
+ "The cards are kept on this iPhone, and in its iPhone backup. The automatic copy to iCloud Drive comes in a later version.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Les cartes sont gardées sur cet iPhone, et dans sa sauvegarde d'iPhone. La copie automatique dans iCloud Drive arrive dans une prochaine version."
+ }
+ }
+ }
+ },
"The cards are only on this iPhone: sign in to iCloud and turn iCloud Drive on to have them backed up automatically.": {
"localizations": {
"fr": {
diff --git a/App/Model/Cards.swift b/App/Model/Cards.swift
@@ -47,6 +47,8 @@ struct CertificationCard: Codable, Identifiable, Equatable {
final class CardStore {
enum Backup: Equatable {
case unknown
+ /// This build has no iCloud folder (see `CardsICloudBackup` in project.yml).
+ case notBuiltIn
/// No iCloud account, or iCloud Drive turned off for the app.
case unavailable
case working
@@ -190,8 +192,8 @@ final class CardStore {
/// Merges this iPhone's cards with the copy in iCloud Drive, both ways. Safe to call at any time.
func sync() {
- guard !LaunchOptions.flag("-demoCards") else {
- backup = .unavailable
+ guard !LaunchOptions.flag("-demoCards"), Bundle.main.object(forInfoDictionaryKey: "CardsICloudBackup") as? Bool == true else {
+ backup = .notBuiltIn
return
}
if syncing {
diff --git a/App/Views/CardsView.swift b/App/Views/CardsView.swift
@@ -52,6 +52,8 @@ struct BackupFootnote: View {
switch store.backup {
case .unknown, .working:
Text("Checking the iCloud backup…")
+ case .notBuiltIn:
+ Text("The cards are kept on this iPhone, and in its iPhone backup. The automatic copy to iCloud Drive comes in a later version.")
case .unavailable:
Text("The cards are only on this iPhone: sign in to iCloud and turn iCloud Drive on to have them backed up automatically.")
case .done(let date):
diff --git a/fastlane/Fastfile b/fastlane/Fastfile
@@ -33,6 +33,21 @@ platform :ios do
[res.code.to_i, (JSON.parse(res.body) rescue {})]
end
+ desc "Turns the iCloud capability on for the app identifier (the iCloud container itself is assigned in the developer portal)"
+ lane :icloud_setup do
+ api_key
+ _, found = asc(:get, "/v1/bundleIds?filter[identifier]=#{APP_ID}&include=bundleIdCapabilities")
+ bundle = found["data"].find { |b| b["attributes"]["identifier"] == APP_ID } or UI.user_error!("No bundle identifier #{APP_ID}")
+ capabilities = (found["included"] || []).map { |c| c["attributes"]["capabilityType"] }
+ UI.message("CAPABILITIES #{capabilities.sort.join(", ")}")
+ unless capabilities.include?("ICLOUD")
+ c, r = asc(:post, "/v1/bundleIdCapabilities", { data: { type: "bundleIdCapabilities",
+ attributes: { capabilityType: "ICLOUD", settings: [{ key: "ICLOUD_VERSION", options: [{ key: "XCODE_6" }] }] },
+ relationships: { bundleId: { data: { type: "bundleIds", id: bundle["id"] } } } } })
+ UI.message("ICLOUD -> #{c} #{(r["errors"] || []).map { |e| e["detail"] }.join(" ; ")}")
+ end
+ end
+
desc "Internal tester group, TestFlight texts and notes of the latest build"
lane :beta_setup do
api_key
@@ -61,9 +76,9 @@ platform :ios do
end
texts = {
"fr-CA" => ["Votre carnet de plongée Subsurface sur iPhone : lecture, profils, modification hors ligne, synchronisation avec le nuage Subsurface. Application indépendante de l'équipe de Subsurface.",
- "0.5 : Nouveau : (1) Modifier une plongée permet de saisir les bouteilles et le lest. (2) Réglages, Cartes de certification : agence, numéro, photo recto et verso, affichage plein écran ; sauvegarde automatique dans iCloud Drive. (3) Fusion de plongées depuis la liste (+) ou depuis la fiche (menu ...). À vérifier : après avoir ajouté une carte, le pied de la liste doit indiquer la sauvegarde iCloud, et le dossier Sub Rascasse doit apparaître dans Fichiers, iCloud Drive."],
+ "0.5 : Nouveau : (1) Modifier une plongée permet de saisir les bouteilles et le lest. (2) Réglages, Cartes de certification : agence, numéro, photo recto et verso, affichage plein écran (gardées sur l'iPhone ; la copie automatique dans iCloud Drive arrive dans une prochaine version). (3) Fusion de plongées depuis la liste (+) ou depuis la fiche (menu ...)."],
"en-CA" => ["Your Subsurface dive log on iPhone: browse, profiles, offline editing, sync with Subsurface cloud storage. Independent from the Subsurface team.",
- "0.5: New: (1) Editing a dive now covers cylinders and weights. (2) Settings, Certification cards: agency, number, photo of each side, full screen display; automatic backup in iCloud Drive. (3) Merging dives from the list (+) or from a dive page (... menu). To check: after adding a card, the footer of the list should mention the iCloud backup, and a Sub Rascasse folder should appear in Files, iCloud Drive."],
+ "0.5: New: (1) Editing a dive now covers cylinders and weights. (2) Settings, Certification cards: agency, number, photo of each side, full screen display (kept on the iPhone; the automatic copy to iCloud Drive comes in a later version). (3) Merging dives from the list (+) or from a dive page (... menu)."],
}
_, locs = asc(:get, "/v1/apps/#{app.id}/betaAppLocalizations")
texts.each do |locale, (description, _)|
diff --git a/project.yml b/project.yml
@@ -51,12 +51,17 @@ targets:
# French translation in App/InfoPlist.xcstrings.
NSPhotoLibraryUsageDescription: "Sub Rascasse flags the dives you have photos or videos of and shows them on the dive page. They stay on your iPhone; nothing is sent."
NSCameraUsageDescription: "Sub Rascasse uses the camera to photograph your certification cards."
+ # iCloud backup of the certification cards. It needs the iCloud container, which only the account holder can
+ # create (developer portal > Identifiers > iCloud Containers > iCloud.org.schurger.subrascasse, then assign
+ # it to the app identifier: an App Store Connect API key cannot do it). Once it exists: set this to true and
+ # uncomment NSUbiquitousContainers below and the three iCloud entitlements further down.
+ CardsICloudBackup: false
# The cards folder shows up in the Files app, under iCloud Drive.
- NSUbiquitousContainers:
- iCloud.org.schurger.subrascasse:
- NSUbiquitousContainerIsDocumentScopePublic: true
- NSUbiquitousContainerName: Sub Rascasse
- NSUbiquitousContainerSupportedFolderLevels: Any
+ # NSUbiquitousContainers:
+ # iCloud.org.schurger.subrascasse:
+ # NSUbiquitousContainerIsDocumentScopePublic: true
+ # NSUbiquitousContainerName: Sub Rascasse
+ # NSUbiquitousContainerSupportedFolderLevels: Any
NSBluetoothAlwaysUsageDescription: "Sub Rascasse uses Bluetooth to download the dives stored in your dive computer."
# Open Remora opens "subrascasse://open-remora" after dropping a dive.
CFBundleURLTypes:
@@ -68,9 +73,9 @@ targets:
# Folder shared with Open Remora (dives from the watch, to be imported).
com.apple.security.application-groups: [group.org.schurger.dive]
# iCloud Drive folder where the certification cards are backed up.
- com.apple.developer.icloud-container-identifiers: [iCloud.org.schurger.subrascasse]
- com.apple.developer.ubiquity-container-identifiers: [iCloud.org.schurger.subrascasse]
- com.apple.developer.icloud-services: [CloudDocuments]
+ # com.apple.developer.icloud-container-identifiers: [iCloud.org.schurger.subrascasse]
+ # com.apple.developer.ubiquity-container-identifiers: [iCloud.org.schurger.subrascasse]
+ # com.apple.developer.icloud-services: [CloudDocuments]
schemes:
DiveLog:
build: