Skip to content

Commit 757399b

Browse files
authored
fix: modernize scripts/build-for-testing.sh (#1819)
* fix: modernize scripts/build-for-testing.sh * dont set xcode within script * fix unbound variable * add back storyboard
1 parent af28e6c commit 757399b

File tree

3 files changed

+166
-2
lines changed

3 files changed

+166
-2
lines changed

messaging/MessagingExample.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
5F99610D1AE0CF4F0034F503 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5F9961071AE0CF4F0034F503 /* LaunchScreen.xib */; };
1818
8DC73D8C2D41AE850092B6EE /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = 8DC73D8B2D41AE850092B6EE /* FirebaseMessaging */; };
1919
978E6F2CAAC2AD673D158985 /* GoogleService-Info.plist in Sources */ = {isa = PBXBuildFile; fileRef = 82E79B6D15A982EAE7B0E31B /* GoogleService-Info.plist */; };
20+
EA2B4E6C2ED4F571003F9A40 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EA2B4E662ED4F571003F9A40 /* Main.storyboard */; };
21+
EA2B4E752ED4F571003F9A40 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EA2B4E662ED4F571003F9A40 /* Main.storyboard */; };
2022
EAC902A32EC6849A000761B8 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = EAC902A22EC6849A000761B8 /* FirebaseMessaging */; };
2123
/* End PBXBuildFile section */
2224

@@ -69,6 +71,7 @@
6971
DEB13BC723AEC9DF0066A6F3 /* FIREGHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIREGHelper.m; sourceTree = "<group>"; };
7072
DEB13BC823AEC9DF0066A6F3 /* FIREGSignInHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FIREGSignInHelper.h; sourceTree = "<group>"; };
7173
DED65CF723E9DE6400461312 /* FIREGSignInInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FIREGSignInInfo.h; sourceTree = "<group>"; };
74+
EA2B4E652ED4F571003F9A40 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
7275
EAE93A8D2E86E558005ABAF0 /* MessagingExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MessagingExample.entitlements; sourceTree = "<group>"; };
7376
/* End PBXFileReference section */
7477

@@ -175,6 +178,7 @@
175178
EAE93A8A2E86E465005ABAF0 /* MessagingExample */ = {
176179
isa = PBXGroup;
177180
children = (
181+
EA2B4E662ED4F571003F9A40 /* Main.storyboard */,
178182
EAE93A8D2E86E558005ABAF0 /* MessagingExample.entitlements */,
179183
5F5A537D1ADE67D500F81DF0 /* AppDelegate.swift */,
180184
5F5A537F1ADE67D500F81DF0 /* ViewController.swift */,
@@ -310,6 +314,7 @@
310314
isa = PBXResourcesBuildPhase;
311315
buildActionMask = 2147483647;
312316
files = (
317+
EA2B4E6C2ED4F571003F9A40 /* Main.storyboard in Resources */,
313318
);
314319
runOnlyForDeploymentPostprocessing = 0;
315320
};
@@ -319,6 +324,7 @@
319324
files = (
320325
5F99610D1AE0CF4F0034F503 /* LaunchScreen.xib in Resources */,
321326
5F99610B1AE0CF4F0034F503 /* Images.xcassets in Resources */,
327+
EA2B4E752ED4F571003F9A40 /* Main.storyboard in Resources */,
322328
);
323329
runOnlyForDeploymentPostprocessing = 0;
324330
};
@@ -367,6 +373,17 @@
367373
};
368374
/* End PBXTargetDependency section */
369375

