diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 0000000..c5287bd --- /dev/null +++ b/.github/workflows/ios.yml @@ -0,0 +1,44 @@ +name: iOS starter workflow + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: Build and Test default scheme using any available iPhone simulator + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set Default Scheme + run: | + scheme_list=$(xcodebuild -list -json | tr -d "\n") + default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") + echo $default | cat >default + echo Using default scheme: $default + - name: Build + env: + scheme: ${{ 'default' }} + platform: ${{ 'iOS Simulator' }} + run: | + # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) + device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` + if [ $scheme = default ]; then scheme=$(cat default); fi + if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + xcodebuild build-for-testing -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" + - name: Test + env: + scheme: ${{ 'default' }} + platform: ${{ 'iOS Simulator' }} + run: | + # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) + device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` + if [ $scheme = default ]; then scheme=$(cat default); fi + if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + xcodebuild test-without-building -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..238915d --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,19 @@ +name: Swift + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + - name: Build + run: swift build -v + - name: Run tests + run: swift test -v diff --git a/3D Touch - Swift/3D Touch Swift.xcodeproj/project.pbxproj b/3D Touch - Swift/3D Touch Swift.xcodeproj/project.pbxproj index a7c9be9..b3072ee 100644 --- a/3D Touch - Swift/3D Touch Swift.xcodeproj/project.pbxproj +++ b/3D Touch - Swift/3D Touch Swift.xcodeproj/project.pbxproj @@ -197,22 +197,22 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Pinkstone Pictures LLC"; TargetAttributes = { D2E91BEF1C122F3C0037EFE0 = { CreatedOnToolsVersion = 7.1; DevelopmentTeam = F34HMY85N9; - LastSwiftMigration = 0830; + LastSwiftMigration = 0900; }; D2E91C031C122F3C0037EFE0 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 0900; TestTargetID = D2E91BEF1C122F3C0037EFE0; }; D2E91C0E1C122F3C0037EFE0 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 0900; TestTargetID = D2E91BEF1C122F3C0037EFE0; }; }; @@ -328,14 +328,20 @@ 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; @@ -375,14 +381,20 @@ 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; @@ -417,7 +429,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.versluis.-D-Touch-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -430,7 +443,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.versluis.-D-Touch-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -442,7 +456,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.versluis.-D-Touch-SwiftTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/3D Touch Swift.app/3D Touch Swift"; }; name = Debug; @@ -455,7 +470,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.versluis.-D-Touch-SwiftTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/3D Touch Swift.app/3D Touch Swift"; }; name = Release; @@ -467,7 +483,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.versluis.-D-Touch-SwiftUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = "3D Touch Swift"; USES_XCTRUNNER = YES; }; @@ -480,7 +497,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.versluis.-D-Touch-SwiftUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = "3D Touch Swift"; USES_XCTRUNNER = YES; }; diff --git a/3D Touch - Swift/3D Touch Swift.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch Swift.xcscheme b/3D Touch - Swift/3D Touch Swift.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch Swift.xcscheme index a4a987c..2042115 100644 --- a/3D Touch - Swift/3D Touch Swift.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch Swift.xcscheme +++ b/3D Touch - Swift/3D Touch Swift.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch Swift.xcscheme @@ -1,6 +1,6 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1 + 1.2 CFBundleSignature ???? CFBundleVersion - 2 + 3 LSRequiresIPhoneOS UIApplicationShortcutItems diff --git a/3D Touch - Swift/3D Touch Swift/PreviewViewController.swift b/3D Touch - Swift/3D Touch Swift/PreviewViewController.swift index 6953bc8..bd67f84 100644 --- a/3D Touch - Swift/3D Touch Swift/PreviewViewController.swift +++ b/3D Touch - Swift/3D Touch Swift/PreviewViewController.swift @@ -20,7 +20,7 @@ class PreviewViewController: UIViewController { // Dispose of any resources that can be recreated. } - func dismissMe() { + @objc func dismissMe() { // dismiss this view controller self.dismiss(animated: true, completion: nil) diff --git a/3D Touch - Swift/3D Touch Swift/ViewController.swift b/3D Touch - Swift/3D Touch Swift/ViewController.swift index 7727e41..7761196 100644 --- a/3D Touch - Swift/3D Touch Swift/ViewController.swift +++ b/3D Touch - Swift/3D Touch Swift/ViewController.swift @@ -90,7 +90,7 @@ class ViewController: UIViewController, UIViewControllerPreviewingDelegate { // MARK: 3D Touch Alternative - func showPeek() { + @objc func showPeek() { print("showing peek") diff --git a/3D Touch.xcodeproj/project.pbxproj b/3D Touch.xcodeproj/project.pbxproj index db8bab8..08a9585 100644 --- a/3D Touch.xcodeproj/project.pbxproj +++ b/3D Touch.xcodeproj/project.pbxproj @@ -214,7 +214,7 @@ D20FACA61BB039DE00662806 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Pinkstone Pictures LLC"; TargetAttributes = { D20FACAD1BB039DE00662806 = { @@ -350,14 +350,20 @@ 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; @@ -396,14 +402,20 @@ 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; diff --git a/3D Touch.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch.xcscheme b/3D Touch.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch.xcscheme index e8cbbb8..1a9c08a 100644 --- a/3D Touch.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch.xcscheme +++ b/3D Touch.xcodeproj/xcuserdata/versluis.xcuserdatad/xcschemes/3D Touch.xcscheme @@ -1,6 +1,6 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1 + 1.2 CFBundleSignature ???? CFBundleVersion - 2 + 3 LSRequiresIPhoneOS UIApplicationShortcutItems diff --git a/README.md b/README.md index 1afe175..d9d6c6a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 3D Touch -iOS 9 Demo showing how to use 3D Touch on iPhone 6s devices in both Objective-C and Swift. +iOS 9 Demo showing how to use 3D Touch on compatible devices in both Objective-C and Swift 3. If 3D Touch is available, the Main View will bring up a Preview View upon shallow press (Peek), and a Commit View when the user presses deeper (Pop). @@ -20,3 +20,12 @@ I've also added static and dynamic shortcut items to this project. I've explaine Rather than boring log messages, I've added two options for Deep Linking a navigation controller: - Deep Link 1 will launch a navigation controller - Deep Link 2 launches a view controller that has been pushed onto the same navigation controller + +### Workspace Organisation +This repo contains both an Objective-C and a Swift version of the project. I've added them both to the same Workspace to centralise and make it more practical to work with either project. Just in case you're not familiar with Workspaces in Xcode, here's how they work: + +Instead of opening the respective .xcproj file, open 3D-Touch.xcworkspace. You'll then see two projects: + * 3D Touch (that's the Objective-C version), and + * 3D Touch Swift (that's the Swift version). + +You can switch between each version at the top of the screen (next to the play/stop button in Xcode) and choose a different simuluator and target device for each project. You can build and focus on a single project at a time this way, but still maintain multiple projects in the same repository. diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c50ff38 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-merlot \ No newline at end of file