Skip to content

Commit 793c077

Browse files
committed
tweaks to chapter 9 examples; converted one project to the new Info.plist format (interesting exercise)
1 parent f284d0c commit 793c077

File tree

9 files changed

+59
-73
lines changed

9 files changed

+59
-73
lines changed

bk1ch09p380unitTesting/EmptyWindowTests/EmptyWindowTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class EmptyWindowTests: XCTestCase {
7474
}
7575

7676
func testCustomAssertion() {
77+
return; // comment out to try it
7778
let loc = XCTSourceCodeLocation(filePath: #file, lineNumber: #line) // point of failure
7879
var issue = XCTIssue(type: .assertionFailure, compactDescription: "oh darn")
7980
issue.add(XCTAttachment(string:"yipes"))

bk1ch09p380unitTesting/TestPlan2.xctestplan

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
},
1414
"testTargets" : [
1515
{
16-
"enabled" : false,
1716
"target" : {
1817
"containerPath" : "container:bk1ch09p380unitTesting.xcodeproj",
1918
"identifier" : "814A1AAF1D109C1F008F3FF6",
2019
"name" : "EmptyWindowTests"
2120
}
2221
},
2322
{
23+
"enabled" : false,
2424
"target" : {
2525
"containerPath" : "container:bk1ch09p380unitTesting.xcodeproj",
2626
"identifier" : "814A1AA11D109B13008F3FF6",

bk1ch09p380unitTesting/bk1ch09p380unitTesting/Base.lproj/Main.storyboard

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19158" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17105"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19141"/>
66
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
@@ -16,7 +16,7 @@
1616
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1717
<subviews>
1818
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KSR-PR-fGd">
19-
<rect key="frame" x="44" y="45" width="61" height="30"/>
19+
<rect key="frame" x="52" y="162" width="61" height="30"/>
2020
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2121
<accessibility key="accessibilityConfiguration" identifier="GreetingButton"/>
2222
<state key="normal" title="Hello"/>

bk1ch09p397localization/Empty Window.xcodeproj/project.pbxproj

+24-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 55;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -109,7 +109,7 @@
109109
};
110110
};
111111
buildConfigurationList = 818047471F2E5DF20096D446 /* Build configuration list for PBXProject "Empty Window" */;
112-
compatibilityVersion = "Xcode 9.3";
112+
compatibilityVersion = "Xcode 13.0";
113113
developmentRegion = en;
114114
hasScannedForEncodings = 0;
115115
knownRegions = (
@@ -241,7 +241,7 @@
241241
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
242242
GCC_WARN_UNUSED_FUNCTION = YES;
243243
GCC_WARN_UNUSED_VARIABLE = YES;
244-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
244+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
245245
MTL_ENABLE_DEBUG_INFO = YES;
246246
ONLY_ACTIVE_ARCH = YES;
247247
SDKROOT = iphoneos;
@@ -293,7 +293,7 @@
293293
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294294
GCC_WARN_UNUSED_FUNCTION = YES;
295295
GCC_WARN_UNUSED_VARIABLE = YES;
296-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
296+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
297297
MTL_ENABLE_DEBUG_INFO = NO;
298298
SDKROOT = iphoneos;
299299
SWIFT_COMPILATION_MODE = wholemodule;
@@ -306,15 +306,25 @@
306306
isa = XCBuildConfiguration;
307307
buildSettings = {
308308
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
309+
CURRENT_PROJECT_VERSION = 1;
309310
DEVELOPMENT_TEAM = W3LHX5RGV2;
311+
GENERATE_INFOPLIST_FILE = YES;
310312
INFOPLIST_FILE = "Empty Window/Info.plist";
313+
INFOPLIST_KEY_CFBundleDisplayName = "Empty Window";
314+
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
315+
INFOPLIST_KEY_UIMainStoryboardFile = Main;
316+
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
317+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortraitUpsideDown";
318+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
311319
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
312320
LD_RUNPATH_SEARCH_PATHS = (
313321
"$(inherited)",
314322
"@executable_path/Frameworks",
315323
);
324+
MARKETING_VERSION = 1.0;
316325
PRODUCT_BUNDLE_IDENTIFIER = "com.neuburg.matt.Empty-Window";
317326
PRODUCT_NAME = "$(TARGET_NAME)";
327+
SWIFT_EMIT_LOC_STRINGS = YES;
318328
SWIFT_VERSION = 5.0;
319329
TARGETED_DEVICE_FAMILY = "1,2";
320330
};
@@ -324,15 +334,25 @@
324334
isa = XCBuildConfiguration;
325335
buildSettings = {
326336
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
337+
CURRENT_PROJECT_VERSION = 1;
327338
DEVELOPMENT_TEAM = W3LHX5RGV2;
339+
GENERATE_INFOPLIST_FILE = YES;
328340
INFOPLIST_FILE = "Empty Window/Info.plist";
341+
INFOPLIST_KEY_CFBundleDisplayName = "Empty Window";
342+
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
343+
INFOPLIST_KEY_UIMainStoryboardFile = Main;
344+
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
345+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortraitUpsideDown";
346+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
329347
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
330348
LD_RUNPATH_SEARCH_PATHS = (
331349
"$(inherited)",
332350
"@executable_path/Frameworks",
333351
);
352+
MARKETING_VERSION = 1.0;
334353
PRODUCT_BUNDLE_IDENTIFIER = "com.neuburg.matt.Empty-Window";
335354
PRODUCT_NAME = "$(TARGET_NAME)";
355+
SWIFT_EMIT_LOC_STRINGS = YES;
336356
SWIFT_VERSION = 5.0;
337357
TARGETED_DEVICE_FAMILY = "1,2";
338358
};

bk1ch09p397localization/Empty Window.xcodeproj/xcshareddata/xcschemes/Empty Window.xcscheme

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
buildConfiguration = "Debug"
3535
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3636
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
language = "fr"
38+
region = "FR"
3739
launchStyle = "0"
3840
useCustomWorkingDirectory = "NO"
3941
ignoresPersistentStateOnLaunch = "NO"

bk1ch09p397localization/Empty Window/Base.lproj/Main.storyboard

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14835.7" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19158" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14790.5"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19141"/>
76
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
87
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
98
</dependencies>
@@ -16,21 +15,21 @@
1615
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1716
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1817
<subviews>
19-
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YMD-h7-RKH">
20-
<rect key="frame" x="36" y="32" width="95" height="30"/>
18+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="LocalizableImage" translatesAutoresizingMaskIntoConstraints="NO" id="tWA-Vk-4PR">
19+
<rect key="frame" x="33" y="181" width="180" height="180"/>
20+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
21+
</imageView>
22+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YMD-h7-RKH">
23+
<rect key="frame" x="33" y="84" width="95" height="30"/>
2124
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2225
<state key="normal" title="Hello"/>
2326
<connections>
2427
<action selector="buttonPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="r42-fS-mRa"/>
2528
</connections>
2629
</button>
27-
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="LocalizableImage" translatesAutoresizingMaskIntoConstraints="NO" id="tWA-Vk-4PR">
28-
<rect key="frame" x="33" y="110" width="180" height="180"/>
29-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
30-
</imageView>
3130
</subviews>
32-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3331
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
32+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3433
</view>
3534
</viewController>
3635
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict>
5-
<key>CFBundleDevelopmentRegion</key>
6-
<string>$(DEVELOPMENT_LANGUAGE)</string>
7-
<key>CFBundleDisplayName</key>
8-
<string>Empty Window</string>
9-
<key>CFBundleExecutable</key>
10-
<string>$(EXECUTABLE_NAME)</string>
11-
<key>CFBundleIdentifier</key>
12-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13-
<key>CFBundleInfoDictionaryVersion</key>
14-
<string>6.0</string>
15-
<key>CFBundleName</key>
16-
<string>$(PRODUCT_NAME)</string>
17-
<key>CFBundlePackageType</key>
18-
<string>APPL</string>
19-
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
21-
<key>CFBundleVersion</key>
22-
<string>1</string>
23-
<key>LSRequiresIPhoneOS</key>
24-
<true/>
25-
<key>UILaunchStoryboardName</key>
26-
<string>LaunchScreen</string>
27-
<key>UIMainStoryboardFile</key>
28-
<string>Main</string>
29-
<key>UIRequiredDeviceCapabilities</key>
30-
<array>
31-
<string>armv7</string>
32-
</array>
33-
<key>UISupportedInterfaceOrientations</key>
34-
<array>
35-
<string>UIInterfaceOrientationPortrait</string>
36-
<string>UIInterfaceOrientationLandscapeLeft</string>
37-
<string>UIInterfaceOrientationLandscapeRight</string>
38-
</array>
39-
<key>UISupportedInterfaceOrientations~ipad</key>
40-
<array>
41-
<string>UIInterfaceOrientationPortrait</string>
42-
<string>UIInterfaceOrientationPortraitUpsideDown</string>
43-
<string>UIInterfaceOrientationLandscapeLeft</string>
44-
<string>UIInterfaceOrientationLandscapeRight</string>
45-
</array>
46-
</dict>
4+
<dict/>
475
</plist>

bk1ch09p397localization/Empty Window/ViewController.swift

+12-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ class ViewController: UIViewController {
66

77

88
@IBAction func buttonPressed(_ sender: Any) {
9+
let greeting = String(
10+
localized: "Howdy!",
11+
comment: "Alert title: Say hello")
12+
let message = String(
13+
localized: "You tapped me!",
14+
comment: "Alert message: Report a tap")
15+
let ok = String(
16+
localized: "OK",
17+
comment: "Alert button: accept and dismiss")
918
let alert = UIAlertController(
10-
title: NSLocalizedString(
11-
"Greeting", value:"Howdy!", comment:"Say hello"),
12-
message: NSLocalizedString(
13-
"Tapped", value:"You tapped me!", comment:"User tapped button"),
19+
title: greeting,
20+
message: message,
1421
preferredStyle: .alert)
1522
alert.addAction(
16-
UIAlertAction(title: NSLocalizedString(
17-
"Accept", value:"OK", comment:"Dismiss"),
23+
UIAlertAction(title: ok,
1824
style: .cancel))
1925
self.present(alert, animated: true)
2026
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/* Dismiss */
2-
"Accept" = "OK";
1+
/* Alert title: Say hello */
2+
"Howdy!" = "Bonjour!";
33

4-
/* Say hello */
5-
"Greeting" = "Bonjour!";
4+
/* Alert button: accept and dismiss */
5+
"OK" = "OK";
66

7-
/* User tapped button */
8-
"Tapped" = "Vous m'avez tapé!";
7+
/* Alert message: Report a tap */
8+
"You tapped me!" = "Vous m'avez tapé!";
99

0 commit comments

Comments
 (0)