Skip to content

Commit

Permalink
Updated sample code to Xcode 9.0 and iOS SDK 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
warrenm committed Oct 13, 2017
1 parent 99162f8 commit fed1c83
Show file tree
Hide file tree
Showing 38 changed files with 374 additions and 82 deletions.
21 changes: 19 additions & 2 deletions objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
833FBBB11BBE0B0E001EFE4D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 833FBBAF1BBE0B0E001EFE4D /* Main.storyboard */; };
833FBBB31BBE0B0E001EFE4D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 833FBBB21BBE0B0E001EFE4D /* Assets.xcassets */; };
833FBBB61BBE0B0E001EFE4D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 833FBBB41BBE0B0E001EFE4D /* LaunchScreen.storyboard */; };
833FBBBF1BBE0C19001EFE4D /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 833FBBBE1BBE0C19001EFE4D /* MBEMetalView.m */; settings = {ASSET_TAGS = (); }; };
833FBBBF1BBE0C19001EFE4D /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 833FBBBE1BBE0C19001EFE4D /* MBEMetalView.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -110,7 +110,7 @@
833FBB9B1BBE0B0E001EFE4D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Metal by Example";
TargetAttributes = {
833FBBA21BBE0B0E001EFE4D = {
Expand Down Expand Up @@ -191,13 +191,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -235,13 +243,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -308,6 +324,7 @@
833FBBBC1BBE0B0E001EFE4D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -32,6 +42,16 @@
"filename" : "Icon@3x.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -63,6 +83,16 @@
"idiom" : "ipad",
"filename" : "Icon~ipad@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
31 changes: 24 additions & 7 deletions objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
83E2D7721BD188110006DDD8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D7701BD188110006DDD8 /* Main.storyboard */; };
83E2D7741BD188110006DDD8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D7731BD188110006DDD8 /* Assets.xcassets */; };
83E2D7771BD188110006DDD8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D7751BD188110006DDD8 /* LaunchScreen.storyboard */; };
83E2D7811BD188710006DDD8 /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D77F1BD188710006DDD8 /* MBEMetalView.m */; settings = {ASSET_TAGS = (); }; };
83E2D7821BD188710006DDD8 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7801BD188710006DDD8 /* Shaders.metal */; settings = {ASSET_TAGS = (); }; };
83E2D7811BD188710006DDD8 /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D77F1BD188710006DDD8 /* MBEMetalView.m */; };
83E2D7821BD188710006DDD8 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7801BD188710006DDD8 /* Shaders.metal */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
83E2D7641BD188110006DDD8 /* DrawingIn2D.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DrawingIn2D.app"; sourceTree = BUILT_PRODUCTS_DIR; };
83E2D7641BD188110006DDD8 /* DrawingIn2D.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DrawingIn2D.app; sourceTree = BUILT_PRODUCTS_DIR; };
83E2D7681BD188110006DDD8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
83E2D76A1BD188110006DDD8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
83E2D76B1BD188110006DDD8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -76,7 +76,7 @@
83E2D7781BD188110006DDD8 /* Info.plist */,
83E2D7671BD188110006DDD8 /* Supporting Files */,
);
path = "DrawingIn2D";
path = DrawingIn2D;
sourceTree = "<group>";
};
83E2D7671BD188110006DDD8 /* Supporting Files */ = {
Expand All @@ -102,8 +102,8 @@
);
dependencies = (
);
name = "DrawingIn2D";
productName = "DrawingIn2D";
name = DrawingIn2D;
productName = DrawingIn2D;
productReference = 83E2D7641BD188110006DDD8 /* DrawingIn2D.app */;
productType = "com.apple.product-type.application";
};
Expand All @@ -113,7 +113,7 @@
83E2D75C1BD188110006DDD8 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Metal by Example";
TargetAttributes = {
83E2D7631BD188110006DDD8 = {
Expand Down Expand Up @@ -195,13 +195,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -239,13 +247,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -312,6 +328,7 @@
83E2D77D1BD188110006DDD8 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
22 changes: 22 additions & 0 deletions objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ - (void)didMoveToSuperview
}
}

- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];

// During the first layout pass, we will not be in a view hierarchy, so we guess our scale
CGFloat scale = [UIScreen mainScreen].scale;

// If we've moved to a window by the time our frame is being set, we can take its scale as our own
if (self.window)
{
scale = self.window.screen.scale;
}

CGSize drawableSize = self.bounds.size;

// Since drawable size is in pixels, we need to multiply by the scale to move from points to pixels
drawableSize.width *= scale;
drawableSize.height *= scale;

self.metalLayer.drawableSize = drawableSize;
}

- (CAMetalLayer *)metalLayer {
return (CAMetalLayer *)self.layer;
}
Expand Down
26 changes: 21 additions & 5 deletions objc/04-DrawingIn3D/DrawingIn3D.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
83E2D79A1BD597A30006DDD8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D7981BD597A30006DDD8 /* Main.storyboard */; };
83E2D79C1BD597A30006DDD8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D79B1BD597A30006DDD8 /* Assets.xcassets */; };
83E2D79F1BD597A30006DDD8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D79D1BD597A30006DDD8 /* LaunchScreen.storyboard */; };
83E2D7B21BD598810006DDD8 /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7A71BD598810006DDD8 /* MBEMetalView.m */; settings = {ASSET_TAGS = (); }; };
83E2D7B51BD598810006DDD8 /* MBERenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7AC1BD598810006DDD8 /* MBERenderer.m */; settings = {ASSET_TAGS = (); }; };
83E2D7B61BD598810006DDD8 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7AD1BD598810006DDD8 /* Shaders.metal */; settings = {ASSET_TAGS = (); }; };
83E2D7B81BD598810006DDD8 /* MBEMathUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7B11BD598810006DDD8 /* MBEMathUtilities.m */; settings = {ASSET_TAGS = (); }; };
83E2D7B21BD598810006DDD8 /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7A71BD598810006DDD8 /* MBEMetalView.m */; };
83E2D7B51BD598810006DDD8 /* MBERenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7AC1BD598810006DDD8 /* MBERenderer.m */; };
83E2D7B61BD598810006DDD8 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7AD1BD598810006DDD8 /* Shaders.metal */; };
83E2D7B81BD598810006DDD8 /* MBEMathUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7B11BD598810006DDD8 /* MBEMathUtilities.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -123,7 +123,7 @@
83E2D7841BD597A30006DDD8 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Metal by Example";
TargetAttributes = {
83E2D78B1BD597A30006DDD8 = {
Expand Down Expand Up @@ -207,13 +207,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -251,13 +259,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down
Loading

0 comments on commit fed1c83

Please sign in to comment.