Alamofire was compiled with optimization - stepping may behave oddly; variables may not be available.

Created on 19 Sep 2015  Â·  16Comments  Â·  Source: Alamofire/Alamofire

when I use Alamofire2.0,run app ,this is error occurred:

Alamofire was compiled with optimization - stepping may behave oddly; variables may not be available

Xcode pointed to Alamofire.swift,line number 92
who can help me?
Thanks~!

support

Most helpful comment

You got it @geoherna. We had server-provided media URLs with spaces in them, so this fixed it :

NSURL(string: unsafeUrlString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.whitespaceCharacterSet().invertedSet))

All 16 comments

fixed it

@cnoon how did you fix this? can you help me out. I have the same issue.

Same problem here. Any idea? @mattt
I've checked complier setting and optimizer is set NONE

I ran into the same issue in ReactiveCocoa and running 'carthage build' fixed the problem.

@andrewschreiber I'm using Cocoapods. Any solution for that?

Perhaps a 'pod install'

@andrewschreiber I've tried pod install several time. Removed pods completely and add them back. nothing is working.

Sorry,I just see the email,Now,how to the error was solved,

TARGETS->Build Phases->Embed Frameworks
when you add the framework of Alamofire2.0,
Xcode will take three frameworks,iphoneos ,xos,watchos,
please delete the xos,watchos,save the iphoneos,
when you run the app,the error was solved~!!
Happy Mid Autumn Festival

@ylj798 I can't see "Embed Frameworks". BTW, I think I'm in the wrong thread, I'm using AFNetworking not Alamofire

This problem seems to (also) occur when you try to construct a url using optionals:

let username: String? = "mattt"
let request = Alamofire.request(.GET, "http://localhost/user/\(username)").responseJSON { response in
    // ...
}

The solution is obvious; make sure you unwrap any optionals using guard, if-let or by implicitly unwrapping them before constructing your url.

My guess is that Carthage builds the Alamofire framework with the Release configuration (by default) for which optimizations _are_ enabled, which results in the error message mentioned in the initial post instead of a more descriptive message. Could be wrong about this though ¯_(ツ)_/¯

Same error, PUT isn't working

let parameters = ["briefDes": briefDes.text, "jobDetail": detail.text, "skill": skillsTF.text]
Alamofire.request(.PUT, "http://localhost:2403/postedjob?id=\(jobId.text)", parameters: parameters)

error: Alamofire was compiled with optimization - stepping may behave oddly; variables may not be available.

Update:
Issue solved.! jobId.text wasn't unwrapped. :)

@29satnam life saver !!!, unwraping was also my issue with different library :)

Just incase anyone else is getting: error: Alamofire was compiled with optimization - stepping may behave oddly; variables may not be available.

I was getting that error when constructing a URL for google geo services. I was appending a street address to the end of the URL WITHOUT encoding the street address itself first.
My Solution:

var streetAdress = "123 fake street, new york, ny"
var escapedStreetAddress = streetAddress.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
let url = "(self.baseUrl)&address=(escapedAddress!)"

That fixed it for me! It didnt like that the address had spaces and commas, etc.

Hope this helps someone else!

man geoherna, you nailed it, yes there was a trailing space in input and your way worked...

You got it @geoherna. We had server-provided media URLs with spaces in them, so this fixed it :

NSURL(string: unsafeUrlString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.whitespaceCharacterSet().invertedSet))

hi friends i have fetch same problem "Alamofire was compiled with optimization - stepping may behave oddly; variables may not be available."
But , I was Fixed it Check your url string Pass Url Without any SPACE

Was this page helpful?
0 / 5 - 0 ratings