I am trying to perform a very simple GET request on iOS. I just want to get the response from a PHP page that I have created to access a database. The code works perfectly on Andoid, Windows and OSX but causes a crash immediately as it’s called on iOS. I’ve been trying to figure this out for about a month now and it’s killing me. I will be so incredibly happy if someone knows what is going wrong.
The code I’m using is below.
Header .h file:
//Send an HTTP Get request
UFUNCTION(BlueprintCallable, Category = "SBNetworking")
bool SendGetRequest(FString TheHost);
//this is called when data is received.
void HTTPOnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
//This is an event callable in BP that fires when HTTP data is received
UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Http Request Data Received"))
void HTTPRequestDataReceived(const FString& HttpData);
If there is another way of doing this I am totally open to suggestions!!! I tried creating a fresh project and adding the code to test it out. It crashed as expected. I have “HTTP” added to my public and private dependencies in build.cs and #include “Http.h” in my header file. Once again it works on all platforms I’ve tested but iOS.
The crash stack dump are not very helpful, they missing symbol data (what address correspond to what line in cpp file) you can see those in iOS libraries
Do you use launcher iOS UE4 build? If not, try to compile debug build and run it, it should have symbols then… i think i never worked with iOS or OSX. Without that it hard to debug crashes
Alternativly you could try see logs (again i don’t know how you do it in iOS), this might be some controlled crash (UE4 is design to crash it self in controllable way when issue is detected, insted of letting it crash it self without much data), like assert error, not to mention looking on stack dump
Hey thanks so much for the response! I grabbed those crash logs from the device manager in XCode which is all i could find. I think it attempts to symbolify it. If there is some way to get the symbol data that would be more helpful then please let me know and I will get it right away!
I have tried building/running from XCode. I build/run the editor in XCode then launch on the device from the editor. I have also tried packaging with no luck. I can get other C++ code to work on iOS but this function just crashes instantly.
If there is any way to get better debug information from these crashes please let me know! I had no idea what to make of these crash logs and was hoping they would be of some use.
Do you know how (or if) I can find the UE4 suicide note from the iPad? That would be amazingly helpful
Oh wow you are amazing thank you so much for pointing out NSLog!! I am brand new to OSX and apparently there is a little triangle at the bottom left of the device manager that shows the console. I am not sure if I enabled it in Xcode → preferences or if it was there all along. It’s showing now and that’s what matters. Now I have an actual error to work with!
"Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file."
is the source of the problem. It looks like the HTTP request was blocked and is causing a crash. What do I need to do to my Info.plist file to allow this?
Well you would need to build debug version of engine, which means you need to build it from source. But try to get log first, since for me looking on what i can read from this crash now it is controlled crash.
i don’t know how to get the logs in iOS, i don’t know how devlopment looks there, but i my guess is you can watch logs in some of iOS debug tools in XCode. In case of Android UE4 it prints logs in to central system log called logcat, which you can see using ADB or Android monitor tool, so the same probably is with iOS, there might be tool for that. I trying to google but i can’t find much, this might direct you somewhere:
Oh wow I finally got it to work. Thank you so much for showing me NSLog! That gave me the output I needed to figure out what was actually going wrong! I needed to allow an exception for the connection I’m making in the plist.
I just added this to the “additional plist data” section in project settings->ios (this is for google.ca for example):
<key>NSAppTransportSecurity</key><dict><key>NSExceptionDomains</key><dict><key>google.ca</key><dict><!--Include to allow subdomains--><key>NSIncludesSubdomains</key><true/><!--Include to allow HTTP requests--><key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key><true/><!--Include to specify minimum TLS version--><key>NSTemporaryExceptionMinimumTLSVersion</key><string>TLSv1.1</string></dict></dict></dict>
I removed the line breaks from above. You are amazing !
Edit: I am converting this to answer and marking it for future people having this problem.