RideBooking Concept using sirikit xcode 8 - ios

As we know that xcode 8 is ingrates with all new features. I started working on the siri kit apps. Taking concept of Ride booking. I followed all the steps and completed coding part. Unfortunately i'm unable to run app in siri. Please correct me what i miss or what change should i do to proceed further.
Process followed :-
Added new targets with intents along with UI option enabled.
Added " NSSiriUsageDescription " in project info plist.
Adding Ride Booking Intents in the info plist of intent handler
Custom designed Intent layout with buttons and map.
Error Receiving while running the app :-
Sorry, name, somethings gone wrong. can you try that again ?
Thanks in advance for helping me out. please post any example or how to work with ride booking ?

I am also doing the same thing as you are doing. But I resolved my issues and here I share my code:
Step 1: AppDelegate:
INPreferences.requestSiriAuthorization {
switch $0 {
case .authorized:
print("authorized")
break
case .notDetermined:
print("notDetermined")
break
case .restricted:
print("restricted")
break
case .denied:
print("denied")
break
}
}
Step 2: Create a plist file which will store all your intents and vocabulary in Main project (AppIntentVocabulary.plist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ParameterVocabularies</key>
<array>
<dict>
<key>ParameterNames</key>
<array>
<string>INRequestRideIntent.SlideToOpen</string>
</array>
<key>ParameterVocabulary</key>
<array>
<dict>
<key>VocabularyItemIdentifier</key>
<string>slide_to_open</string>
<key>VocabularyItemSynonyms</key>
<array>
<dict>
<key>VocabularyItemExamples</key>
<array>
<string>Book ride in MyApp</string>
</array>
</dict>
</array>
</dict>
</array>
</dict>
</array>
<key>IntentPhrases</key>
<array>
<dict>
<key>IntentName</key>
<string>INRequestRideIntent</string>
<key>IntentExamples</key>
<array>
<string>Book smart parking</string>
<string>Get ETA Way</string>
<string>Go Online in Way</string>
<string>Book ride in Way</string>
<string>Book table in way</string>
</array>
</dict>
</array>
Step 3: In your IntentHandler class, extend your class by INRequestRideIntentHandling, INGetRideStatusIntentHandling, INListRideOptionsIntentHandling delegates.
Stpe 4: Add handle method for handling your ride request:
func handle(requestRide intent: INRequestRideIntent, completion: #escaping (INRequestRideIntentResponse) -> Void) {
}
func handle(getRideStatus intent: INGetRideStatusIntent, completion: #escaping (INGetRideStatusIntentResponse) -> Void) {
}
func handle(listRideOptions intent: INListRideOptionsIntent, completion: #escaping (INListRideOptionsIntentResponse) -> Void) {
let response = INListRideOptionsIntentResponse(code: .success, userActivity: nil)
let smallCarOption = INRideOption(name: "Small Car", estimatedPickupDate: Date(timeIntervalSinceNow: 3 * 60)) // You must provide a name and estimated pickup date.
smallCarOption.priceRange = INPriceRange(firstPrice: NSDecimalNumber(string: "5.60") , secondPrice: NSDecimalNumber(string: "10.78"), currencyCode: "USD") // There are different ways to define a price range and depending on which initializer you use, Maps may change the formatting of the price.
smallCarOption.disclaimerMessage = "This is a very small car, tall passengers may not fit." // A message that is specific to this ride option.
smallCarOption.availablePartySizeOptions = [
INRidePartySizeOption(partySizeRange: NSRange(location: 0, length: 1), sizeDescription: "One person", priceRange: nil),
INRidePartySizeOption(partySizeRange: NSRange(location: 0, length: 2), sizeDescription: "Two people", priceRange: INPriceRange(firstPrice: NSDecimalNumber(string: "6.60") , secondPrice: NSDecimalNumber(string: "11.78"), currencyCode: "USD"))
]
smallCarOption.availablePartySizeOptionsSelectionPrompt = "Choose a party size"
smallCarOption.specialPricing = "High demand. 50% extra will be added to your fare."
smallCarOption.specialPricingBadgeImage = INImage(named: "specialPricingBadge")
let base = INRideFareLineItem(title: "Base fare", price: NSDecimalNumber(string: "4.76"), currencyCode: "USD" )!
let airport = INRideFareLineItem(title: "Airport fee", price: NSDecimalNumber(string: "3.00"), currencyCode: "USD" )!
let discount = INRideFareLineItem(title: "Promo code (3fs8sdx)", price: NSDecimalNumber(string: "-4.00"), currencyCode: "USD" )!
smallCarOption.fareLineItems = [ base, airport, discount ]
smallCarOption.userActivityForBookingInApplication = NSUserActivity(activityType: "bookInApp");
response.rideOptions = [ smallCarOption ]
let paymentMethod = INPaymentMethod(type: .credit, name: "Visa Platinum", identificationHint: "•••• •••• •••• 1234", icon: INImage(named: "creditCardImage"))
let applePay = INPaymentMethod.applePay() // If you support Pay and the user has an Pay payment method set in your parent app
response.paymentMethods = [ paymentMethod, applePay ]
response.expirationDate = Date(timeIntervalSinceNow: 5 * 60)
}
func confirm(requestRide intent: INRequestRideIntent, completion: #escaping (INRequestRideIntentResponse) -> Void) {
let rideOption = INRideOption(name: "Small car", estimatedPickupDate: Date(timeIntervalSinceNow: 5 * 60))
let rideStatus = INRideStatus()
rideStatus.rideOption = rideOption
rideStatus.estimatedPickupDate = Date(timeIntervalSinceNow: 5 * 60)
rideStatus.rideIdentifier = NSUUID().uuidString
let response = INRequestRideIntentResponse(code: .success, userActivity: nil)
response.rideStatus = rideStatus
completion(response)
}
func startSendingUpdates(forGetRideStatus intent: INGetRideStatusIntent, to observer: INGetRideStatusIntentResponseObserver) {
}
func stopSendingUpdates(forGetRideStatus intent: INGetRideStatusIntent) {
}
Step 5: Add INRequestRideIntent in NSExtension in Info.plist in both Intent extensions.
Step 6: First build & run app in your device and run your extension in your device.
If it returns an error like you are describing then just add CoreLocation.framework in your project and run the app again.

Related

Apple Local Push Connectivity with error nil?

I'm trying to configure Local Push Connectivity. I already have Local Push Entitlement, and have install a provisioning profile with local push entitlement. It's build fine but when app start, PushProvider didn't active and start and Push Manager show error nil. I have done every instructions that sample code have provided.
This is my project.
In my application target, I have a bundle id com.my_team_name.my_app_name
and in the app group name group.com.my_team_name.my_app_name
In the .entitlement, I've set the required configuration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>app-push-provider</string>
</array>
<key>com.apple.developer.networking.wifi-info</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.my_team_name.my_app_name</string>
</array>
</dict>
</plist>
Info.plist has noting to change
And I have a PushManager Class with this code
class AppPushManager: NSObject, NEAppPushDelegate{
func appPushManager(_ manager: NEAppPushManager, didReceiveIncomingCallWithUserInfo userInfo: [AnyHashable : Any] = [:]) {
}
static let shared = AppPushManager()
private var pushManager: NEAppPushManager = NEAppPushManager()
private let pushManagerDescription = "PushDefaultConfiguration"
private let pushProviderBundleIdentifier = "com.my_team_name.my_app_name.PushProvider"
func initialize() {
if pushManager.delegate == nil {
pushManager.delegate = self
}
pushManager.localizedDescription = pushManagerDescription
pushManager.providerBundleIdentifier = pushProviderBundleIdentifier
pushManager.isEnabled = true
pushManager.providerConfiguration = [
"host": "my_server.local"
]
pushManager.matchSSIDs = ["my_wifi_ssid"]
pushManager.saveToPreferences(completionHandler: { error in
print("error? \(String(describing: error))")
print("is active: \(pushManager.isActive)")
})
}
}
In my extension, A PushProvider Target. I have a bundle id com.my_team_name.my_app_name.PushProvider
and in the app group name group.com.my_team_name.my_app_name
In the Info.plist of my extension, I've added the required configuration:
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.networkextension.app-push</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).PushProvider</string>
</dict>
the .entitlement file have the same contents as the application.
and I have created the extension class "PushProvider.swift" as follow:
class PushProvider: NEAppPushProvider {
...
}
When I run the application, I got this printed out
error? nil
is active: false
I think it might be something with providerBundleIdentifier in Push Manager. Have anyone know what I've missing?

