diff --git a/Configs/Config.xcconfig b/Configs/Config.xcconfig index a81ec04..5896ee2 100644 --- a/Configs/Config.xcconfig +++ b/Configs/Config.xcconfig @@ -1,4 +1,6 @@ // FreeMount Base Configuration -// Conditionally includes local secrets if present. +// Default bundle identifier prefix (overridden per-team in Secrets.xcconfig for source builds). +FREEMOUNT_BUNDLE_IDENTIFIER = com.freemount.app +// Conditionally includes local secrets if present. #include? "Secrets.xcconfig" diff --git a/Configs/Secrets.xcconfig.example b/Configs/Secrets.xcconfig.example index a84a4da..066bfbf 100644 --- a/Configs/Secrets.xcconfig.example +++ b/Configs/Secrets.xcconfig.example @@ -20,3 +20,8 @@ FREEMOUNT_GOOGLE_CLIENT_ID = 319728381325-v71u1mjithqc6ovqvbb4mnc0hhbf0r65.apps. FREEMOUNT_GOOGLE_CLIENT_SECRET = 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 DEVELOPMENT_TEAM = + +// Optional: override the app bundle identifier (recommended for Personal Team +// builds so Apple's Developer Portal does not reject shared IDs; +// scripts/install-from-source.sh sets this to com.freemount.app.). +// FREEMOUNT_BUNDLE_IDENTIFIER = com.freemount.app diff --git a/FreeMount.xcodeproj/project.pbxproj b/FreeMount.xcodeproj/project.pbxproj index 1f012f9..c868cab 100644 --- a/FreeMount.xcodeproj/project.pbxproj +++ b/FreeMount.xcodeproj/project.pbxproj @@ -942,7 +942,7 @@ "@executable_path/../Frameworks", "@executable_path/../../../../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.freemount.app.fileprovider; + PRODUCT_BUNDLE_IDENTIFIER = "$(FREEMOUNT_BUNDLE_IDENTIFIER).fileprovider"; PRODUCT_NAME = FreeMountFileProvider; SDKROOT = macosx; SKIP_INSTALL = NO; @@ -1026,7 +1026,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.freemount.app; + PRODUCT_BUNDLE_IDENTIFIER = "$(FREEMOUNT_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = FM; SDKROOT = macosx; }; @@ -1102,7 +1102,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.freemount.app; + PRODUCT_BUNDLE_IDENTIFIER = "$(FREEMOUNT_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = FM; SDKROOT = macosx; }; @@ -1125,7 +1125,7 @@ "@executable_path/../Frameworks", "@executable_path/../../../../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.freemount.app.fileprovider; + PRODUCT_BUNDLE_IDENTIFIER = "$(FREEMOUNT_BUNDLE_IDENTIFIER).fileprovider"; PRODUCT_NAME = FreeMountFileProvider; SDKROOT = macosx; SKIP_INSTALL = NO; diff --git a/docs/building.md b/docs/building.md index 8412058..69cf35b 100644 --- a/docs/building.md +++ b/docs/building.md @@ -19,6 +19,7 @@ Edit `Configs/Secrets.xcconfig` (git-ignored): | Key | Where to get it | |---|---| | `DEVELOPMENT_TEAM` | Your Team ID: Xcode → Settings → Accounts → select your team | +| `FREEMOUNT_BUNDLE_IDENTIFIER` | Optional (defaults to `com.freemount.app`); set to `com.freemount.app.` for Personal Team builds (`scripts/install-from-source.sh` configures this automatically) | | `FREEMOUNT_GOOGLE_CLIENT_ID` / `FREEMOUNT_GOOGLE_CLIENT_SECRET` | Defaults are bundled; optionally your own Google Cloud Console **Desktop app** OAuth client | The repository bundles a default Google Desktop OAuth client (public by diff --git a/project.yml b/project.yml index 3dd8e23..4c4bdc6 100644 --- a/project.yml +++ b/project.yml @@ -27,7 +27,7 @@ targets: buildPhase: resources settings: base: - PRODUCT_BUNDLE_IDENTIFIER: com.freemount.app + PRODUCT_BUNDLE_IDENTIFIER: $(FREEMOUNT_BUNDLE_IDENTIFIER) PRODUCT_NAME: FM ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon INFOPLIST_FILE: App/Resources/Info.plist @@ -57,7 +57,7 @@ targets: buildPhase: resources settings: base: - PRODUCT_BUNDLE_IDENTIFIER: com.freemount.app.fileprovider + PRODUCT_BUNDLE_IDENTIFIER: $(FREEMOUNT_BUNDLE_IDENTIFIER).fileprovider PRODUCT_NAME: FreeMountFileProvider INFOPLIST_FILE: App/FileProviderExtension/Info.plist CODE_SIGN_ENTITLEMENTS: App/FileProviderExtension/FreeMountFileProvider.entitlements diff --git a/scripts/install-from-source.sh b/scripts/install-from-source.sh index ea8c031..d45f19a 100755 --- a/scripts/install-from-source.sh +++ b/scripts/install-from-source.sh @@ -6,8 +6,9 @@ # # What it does: checks prerequisites, prepares Configs/Secrets.xcconfig # (Google OAuth client defaults ship in the repo), detects or takes your -# personal team ID, builds Release, signs with your Apple Development -# identity and installs. Re-run the same command to update after `git pull`. +# personal team ID, sets a team-scoped bundle identifier, builds Release, +# signs with your Apple Development identity and installs. Re-run the same +# command to update after `git pull`. set -euo pipefail cd "${0:A:h:h}" @@ -73,11 +74,27 @@ print(" ".join(seen)) print "Auto-detected team $team and saved it to Configs/Secrets.xcconfig." fi +# Resolve team-scoped bundle identifier so personal-team builds do not collide +# with globally registered App IDs in Apple's Developer Portal. +bundle_id="$(awk -F'=' '/^FREEMOUNT_BUNDLE_IDENTIFIER[ \t]*=/ {gsub(/[ \t]/,"",$2); print $2}' Configs/Secrets.xcconfig)" +if [[ -z "$bundle_id" ]]; then + bundle_id="com.freemount.app.$team" + if grep -q '^FREEMOUNT_BUNDLE_IDENTIFIER[ \t]*=' Configs/Secrets.xcconfig; then + sed -i '' "s/^FREEMOUNT_BUNDLE_IDENTIFIER[ \t]*=.*/FREEMOUNT_BUNDLE_IDENTIFIER = $bundle_id/" Configs/Secrets.xcconfig + else + printf '\nFREEMOUNT_BUNDLE_IDENTIFIER = %s\n' "$bundle_id" >> Configs/Secrets.xcconfig + fi + print "Configured team-scoped bundle ID $bundle_id in Configs/Secrets.xcconfig." +elif [[ -n "$team_override" && "$bundle_id" == com.freemount.app.* ]]; then + bundle_id="com.freemount.app.$team" +fi + print "Building Release (first run may take a few minutes; Xcode provisions your personal team automatically)…" xcodebuild -project FreeMount.xcodeproj -scheme FreeMount \ -configuration Release -destination 'platform=macOS' \ -derivedDataPath build/install-dd \ DEVELOPMENT_TEAM="$team" \ + FREEMOUNT_BUNDLE_IDENTIFIER="$bundle_id" \ -allowProvisioningUpdates \ build >/tmp/freemount-install-build.log 2>&1 || { tail -20 /tmp/freemount-install-build.log @@ -90,6 +107,9 @@ codesign --verify --deep --strict "$APP" || { print -u2 "Built bundle failed sig # Record repository directory in user defaults so the app knows where to pull updates from defaults write com.freemount.app FreeMountSourceRepositoryPath "$PWD" +if [[ "$bundle_id" != "com.freemount.app" ]]; then + defaults write "$bundle_id" FreeMountSourceRepositoryPath "$PWD" +fi pkill -x FM 2>/dev/null || true if [[ -d /Applications/FreeMount.app ]]; then rm -rf /Applications/FreeMount.app; fi