Skip to content

Commit 7cc402f

Browse files
committed
remove sdk root change
1 parent 514a071 commit 7cc402f

4 files changed

Lines changed: 109 additions & 26 deletions

File tree

com.onesignal.unity.ios/Editor/BuildPostProcessor.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ private void AddNotificationServiceExtension()
223223
_project.SetBuildProperty(extensionGuid, "TARGETED_DEVICE_FAMILY", "1,2");
224224
_project.SetBuildProperty(extensionGuid, "IPHONEOS_DEPLOYMENT_TARGET", "13.0");
225225
_project.SetBuildProperty(extensionGuid, "SWIFT_VERSION", "5.0");
226-
227-
var sdkRoot = PlayerSettings.iOS.sdkVersion == iOSSdkVersion.SimulatorSDK
228-
? "iphonesimulator"
229-
: "iphoneos";
230-
_project.SetBuildProperty(extensionGuid, "SDKROOT", sdkRoot);
231-
232226
_project.SetBuildProperty(
233227
extensionGuid,
234228
"DEVELOPMENT_TEAM",

examples/demo/Assets/Scripts/Editor/BuildScript.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,30 @@ public static void BuildAndroidEmulator()
6767
}
6868

6969
/// <summary>
70-
/// Builds an Xcode project for the iOS Simulator (ARM64).
71-
/// The OneSignal SDK post-processor automatically adds push capabilities,
72-
/// the NSE target, and CocoaPods entries during the build.
70+
/// Builds an Xcode project for the iOS Simulator.
7371
/// </summary>
7472
public static void BuildiOSSimulator()
73+
{
74+
BuildiOS(iOSSdkVersion.SimulatorSDK);
75+
}
76+
77+
/// <summary>
78+
/// Builds an Xcode project for a physical iOS device.
79+
/// </summary>
80+
public static void BuildiOSDevice()
81+
{
82+
BuildiOS(iOSSdkVersion.DeviceSDK);
83+
}
84+
85+
private static void BuildiOS(iOSSdkVersion sdkVersion)
7586
{
7687
Directory.CreateDirectory(IOSOutputDir);
7788

7889
PlayerSettings.SetScriptingBackend(
7990
NamedBuildTarget.iOS,
8091
ScriptingImplementation.IL2CPP
8192
);
82-
PlayerSettings.iOS.sdkVersion = iOSSdkVersion.SimulatorSDK;
93+
PlayerSettings.iOS.sdkVersion = sdkVersion;
8394

8495
Debug.Log(
8596
$"[BuildScript] iOS sdk={PlayerSettings.iOS.sdkVersion} backend={PlayerSettings.GetScriptingBackend(NamedBuildTarget.iOS)}"

examples/demo/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ PlayerSettings:
191191
StripUnusedMeshComponents: 0
192192
strictShaderVariantMatching: 0
193193
VertexChannelCompressionMask: 4054
194-
iPhoneSdkVersion: 989
194+
iPhoneSdkVersion: 988
195195
iOSSimulatorArchitecture: 0
196196
iOSTargetOSVersionString: 15.0
197197
tvOSSdkVersion: 0

examples/demo/build_ios.sh

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/sh
2-
# Build the OneSignal Unity demo for iOS simulator.
2+
# Build the OneSignal Unity demo for iOS simulator or device.
33
#
44
# Usage:
5-
# ./build_ios.sh [--no-install] [--install-only] [--open]
5+
# ./build_ios.sh [--device] [--no-install] [--install-only] [--open]
6+
#
7+
# By default targets the iOS Simulator. Pass --device to build for a
8+
# connected physical device instead.
69
set -eu
710

811
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -15,9 +18,11 @@ APP_BUNDLE_ID="com.onesignal.example"
1518
INSTALL=true
1619
SKIP_BUILD=false
1720
OPEN_XCODE=false
21+
DEVICE_BUILD=false
1822

1923
for arg in "$@"; do
2024
case "$arg" in
25+
--device) DEVICE_BUILD=true ;;
2126
--no-install) INSTALL=false ;;
2227
--install-only) SKIP_BUILD=true ;;
2328
--open) OPEN_XCODE=true; INSTALL=false; SKIP_BUILD=true ;;
@@ -53,9 +58,63 @@ for r,devs in d['devices'].items():
5358
SIM_NAME=$(echo "$LINE" | cut -d'|' -f2)
5459
}
5560