How to read different type of NFC Tag in NFCTagReaderSession in iOS 13?

For reading NFC Tag UID I am using NFCTagReaderSession in iOS 13. Well it is reading Mifare Ultralight tag successfully. I am able to get Identifier using this code:
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if case let NFCTag.miFare(tag) = tags.first! {
session.connect(to: tags.first!) { (error: Error?) in
let apdu = NFCISO7816APDU(instructionClass: 0, instructionCode: 0xB0, p1Parameter: 0, p2Parameter: 0, data: Data(), expectedResponseLength: 16)
tag.sendMiFareISO7816Command(apdu) { (apduData, sw1, sw2, error) in
let tagUIDData = tag.identifier
} } } }
Well for this I setup session initialisation as :
if #available(iOS 13.0, *) {
guard NFCNDEFReaderSession.readingAvailable else {
return
}
readerSession1 = NFCTagReaderSession(pollingOption: [.iso14443, .iso15693, .iso18092], delegate: self, queue: nil)
readerSession1?.alertMessage = NSLocalizedString("Hold your iPhone near an NFC.", comment: "")
readerSession1?.begin()
} else {
print("should do some fallback code")
}
And it is working fine for Mifare Ultralight. Now I want my app to read all types of NFC Tags that are given in Apple developer site. say :
1. NFCNDEFTag
2. NFCISO7816Tag
3. NFCMiFareTag
4. NFCISO15693Tag
5. NFCFeliCaTag
well, My question is ... do I need to add any new key in info.plist for these tag?
there is already this key added in info.plist :
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>com.apple.developer.nfc.readersession.iso7816.select-identifiers</string>
<string>D2760000850101</string>
</array>
What are the settings required for all tags??
Yes.
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
<string>12FC</string>
</array>
I don't remember the meaning of 12FC value, but you should have it if you try to read . iso18092.
I also have the following values for 7816 taken from https://www.eftlab.com/knowledge-base/211-emv-aid-rid-pix/:
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>A000000003101001</string>
<string>A000000003101002</string>
<string>A0000000041010</string>
<string>A0000000042010</string>
<string>A0000000044010</string>
<string>44464D46412E44466172653234313031</string>
<string>D2760000850100</string>
<string>D2760000850101</string>
<string>00000000000000</string>
</array>

