I've read a ton of threads debating if 3D touch is available on the latest Xcode 7 versions. The consensus was that it's possible but only with a 3D phone or trackpad. My question is if with the new Xcode and Simulator, has that changed?
I'm on a 2012 MacBook running Sierra:
I can see some force touch options:
But can I somehow enable those options so I can starting testing my 3D Touch code?
To test 3D touch in the simulator, you would need a force-touch trackpad (i.e. a MacBook with a force-touch trackpad built in, or a Magic Trackpad 2). If you have one, those menu items come to life. If you don't have one, you can only test on a device!
Make sure you also have a device that can support it lol. Had simulator set up to iPhone 5S/SE and didn't realize why it wasn't working (head slap)
Only a MacBook Pro or MacBook 12' after 2015 is shipped with a force-touch trackpad which you can use to simulate 3D touch in Xcode's simulator. You can check that with your mac in System Preferences->Trackpad->Point&Click.
When I search Google, I got SBShortcutMenuSimulator, it's can simulator Quick Action operate in iOS simulator. But, how test peek and pop operate?
I find way! If your have MacBook Pro with ForceTouch Trackpad, you can do it.
Follow:
Choose iOS 9.3 with iPhone 6S Simulator, Find Hardware option on menu bar, check "Use Trackpad force for 3D Touch", then use your force touch Trackpad simulate 3D Touch.
You can use FLEX to check it on the simulator. Using a combination of the command, control, and shift keys, you can simulate different levels of 3D touch pressure in the simulator. Each key contributes 1/3 of maximum possible force. Note that you need to move the touch slightly to get pressure updates.
https://github.com/Flipboard/FLEX
Just remember to exclude FLEX from Release (App Store) Builds
Can I simulate application shortcut on simulator? (With 3D Touch for ios 9)
What is force touch pressure for?
Thanks you all for your quick help. I find this one that can simulate application shortcut. I have tested and it is working.
https://github.com/DeskConnect/SBShortcutMenuSimulator
It is impossible now unfortunately. force touch pressure is different from 3D touch. force touch pressure is for Apple Watch.
As per apples documentation
With Xcode 7.0 you must develop on a device that supports 3D Touch.
Simulator in Xcode 7.0 does not support 3D Touch.
In the simulator menu you seeing Force Touch Pressure is for Apple Watch simulator
You can refer this in the apple developer (https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/index.html#//apple_ref/doc/uid/TP40016543-CH1-SW7)
I am trying to simulate a force touch using Xcode 7 GM on the iPhone 6S or iPhone 6S Plus simulator. In particular, I am trying to simulate the force touch on the icon of the test app which is implementing Application Shortcuts.
Let me know if there is a solution to simulate this, I tried the long press which the Watch simulator uses to simulate force touch, didn't work since the iPhone captures it as a long press gesture.
Update: I downloaded the ViewControllerPreview Sample code from Apple. Running their sample application I see that the simulator, although an iPhone 6s, does not support for 3D / force touch feature. I am still unsure if it would support the feature if I were to be using a macbook with a force touch enabled trackpad.
EDIT: Can someone with a macbook that has a force touch trackpad attempt to use the force touch on the trackpad to simulate 3D touch on the iPhone 6s or 6s Plus simulator? My theory is that you can maybe use the force touch trackpad on the new MacBooks to simulate the 3D touch on new iPhone simulators. Add a comment noting the results if you try it and I can update the post.
EDIT2: It seems that Force Touch trackpads on the newer model macbook pros do not help.
It says here! at the bottom of the page....
Development Environment
Xcode 7 supports 3D Touch development. All the debugging features of Xcode are available for implementing the new features.
Keep the following in mind:
With Xcode 7.0 you must develop on a device that supports 3D Touch. Simulator in Xcode 7.0 does not support 3D Touch.
With Xcode 7.0 you must implement your peek and pop view controllers in code. Interface Builder in Xcode 7.0 does not provide graphical support for configuring view controllers or transitions for 3D Touch.
Be sure to test your app with 3D Touch both enabled and disabled, ensuring that all features are available to all users. On a 3D Touch device, you can disable 3D Touch in Settings > General > Accessibility > 3D Touch
So unfortunately it looks like we need to get our hands on the actual devices to do it. :-(
EDIT.....
As of Xcode 7.3 there is a way to do this if your MacBook's trackpad supports force touch. See answer by #iPrabu.
For those that are developing Quick Actions (App Shortcuts) you can use this script that enables you to simulate a deep press on an app on the simulator.
https://github.com/DeskConnect/SBShortcutMenuSimulator
Here's a screenshot:
For those that are looking at how to add the actions on the first place, there are two options, Static and Dynamic. You can set only 4 options, it will first show all Static ones, and if there's space, show Dynamic ones.
Here's how to add Static shortcuts. It's pretty easy, just add some keys on the main Info.plist
In this example i will be adding two static options one with Default Search icon, and the other with custom icon from asset catalog.
<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemTitle</key>
<string>Add Event (with custom icon)</string>
<key>UIApplicationShortcutItemType</key>
<string>com.reverse.appname.addevent</string>
<key>UIApplicationShortcutItemIconFile</key>
<string>custom-icon-from-asset-catalog</string>
<key>UIApplicationShortcutItemSubtitle</key>
<string>Here you can add some text below the option</string>
</dict>
<dict>
<key>UIApplicationShortcutItemTitle</key>
<string>Search Event (with default icon)</string>
<key>UIApplicationShortcutItemType</key>
<string>com.reverse.appname.searchevents</string>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeSearch</string>
<key>UIApplicationShortcutItemSubtitle</key>
<string>Here you can add some text below the option</string>
</dict>
</array>
With Xcode 7.3 you can test the 3D touch feature in simulator but with only one constraint. (Xcode7.3 release notes reference)
The machine(macbook/mac with trackpad) your are developing should have 3D touch capability.
You can find it under iOS simulator Hardware menu.
Comments from Pavel Alexeev: Be sure to enable “Force Click and haptic feedback” in System Preferences → Trackpad
Force pressure in iOS (eg: Peek & Pop) is not exposed through Xcode 7.0 nor Xcode 7.1 Beta's Simulator. The pressure touch options are only relevant for watchOS devices in those versions of Simulator. If you have the Xcode 7.1 beta, you'll notice that the menu option is actually disabled.
With Xcode 7.3 and the iOS 9.3 and later simulator runtimes, you can test peek/pop functionality using a force touch trackpad.
You can enable 3D Touch in simulator. Thanks to this library.
After adding it Using a combination of the command, control, and shift keys 3D Touch can be enabled.
Don't forget to add library in Debug environment only. Exclude it from Release environment.
For the "Home Screen Quick Actions" touch I made the following:
created an object of UIMutableApplicationShortcutItem
put it into launchOptions to UIApplicationLaunchOptionsShortcutItemKey
and thats it
It looks like user did the 3d touch on the app icon.
let shortcut = UIMutableApplicationShortcutItem(type: ShortcutIdentifier.Third.type,
localizedTitle: "Title",
localizedSubtitle: "Subtitle",
icon: UIApplicationShortcutIcon(type: .Play), userInfo: [
AppDelegate.applicationShortcutUserInfoIconKey: UIApplicationShortcutIconType.Play.rawValue
]
)
let launchOption = [
"UIApplicationLaunchOptionsShortcutItemKey" : shortcut
]
launchOptions = launchOption
(application:didFinishLaunchingWithOptions:)
There's a bit of code here that allows you to test 3D Touch peek & pop in the simulator. Bear in mind this is code for iOS 9.0, and some of the internal/private methods have changed in 9.1 so you'll need to make a few minor changes (Hint: the word 'Position' changed to 'Location' in one of the method names).
https://gist.github.com/nickfrey/07e2c6d8d2e5444fb91d
Both this and https://github.com/DeskConnect/SBShortcutMenuSimulator mentioned in other answers allow you to test for 3D Touch without an actual device fairly competently.
Officially Xcode 7.1 supports 3D touch but not on simulator. You need to have actual device in order to test. Check last paragraph of documentation from Apple.
However, you can use third-party tools to test it on simulator such as one highlighted by Nicolas S above.
The newer macbooks are having force-touch enabled touch pad. I think these options will only work in that.
It worked for me with XCode 9 & iphone 8 simulator.
In your mac go to system preference -> Trackpad -> Enable Force click and haptic feedback.
Then press firmly on any part of iphone simulator to perform force touch action.
I want to make an application for both touch and non-touch device in blackberry.
I don't know how to find the device is touch or not.
Is there any idea.
Touchscreen.isSupported();
This is used to find whether the device is touch or non-touch.
If the device is Touch then it returns
True
else it returns
False
I found that for me, it was better to build the app to cope with both touch and nontouch phones. Remember that devices running firmware older than 4.7 can not load touch enabled apps.