56-
SIM_UDID=""
57-
SIM_NAME=""
58-
[ "$INSTALL" = true ] && pick_simulator && echo "Target: $SIM_NAME ($SIM_UDID)" && echo ""
61+
pick_device() {
62+
LIST=$(python3 -c "
63+
import subprocess,json,sys,tempfile,os
64+
tmp = tempfile.mktemp(suffix='.json')
65+
subprocess.run(['xcrun','devicectl','list','devices','--json-output',tmp],
66+
capture_output=True, text=True)
67+
try:
68+
with open(tmp) as f: data = json.load(f)
69+
finally:
70+
try: os.unlink(tmp)
71+
except: pass
72+
for d in data.get('result',{}).get('devices',[]):
73+
identifier = d.get('identifier','')
74+
name = d.get('deviceProperties',{}).get('name','')
75+
platform = d.get('hardwareProperties',{}).get('platform','')
76+
if identifier and name and platform in ('iOS','iPadOS'):
77+
print(identifier + '|' + name)
78+
" 2>/dev/null || true)
79+
COUNT=$(printf '%s\n' "$LIST" | grep -c . || true)
80+
81+
[ "$COUNT" -eq 0 ] && echo "No connected devices found. Plug in a device or check Xcode." && exit 1
82+
[ "$COUNT" -eq 1 ] && DEV_UDID=$(echo "$LIST" | cut -d'|' -f1) && DEV_NAME=$(echo "$LIST" | cut -d'|' -f2) && return
83+
84+
echo "Multiple devices found — pick one:"
85+
i=1
86+
printf '%s\n' "$LIST" | while IFS='|' read -r UDID NAME; do
87+
printf " [%d] %s (%s)\n" "$i" "$NAME" "$UDID"
88+
i=$((i + 1))
89+
done
90+
printf "Choice [1-%d]: " "$COUNT"
91+
read -r CHOICE
92+
LINE=$(printf '%s\n' "$LIST" | sed -n "${CHOICE}p")
93+
[ -z "$LINE" ] && echo "Invalid choice." && exit 1
94+
DEV_UDID=$(echo "$LINE" | cut -d'|' -f1)
95+
DEV_NAME=$(echo "$LINE" | cut -d'|' -f2)
96+
}
97+
98+
TARGET_UDID=""
99+
TARGET_NAME=""
100+
101+
if [ "$INSTALL" = true ]; then
102+
if [ "$DEVICE_BUILD" = true ]; then
103+
DEV_UDID=""
104+
DEV_NAME=""
105+
pick_device
106+
TARGET_UDID="$DEV_UDID"
107+
TARGET_NAME="$DEV_NAME"
108+
else
109+
SIM_UDID=""
110+
SIM_NAME=""
111+
pick_simulator
112+
TARGET_UDID="$SIM_UDID"
113+
TARGET_NAME="$SIM_NAME"
114+
fi
115+
echo "Target: $TARGET_NAME ($TARGET_UDID)"
116+
echo ""
117+
fi
59118

60119
if [ "$OPEN_XCODE" = true ]; then
61120
WS="$XCODE_DIR/Unity-iPhone.xcworkspace"
@@ -71,13 +130,20 @@ if [ "$SKIP_BUILD" = true ]; then
71130
else
72131
[ ! -x "$UNITY" ] && echo "Unity not found at $UNITY — set UNITY_PATH" && exit 1
73132
mkdir -p "$XCODE_DIR"
74-
echo "Generating Xcode project (IL2CPP / Simulator)..."
133+
134+
if [ "$DEVICE_BUILD" = true ]; then
135+
BUILD_METHOD="BuildScript.BuildiOSDevice"
136+
echo "Generating Xcode project (IL2CPP / Device)..."
137+
else
138+
BUILD_METHOD="BuildScript.BuildiOSSimulator"
139+
echo "Generating Xcode project (IL2CPP / Simulator)..."
140+
fi
75141
echo "Log: $LOG"
76142
echo ""
77143

78144
START=$(date +%s)
79145
"$UNITY" -batchmode -nographics -quit -buildTarget iOS \
80-
-projectPath "$SCRIPT_DIR" -executeMethod BuildScript.BuildiOSSimulator \
146+
-projectPath "$SCRIPT_DIR" -executeMethod "$BUILD_METHOD" \
81147
-logFile "$LOG"
82148
ELAPSED=$(( $(date +%s) - START ))
83149

@@ -90,22 +156,28 @@ if [ -f "$XCODE_DIR/Podfile" ]; then
90156
(cd "$XCODE_DIR" && pod install --repo-update)
91157
fi
92158

93-
if [ "$INSTALL" = true ] && [ -n "$SIM_UDID" ]; then
159+
if [ "$INSTALL" = true ] && [ -n "$TARGET_UDID" ]; then
94160
echo ""
95-
echo "Building with xcodebuild for simulator..."
161+
echo "Building with xcodebuild..."
96162
WS="$XCODE_DIR/Unity-iPhone.xcworkspace"
97-
[ ! -d "$WS" ] && WS="" # fall back to xcodeproj if no workspace
163+
[ ! -d "$WS" ] && WS=""
164+
165+
if [ "$DEVICE_BUILD" = true ]; then
166+
DESTINATION="generic/platform=iOS"
167+
else
168+
DESTINATION="id=$TARGET_UDID"
169+
fi
98170

99171
BUILD_START=$(date +%s)
100172
if [ -n "$WS" ]; then
101173
xcodebuild -workspace "$WS" -scheme "$SCHEME" \
102-
-destination "id=$SIM_UDID" \
174+
-destination "$DESTINATION" \
103175
-derivedDataPath "$DERIVED" \
104176
-quiet \
105177
build
106178
else
107179
xcodebuild -project "$XCODE_DIR/Unity-iPhone.xcodeproj" -scheme "$SCHEME" \
108-
-destination "id=$SIM_UDID" \
180+
-destination "$DESTINATION" \
109181
-derivedDataPath "$DERIVED" \
110182
-quiet \
111183
build
@@ -116,7 +188,13 @@ if [ "$INSTALL" = true ] && [ -n "$SIM_UDID" ]; then
116188
APP_PATH=$(find "$DERIVED" -name "*.app" -path "*/Build/Products/*" | head -1)
117189
[ -z "$APP_PATH" ] && echo "Could not find .app bundle in derived data." && exit 1
118190

119-
echo "Installing on $SIM_NAME..."
120-
xcrun simctl install "$SIM_UDID" "$APP_PATH"
121-
xcrun simctl launch "$SIM_UDID" "$APP_BUNDLE_ID"
191+
if [ "$DEVICE_BUILD" = true ]; then
192+
echo "Installing on $TARGET_NAME..."
193+
xcrun devicectl device install app --device "$TARGET_UDID" "$APP_PATH"
194+
xcrun devicectl device process launch --device "$TARGET_UDID" "$APP_BUNDLE_ID"
195+
else
196+
echo "Installing on $TARGET_NAME..."
197+
xcrun simctl install "$TARGET_UDID" "$APP_PATH"
198+
xcrun simctl launch "$TARGET_UDID" "$APP_BUNDLE_ID"
199+
fi
122200
fi

0 commit comments

Comments
 (0)