-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-xcode.sh
More file actions
executable file
·206 lines (190 loc) · 7.26 KB
/
Copy pathsetup-xcode.sh
File metadata and controls
executable file
·206 lines (190 loc) · 7.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
#
# AgentPulse Xcode Project Setup Script
# 在 Mac 上运行此脚本来创建 Xcode 项目
#
set -e
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "📱 AgentPulse Xcode Project Setup"
echo " Directory: $PROJECT_DIR"
echo ""
# Check for Xcode
if ! command -v xcodebuild &> /dev/null; then
echo "❌ Xcode not found. Please install Xcode from the App Store."
exit 1
fi
echo "✅ Xcode found: $(xcodebuild -version | head -1)"
echo ""
# ============================================================
# Since we can't programmatically create .xcodeproj without
# additional tools, we'll guide the user through manual setup
# OR use xcodegen if available.
# ============================================================
# Check if xcodegen is available
if command -v xcodegen &> /dev/null; then
echo "✅ XcodeGen found, generating project automatically..."
# Create project.yml for XcodeGen
cat > "$PROJECT_DIR/project.yml" << 'XCODEGEN_EOF'
name: AgentPulse
options:
bundleIdPrefix: com.agentpulse
deploymentTarget:
iOS: "17.0"
xcodeVersion: "15.0"
createIntermediateGroups: true
settings:
base:
SWIFT_VERSION: "5.9"
DEVELOPMENT_TEAM: ""
targets:
AgentPulse:
type: application
platform: iOS
sources:
- path: AgentPulse
group: AgentPulse
- path: AgentPulseShared
group: AgentPulseShared
settings:
base:
INFOPLIST_KEY_UIApplicationSceneManifest_Generation: YES
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents: YES
INFOPLIST_KEY_UILaunchScreen_Generation: YES
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone: "UIInterfaceOrientationPortrait"
INFOPLIST_KEY_NSBonjourServices: ["_agentpulse._tcp"]
INFOPLIST_KEY_NSLocalNetworkUsageDescription: "AgentPulse needs local network access to discover relay servers."
SUPPORTS_LIVE_ACTIVITIES: YES
entitlements:
path: AgentPulse/AgentPulse.entitlements
properties:
com.apple.security.application-groups:
- group.com.agentpulse.shared
dependencies:
- target: AgentPulseWidgets
AgentPulseWidgets:
type: app-extension
platform: iOS
sources:
- path: AgentPulseWidgets
group: AgentPulseWidgets
- path: AgentPulseShared
group: AgentPulseShared
settings:
base:
INFOPLIST_KEY_CFBundleDisplayName: AgentPulse Widgets
INFOPLIST_KEY_NSExtension_NSExtensionPointIdentifier: com.apple.widgetkit-extension
SUPPORTS_LIVE_ACTIVITIES: YES
entitlements:
path: AgentPulseWidgets/AgentPulseWidgets.entitlements
properties:
com.apple.security.application-groups:
- group.com.agentpulse.shared
XCODEGEN_EOF
# Create entitlements files
mkdir -p "$PROJECT_DIR/AgentPulse"
cat > "$PROJECT_DIR/AgentPulse/AgentPulse.entitlements" << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.agentpulse.shared</string>
</array>
</dict>
</plist>
EOF
cat > "$PROJECT_DIR/AgentPulseWidgets/AgentPulseWidgets.entitlements" << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.agentpulse.shared</string>
</array>
</dict>
</plist>
EOF
# Generate project
cd "$PROJECT_DIR"
xcodegen generate
echo ""
echo "✅ Xcode project generated!"
echo " Open: $PROJECT_DIR/AgentPulse.xcodeproj"
echo ""
echo " Run: open AgentPulse.xcodeproj"
else
echo "⚠️ XcodeGen not found. Please install it first:"
echo ""
echo " brew install xcodegen"
echo ""
echo " Then re-run this script:"
echo " ./setup-xcode.sh"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Or create the project manually (see below)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
fi
echo ""
echo "═══════════════════════════════════════════════════"
echo " Manual Xcode Setup (if not using XcodeGen)"
echo "═══════════════════════════════════════════════════"
echo ""
echo " 1. Open Xcode → File → New → Project"
echo " Template: iOS → App"
echo " Product Name: AgentPulse"
echo " Interface: SwiftUI"
echo " Language: Swift"
echo " Save to: ~/Desktop/AgentPulse"
echo " ⚠️ Uncheck 'Create Git repository'"
echo ""
echo " 2. Delete the auto-generated ContentView.swift and AgentPulseApp.swift"
echo ""
echo " 3. Drag these folders into the Xcode project navigator:"
echo " • AgentPulse/App/"
echo " • AgentPulse/Models/"
echo " • AgentPulse/Services/"
echo " • AgentPulse/Views/"
echo " • AgentPulseShared/ (add to BOTH targets)"
echo ""
echo " 4. Add Widget Extension:"
echo " File → New → Target → Widget Extension"
echo " Product Name: AgentPulseWidgets"
echo " ✅ Include Live Activity"
echo " Delete auto-generated files, drag in AgentPulseWidgets/*.swift"
echo " Also add AgentPulseShared/*.swift to this target"
echo ""
echo " 5. Configure targets:"
echo " • Both targets: Deployment Target = iOS 17.0"
echo " • AgentPulse target → Signing & Capabilities:"
echo " + App Groups → group.com.agentpulse.shared"
echo " • AgentPulseWidgets target → Signing & Capabilities:"
echo " + App Groups → group.com.agentpulse.shared"
echo ""
echo " 6. Add Info.plist keys (AgentPulse target):"
echo " • NSLocalNetworkUsageDescription:"
echo " 'AgentPulse needs local network to discover relay servers.'"
echo " • NSBonjourServices: ['_agentpulse._tcp']"
echo " • Supports Live Activities: YES"
echo ""
echo " 7. Build & Run on iPhone or Simulator (iOS 17+)"
echo ""
echo "═══════════════════════════════════════════════════"
echo " Testing"
echo "═══════════════════════════════════════════════════"
echo ""
echo " Terminal 1 (relay server):"
echo " cd ~/Desktop/AgentPulse/relay-server && npm run dev"
echo ""
echo " Terminal 2 (simulate agent):"
echo " cd ~/Desktop/AgentPulse/relay-server && npm run simulate"
echo ""
echo " Then open the app on your iPhone/Simulator."
echo " It should auto-discover the relay via Bonjour,"
echo " show the agent in the list, and activate Dynamic Island."
echo ""
echo " ⚠️ iPhone must be on the same WiFi as your Mac!"
echo " ⚠️ If Bonjour doesn't work, go to Settings in the app"
echo " and manually enter your Mac's IP address + port 8347"
echo ""