376+
/* Begin PBXVariantGroup section */
377+
EA2B4E662ED4F571003F9A40 /* Main.storyboard */ = {
378+
isa = PBXVariantGroup;
379+
children = (
380+
EA2B4E652ED4F571003F9A40 /* Base */,
381+
);
382+
name = Main.storyboard;
383+
sourceTree = "<group>";
384+
};
385+
/* End PBXVariantGroup section */
386+
370387
/* Begin XCBuildConfiguration section */
371388
0718C8C02E8F256800AA7788 /* Debug */ = {
372389
isa = XCBuildConfiguration;
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18121" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="dvH-Ce-6yG">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18091"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
8+
</dependencies>
9+
<scenes>
10+
<!--FCM Example-->
11+
<scene sceneID="tne-QT-ifu">
12+
<objects>
13+
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
14+
<layoutGuides>
15+
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
16+
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
17+
</layoutGuides>
18+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
19+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
20+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
21+
<subviews>
22+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="S9T-hp-Ka1">
23+
<rect key="frame" x="107.5" y="311.5" width="160" height="44"/>
24+
<constraints>
25+
<constraint firstAttribute="height" constant="44" id="Grv-Ur-3qm"/>
26+
<constraint firstAttribute="width" constant="160" id="ggk-PO-zor"/>
27+
</constraints>
28+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
29+
<state key="normal" title="Log Token"/>
30+
<connections>
31+
<action selector="handleLogTokenTouch:" destination="BYZ-38-t0r" eventType="touchUpInside" id="3NM-R6-4A4"/>
32+
</connections>
33+
</button>
34+
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HgF-jF-1NC">
35+
<rect key="frame" x="204" y="233" width="192" height="44"/>
36+
<color key="backgroundColor" red="1" green="0.56078431370000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
37+
<constraints>
38+
<constraint firstAttribute="width" constant="192" id="4Yd-c9-aCb"/>
39+
<constraint firstAttribute="height" constant="44" id="gyc-AL-1xz"/>
40+
</constraints>
41+
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
42+
<state key="normal" title="Subscribe To Weather">
43+
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
44+
</state>
45+
<connections>
46+
<action selector="handleSubscribeTouch:" destination="BYZ-38-t0r" eventType="touchUpInside" id="meX-vb-HDO"/>
47+
</connections>
48+
</button>
49+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No FCM token" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RBg-uJ-gCV">
50+
<rect key="frame" x="67.5" y="459" width="240" height="14"/>
51+
<constraints>
52+
<constraint firstAttribute="width" constant="240" id="R9g-We-nKc"/>
53+
</constraints>
54+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
55+
<nil key="textColor"/>
56+
<nil key="highlightedColor"/>
57+
</label>
58+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No FCM Registration token" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1wF-0v-e01">
59+
<rect key="frame" x="67.5" y="565" width="240" height="13.5"/>
60+
<constraints>
61+
<constraint firstAttribute="width" constant="240" id="FXq-Tm-sRh"/>
62+
</constraints>
63+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
64+
<nil key="textColor"/>
65+
<nil key="highlightedColor"/>
66+
</label>
67+
</subviews>
68+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
69+
<constraints>
70+
<constraint firstItem="1wF-0v-e01" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="0wR-rN-VBn"/>
71+
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="RBg-uJ-gCV" secondAttribute="bottom" constant="194" id="4Cj-3x-9JW"/>
72+
<constraint firstItem="RBg-uJ-gCV" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="7XG-os-4BL"/>
73+
<constraint firstItem="RBg-uJ-gCV" firstAttribute="top" secondItem="S9T-hp-Ka1" secondAttribute="bottom" constant="103.5" id="dJ0-an-jgk"/>
74+
<constraint firstItem="S9T-hp-Ka1" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="eqV-Gc-7aa"/>
75+
<constraint firstItem="S9T-hp-Ka1" firstAttribute="top" secondItem="HgF-jF-1NC" secondAttribute="bottom" constant="8" id="izK-fQ-Uu7"/>
76+
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="1wF-0v-e01" secondAttribute="bottom" constant="88.5" id="p2q-F9-Mpu"/>
77+
<constraint firstItem="HgF-jF-1NC" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="st1-B5-WH3"/>
78+
<constraint firstItem="S9T-hp-Ka1" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="wHX-8g-0MB"/>
79+
</constraints>
80+
</view>
81+
<navigationItem key="navigationItem" title="FCM Example" id="uI5-jL-nrY"/>
82+
<connections>
83+
<outlet property="fcmTokenMessage" destination="RBg-uJ-gCV" id="FUs-GZ-mfF"/>
84+
<outlet property="remoteFCMTokenMessage" destination="1wF-0v-e01" id="nDz-D9-60k"/>
85+
</connections>
86+
</viewController>
87+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
88+
</objects>
89+
<point key="canvasLocation" x="311.19999999999999" y="445.72713643178412"/>
90+
</scene>
91+
<!--Navigation Controller-->
92+
<scene sceneID="BBa-0w-b0R">
93+
<objects>
94+
<navigationController id="dvH-Ce-6yG" sceneMemberID="viewController">
95+
<navigationBar key="navigationBar" contentMode="scaleToFill" barStyle="black" id="FZU-Jb-Wzn">
96+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
97+
<autoresizingMask key="autoresizingMask"/>
98+
<color key="barTintColor" red="0.0" green="0.52156862745098043" blue="0.88627450980392153" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
99+
</navigationBar>
100+
<connections>
101+
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="Sil-bt-Y94"/>
102+
</connections>
103+
</navigationController>
104+
<placeholder placeholderIdentifier="IBFirstResponder" id="cPh-2w-0HS" userLabel="First Responder" sceneMemberID="firstResponder"/>
105+
</objects>
106+
<point key="canvasLocation" x="-381" y="451"/>
107+
</scene>
108+
</scenes>
109+
</document>

scripts/build-for-testing.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,30 @@
2222

2323
set -euo pipefail
2424

25+
xcode_version=$(xcodebuild -version | grep Xcode)
26+
xcode_version="${xcode_version/Xcode /}"
27+
xcode_major="${xcode_version/.*/}"
28+
29+
if [[ "$xcode_major" -ge 26 ]]; then
30+
iphone_version="17"
31+
elif [[ "$xcode_major" -ge 16 ]]; then
32+
iphone_version="16"
33+
else
34+
echo "Unsupported Xcode version $xcode_version; exiting." 1>&2
35+
exit 1
36+
fi
37+
2538
# Set default parameters
2639
if [[ -z "${SPM:-}" ]]; then
2740
SPM=false
2841
echo "Defaulting to SPM=$SPM"
2942
fi
43+
if [[ -z "${OS:-}" ]]; then
44+
OS=iOS
45+
DEVICE="iPhone ${iphone_version}"
46+
echo "Defaulting to OS=$OS"
47+
echo "Defaulting to DEVICE=$DEVICE"
48+
fi
3049

3150
# Set have_secrets to true or false.
3251
source scripts/check_secrets.sh
@@ -45,7 +64,26 @@ fi
4564
# Set scheme
4665
if [[ -z "${SCHEME:-}" ]]; then
4766
if [[ "$SPM" == true ]];then
48-
SCHEME="${SAMPLE}Example (${OS})"
67+
# Get the list of schemes
68+
schemes=$(xcodebuild -list -project "${DIR}/${SAMPLE}Example.xcodeproj" |
69+
grep -E '^\s+' |
70+
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
71+
72+
# Check for the OS-suffixed scheme name
73+
if echo "$schemes" | grep -q "^${SAMPLE}Example (${OS})$"; then
74+
SCHEME="${SAMPLE}Example (${OS})"
75+
# Check for the Swift-suffixed scheme
76+
elif echo "$schemes" | grep -q "^${SAMPLE}ExampleSwift$"; then
77+
SCHEME="${SAMPLE}ExampleSwift"
78+
# Check for the base scheme name
79+
elif echo "$schemes" | grep -q "^${SAMPLE}Example$"; then
80+
SCHEME="${SAMPLE}Example"
81+
else
82+
echo "Error: Could not find a suitable scheme for ${SAMPLE}Example in ${OS}."
83+
echo "Available schemes:"
84+
echo "$schemes"
85+
exit 1
86+
fi
4987
else
5088
SCHEME="${SAMPLE}Example${SWIFT_SUFFIX:-}"
5189
fi
@@ -82,7 +120,7 @@ function xcb() {
82120
}
83121

84122
# Run xcodebuild
85-
sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
123+
sudo xcode-select -p
86124
xcb "${flags[@]}"
87125
echo "$message"
88126

0 commit comments

Comments
 (0)