PacketTunnelProvider network extension not called Swift 3

I am trying to add a PacketTunnerProvider network extension to my project. The method startTunnelWithOptions(options: [String : NSObject]?, completionHandler: (NSError?) -> Void) Never gets called
However, I am able to succesfully establish a VPN connection using the network extensions bundle id for the providerBundleIdentifier
This is my code used to establish a connection
let vpnManager = NETunnelProviderManager.shared()
func initVPNTunnelProviderManager() {
let config = NETunnelProviderProtocol()
config.providerBundleIdentifier = self.tunnelBundleId
config.providerConfiguration = ["lol": 1]
config.serverAddress = self.serverAddress
config.username = self.username
config.passwordReference = passwordRef
vpnManager.loadFromPreferences {
(error: Error?) in
self.vpnManager.protocolConfiguration = vpnProtocol
self.vpnManager.localizedDescription = "Connect_1.0.0"
self.vpnManager.isEnabled = true
self.vpnManager.saveToPreferences {
(error: Error?) in
do {
try self.vpnManager.connection.startVPNTunnel()
} catch let error as NSError {
print("Error: \(error.localizedDescription)")
}
}
}
}
This is my PacketTunnel entitlements file
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.touchcore.Connectionapp</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)touchcore.Connectionapp.PacketTunnel</string>
</array>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>packet-tunnel-provider</string>
<string>app-proxy-provider</string>
<string>content-filter-provider</string>
</array>
</dict>
</plist>`
The method startTunnelWithOptions(options: [String : NSObject]?, completionHandler: (NSError?) -> Void) Never gets called
However, I am able to succesfully establish a VPN connection using the network extensions bundle id for the providerBundleIdentifier
What exactly do you mean it never gets called? If you're able to successfully establish a connection then startTunnelWithOptions is being called.
If you're trying to determine that it' being called by using an NSLog(), keep in mind that that will only show in the debug log if you attatch the debugger to the provider instead of your container application.
This will be difficult as the provider is initialized and the startTunnelWithOptions function is called before you get a chance to attach the debugger.
A useful work around in this situation is to sleep in order to give the debugger time to attach.
- (void) startTunnelWithOptions:(NSDictionary *) options
completionHandler:(void (^)(NSError *)) completionHandler
{
// Give debugger time to attach, 10 seconds is usually enough
// Comment this out before you release the app or else you
// will be stuck with a 10 second delay on all connections.
sleep(10);
// Continue with execution
. . .
}
Then, when you initialize your PacketTunnelProvider it will wait 10 seconds before fully entering your logic inside of the startTunnelWithOptions function.
So, during this time in XCode you can go to Debug->Attach To Process->YourVPNProviderProcess and wait for it to fully initialize.

iOS: Simple way to manage REST end points

Our REST based application can be used for testing on multiple internal environments each with a different REST end point. Is there a simple way to set up environment level configuration within an iOS (Swift 3) app? I've seen a few approaches but they all seem pretty involved.
This is my approach of doing things when we have multiple end points. I used to make a ConfigurationManager class something like this
Swift 3.0 code
import Foundation
import UIKit
let kEnvironmentsPlist:NSString? = "Environments"
let kConfigurationKey:NSString? = "ActiveConfiguration"
let kAPIEndpointKey:NSString? = "APIEndPoint"
let kLoggingEnabledKey:NSString? = "LoggingEnabled"
let kAnalyticsTrackingEnabled:NSString? = "AnalyticsTrackingEnabled"
class ConfigurationManager:NSObject {
var environment : NSDictionary?
//Singleton Method
static let sharedInstance: ConfigurationManager = {
let instance = ConfigurationManager()
// setup code
return instance
}()
override init() {
super.init()
initialize()
}
// Private method
func initialize () {
var environments: NSDictionary?
if let envsPlistPath = Bundle.main.path(forResource: "Environments", ofType: "plist") {
environments = NSDictionary(contentsOfFile: envsPlistPath)
}
self.environment = environments!.object(forKey: currentConfiguration()) as? NSDictionary
if self.environment == nil {
assertionFailure(NSLocalizedString("Unable to load application configuration", comment: "Unable to load application configuration"))
}
}
// CurrentConfiguration
func currentConfiguration () -> String {
let configuration = Bundle.main.infoDictionary?[kConfigurationKey! as String] as? String
return configuration!
}
// APIEndpoint
func APIEndpoint () -> String {
let configuration = self.environment![kAPIEndpointKey!]
return (configuration)! as! String
}
// isLoggingEnabled
func isLoggingEnabled () -> Bool {
let configuration = self.environment![kLoggingEnabledKey!]
return (configuration)! as! Bool
}
// isAnalyticsTrackingEnabled
func isAnalyticsTrackingEnabled () -> String {
let configuration = self.environment![kAnalyticsTrackingEnabled!]
return (configuration)! as! String
}
func applicationName()->String{
let bundleDict = Bundle.main.infoDictionary! as NSDictionary
return bundleDict.object(forKey: "CFBundleName") as! String
}
}
In Project--> Info Add some new configurations as per your need.
I have added Staging and QA as extra endpoints.Generally I use to make Staging as Release config and QA as Debug. So it will look like:
Now go to Targets -> Build Settings and add a User Defined Setting
Give the name of the user defined like ACTIVE_CONFIGURATION.
Add a key named ActiveConfiguration in info.plist with a variable name as $(ACTIVE_CONFIGURATION) same as given in User Defined Settings with a $ in the beginning. We gave the name of key as ActiveConfiguration because we are using the same name in our ConfigurationManager.swift class for kConfigurationKey.
let kConfigurationKey:NSString? = "ActiveConfiguration"
You can define as per your naming convention.
It will look like:
Now in the ConfigurationManager class I am getting a path for Environments.plist file.
I will just make a Environments.plist file like this:
The actual description source of this file is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Development</key>
<dict>
<key>APIEndPoint</key>
<string>https://dev</string>
<key>LoggingEnabled</key>
<true/>
<key>AnalyticsTrackingEnabled</key>
<true/>
<key>Flurry</key>
<dict>
<key>FlurryApplicationID</key>
<string></string>
<key>FlurryApplicationSecret</key>
<string></string>
</dict>
<key>Facebook</key>
<dict>
<key>FacebookAppID</key>
<string></string>
<key>FacebookAppSecret</key>
<string></string>
</dict>
</dict>
<key>QA</key>
<dict>
<key>APIEndPoint</key>
<string>https://qa</string>
<key>LoggingEnabled</key>
<true/>
<key>AnalyticsTrackingEnabled</key>
<true/>
<key>Flurry</key>
<dict>
<key>FlurryApplicationID</key>
<string></string>
<key>FlurryApplicationSecret</key>
<string></string>
</dict>
<key>Facebook</key>
<dict>
<key>FacebookAppID</key>
<string></string>
<key>FacebookAppSecret</key>
<string></string>
</dict>
</dict>
<key>Staging</key>
<dict>
<key>APIEndPoint</key>
<string>https://staging</string>
<key>LoggingEnabled</key>
<false/>
<key>AnalyticsTrackingEnabled</key>
<true/>
<key>Flurry</key>
<dict>
<key>FlurryApplicationID</key>
<string></string>
<key>FlurryApplicationSecret</key>
<string></string>
</dict>
<key>Facebook</key>
<dict>
<key>FacebookAppID</key>
<string>840474532726958</string>
<key>FacebookAppSecret</key>
<string></string>
</dict>
</dict>
<key>Production</key>
<dict>
<key>APIEndPoint</key>
<string>https://production</string>
<key>LoggingEnabled</key>
<true/>
<key>AnalyticsTrackingEnabled</key>
<true/>
<key>Flurry</key>
<dict>
<key>FlurryApplicationID</key>
<string></string>
<key>FlurryApplicationSecret</key>
<string></string>
</dict>
<key>Facebook</key>
<dict>
<key>FacebookAppID</key>
<string></string>
<key>FacebookAppSecret</key>
<string></string>
</dict>
</dict>
</dict>
</plist>
We are now good to go. Now you have to just call
ConfigurationManager.sharedInstance.APIEndpoint()
for your respective end points.
Now you just have to change the schemes from Edit Schemes and you are done and change the Build Configuration in info.
This not only manages API End Points but also other things like whether to enable analytics or tracking for the respective end point or different ids of Facebook for different end points.
As Zac Kwan suggested, you can use different schemes to accomplish this, but you don't necessarily have to create a different configuration as well. Each scheme can specify unique environment variables. Then, access them from Swift:
let prodURL = "http://api.com"
let baseURL = ProcessInfo.processInfo.environment["BASE_URL"] ?? prodURL
I found that creating different Scheme and Configuration for your project works best. My setup is as follow:
I usually have 3 different scheme, MyApp-dev, MyApp-staging and MyApp.
Each of the scheme i created User-Defined-Attribute to have different string appending to my Bundle Display Name. So it can concurrently appear on my iOS device as MyApp-d, MyApp-s and MyApp. Each also have its own Bundle ID Then I create custom flags for each of them.
So in my Routes.swift files i have something like this at the top:
#if PRODUCTION
static let hostName = "http://production.com/api/v1/"
#elseif STAGING
static let hostName = "http://staging.com/api/v1/"
#else
static let hostName = "http://development.com/api/v1/"
#endif
There is quite a few ways in how to update different hostname. But ultimately creating different Scheme and Configuration is always the first step.
Here is a few links that might help you get started:
https://medium.com/#danielgalasko/change-your-api-endpoint-environment-using-xcode-configurations-in-swift-c1ad2722200e#.o6nhic3pf
http://limlab.io/swift/2016/02/22/xcode-working-with-multiple-environments.html
I ended up using https://github.com/theappbusiness/ConfigGenerator:
A command line tool to auto-generate configuration file code, for use
in Xcode projects. The configen tool is used to auto-generate
configuration code from a property list. It is intended to create the
kind of configuration needed for external URLs or API keys used by
your app. Currently supports both Swift and Objective-C code
generation.

Error consuming REST API using swift on iOS

I'm new on iOS development, I was following this tutorial: https://grokswift.com/simple-rest-with-swift/ and I don't know why the following code always return "the placeholder" and I can't see errors on the console's output:
import Foundation
class Resolver{
func doSomething() -> String{
var result = "the placeholder"
print("inside doSomething")
let postEndpoint: String = "http://jsonplaceholder.typicode.com/posts/1"
guard let url = NSURL(string: postEndpoint) else {
print("Error: cannot create URL")
return "error here"
}
let urlRequest = NSURLRequest(URL: url)
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config)
print("another thing")
let task = session.dataTaskWithRequest(urlRequest, completionHandler: {
(data, response, error) in
guard let responseData = data else {
print("Error: did not receive data")
return
//return "error here"
}
print("hereeeeeee ############")
guard error == nil else {
print("error calling GET on /posts/1")
print(error)
return
//return "error here"
}
// parse the result as JSON, since that's what the API provides
let post: NSDictionary
do {
post = try NSJSONSerialization.JSONObjectWithData(responseData,
options: []) as! NSDictionary
} catch {
print("error trying to convert data to JSON")
return
//return "error here"
}
// now we have the post, let's just print it to prove we can access it
print("The post is: " + post.description)
result = post.description
// the post object is a dictionary
// so we just access the title using the "title" key
// so check for a title and print it if we have one
if let postTitle = post["title"] as? String {
print("The title is: " + postTitle)
}
})
task.resume()
return result
}
}
this is my info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string></string>
<key>CFBundleExecutable</key>
<string></string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleName</key>
<string></string>
<key>CFBundleDisplayName</key>
<string></string>
<key>CFBundleVersion</key>
<string></string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>httpbin.org</key>
<dict>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>jsonplaceholder.typicode.com </key>
<dict>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleGetInfoString</key>
<string></string>
</dict>
</plist>
When I run the test I see this output:
Test Suite 'RestTest' started at 2016-03-03 15:38:49.364
Test Case '-[FoodTrackerTests.RestTest testResolver]' started.
inside doSomething
another thing
// I want to see the result: the placeholder
Test Case '-[FoodTrackerTests.RestTest testResolver]' passed (0.061 seconds).
Test Suite 'RestTest' passed at 2016-03-03 15:38:49.425.
Executed 1 test, with 0 failures (0 unexpected) in 0.061 (0.062) seconds
Test Suite 'Selected tests' passed at 2016-03-03 15:38:49.426.
Executed 1 test, with 0 failures (0 unexpected) in 0.061 (0.063) seconds
Why the result variable doesn't contains the post.description value?
As suggested in the comments, it looks like tests are completing before the HTTP call is returned (because the HTTP request is asynchronous) and thus you aren't seeing the results of the API call before the test run ends.
Have a look at XCAsyncTestCase and set up your tests to wait for the async callback instead.
The doSomething() method returns "the placeholder" value before the asynchronous call is finished. That's why you see it.

Resources