Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
c4221435b9
commit
e673658516
84
Agents.md
84
Agents.md
@ -604,6 +604,88 @@ FileManager.default.containerURL(
|
|||||||
CKContainer(identifier: AppIdentifiers.cloudKitContainerIdentifier)
|
CKContainer(identifier: AppIdentifiers.cloudKitContainerIdentifier)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Adding New Targets
|
||||||
|
|
||||||
|
When adding new targets (Widgets, Intents, App Clips, etc.), follow this pattern:
|
||||||
|
|
||||||
|
#### 1. Add Bundle ID Variable to Base.xcconfig
|
||||||
|
|
||||||
|
```
|
||||||
|
// In Base.xcconfig, add new derived identifier
|
||||||
|
WIDGET_BUNDLE_IDENTIFIER = $(APP_BUNDLE_IDENTIFIER).Widget
|
||||||
|
INTENT_BUNDLE_IDENTIFIER = $(APP_BUNDLE_IDENTIFIER).Intent
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Set Target to Use xcconfig
|
||||||
|
|
||||||
|
For the new target's Debug/Release configurations in `project.pbxproj`:
|
||||||
|
|
||||||
|
```
|
||||||
|
EA_NEW_TARGET_DEBUG /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = EACONFIG002 /* Debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "$(WIDGET_BUNDLE_IDENTIFIER)";
|
||||||
|
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
|
||||||
|
// ... other settings
|
||||||
|
};
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Configure Entitlements (if needed)
|
||||||
|
|
||||||
|
If the target needs App Groups or CloudKit access, create an entitlements file using variables:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- WidgetExtension.entitlements -->
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>$(APP_GROUP_IDENTIFIER)</string>
|
||||||
|
</array>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. Share Code via App Groups
|
||||||
|
|
||||||
|
Extensions must use App Groups to share data with the main app:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
// In extension code
|
||||||
|
let sharedDefaults = UserDefaults(suiteName: AppIdentifiers.appGroupIdentifier)
|
||||||
|
let containerURL = FileManager.default.containerURL(
|
||||||
|
forSecurityApplicationGroupIdentifier: AppIdentifiers.appGroupIdentifier
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. Update AppIdentifiers.swift (if needed)
|
||||||
|
|
||||||
|
Add new computed properties for target-specific identifiers:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
static var widgetBundleIdentifier: String { "\(bundleIdentifier).Widget" }
|
||||||
|
static var intentBundleIdentifier: String { "\(bundleIdentifier).Intent" }
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Common Target Types and Bundle ID Patterns
|
||||||
|
|
||||||
|
| Target Type | Bundle ID Variable | Example Value |
|
||||||
|
|-------------|-------------------|---------------|
|
||||||
|
| Widget Extension | `WIDGET_BUNDLE_IDENTIFIER` | `$(APP_BUNDLE_IDENTIFIER).Widget` |
|
||||||
|
| Intent Extension | `INTENT_BUNDLE_IDENTIFIER` | `$(APP_BUNDLE_IDENTIFIER).Intent` |
|
||||||
|
| App Clip | `APPCLIP_BUNDLE_IDENTIFIER` | `$(APP_BUNDLE_IDENTIFIER).Clip` |
|
||||||
|
| Watch App | `WATCH_BUNDLE_IDENTIFIER` | `$(APP_BUNDLE_IDENTIFIER).watchkitapp` |
|
||||||
|
| Notification Extension | `NOTIFICATION_BUNDLE_IDENTIFIER` | `$(APP_BUNDLE_IDENTIFIER).NotificationExtension` |
|
||||||
|
| Share Extension | `SHARE_BUNDLE_IDENTIFIER` | `$(APP_BUNDLE_IDENTIFIER).ShareExtension` |
|
||||||
|
|
||||||
|
#### Checklist for New Targets
|
||||||
|
|
||||||
|
- [ ] Add bundle ID variable to `Base.xcconfig`
|
||||||
|
- [ ] Set `baseConfigurationReference` to Debug/Release xcconfig
|
||||||
|
- [ ] Use `$(VARIABLE)` for `PRODUCT_BUNDLE_IDENTIFIER`
|
||||||
|
- [ ] Use `$(DEVELOPMENT_TEAM)` for team
|
||||||
|
- [ ] Create entitlements with `$(APP_GROUP_IDENTIFIER)` if sharing data
|
||||||
|
- [ ] Add to `AppIdentifiers.swift` if Swift code needs the identifier
|
||||||
|
- [ ] Register App ID in Apple Developer Portal (uses same App Group)
|
||||||
|
|
||||||
### Migration
|
### Migration
|
||||||
|
|
||||||
To migrate to a new developer account, edit **one file** (`Base.xcconfig`):
|
To migrate to a new developer account, edit **one file** (`Base.xcconfig`):
|
||||||
@ -613,7 +695,7 @@ COMPANY_IDENTIFIER = com.newcompany
|
|||||||
DEVELOPMENT_TEAM = NEW_TEAM_ID
|
DEVELOPMENT_TEAM = NEW_TEAM_ID
|
||||||
```
|
```
|
||||||
|
|
||||||
Then clean build (⇧⌘K) and rebuild. Everything updates automatically.
|
Then clean build (⇧⌘K) and rebuild. Everything updates automatically—including all extension targets.
|
||||||
|
|
||||||
|
|
||||||
## Dynamic Type Instructions
|
## Dynamic Type Instructions
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user