I want to request http in mac, so I put NSAllowsArbitraryLoads
in my Info.plist, and specify it in OSX section in game.project, But it seems not working.
When using Build and run
the Info.plist is ignored. It only works when bundling.
After bundling for OSX, if you check the contents of the bundled Info.plist, does it contain your NSAllowsArbitraryLoads
property?
Yes, it has NSAllowsArbitraryLoads
, but my http request still failed, and it have no log window, so I cannot know what happened
How about adding NSAllowsArbitraryLoads
to Defold.app?
Right now, I can use console
to check my log
it have no log window
Run it from the command line?
How about adding
NSAllowsArbitraryLoads
to Defold.app?
I’m not exactly sure what that flag is supposed to do.
And also, it wouldn’t be different from the solution you currently have, adding it to the plist, so I don’t see that solving anything.
You say your http request fails. How do you do your request?
How does it fail?
I check out console and find that http request success, just the response not correct.
BTW, I added NSAllowsArbitraryLoads
to Defold.app, and Build and run
from the editor, http request works.
I’m confused. It’s a success and also a failure?
Do you have any more info about it? What does “incorrect response” mean?
BTW, I added
NSAllowsArbitraryLoads
to Defold.app, andBuild and run
from the editor, http request works.
Is Defold.app
your bundled game? How did you add the flag?
It’s my code’s fault
Ok, so the request was ok?
And NSAllowsArbitraryLoads
wasn’t needed?
I open the Defold editor app from application, and Show Package Contents
, then open the Info.plist and add NSAllowsArbitraryLoads
to it.
Which Info.plist?
Now request is ok, and NSAllowsArbitraryLoads
is needed
Info.plist from the defold editor app
And the path inside the package is Defold.app/Contents/Info.plist
?
I’m really not sure how that would affect how the game is behaving though.
I’ll ping @markus.gustavsson and @vlaaad, perhaps they know how the editor is launching the game?
Yes
I believe the reason why this is happening is that if you run the game from the editor [NSBundle mainBundle]
returns the bundle of the Defold editor app instead of the game’s. The game doesn’t have a macOS app bundle, since it’s just dmengine that gets forked from the editor process.
One other example of this is setting NSRequiresAquaSystemAppearance
to false
in the editor’s Info.plist will not only enable the Mojave dark mode title bar in the editor, but also in forked games.
What NSAllowsArbitraryLoads
does is that it allows apps to use HTTP. Without this flag, mac apps are restricted to HTTPS-only when using NSRequest
and friends.
This is correct with regards to the forking. The dmengine process when launched from the editor is not in a bundle and does not have an Info.plist of its own. I don’t know if child processes inherit those configuration values from the parent but that seems plausible. We will not add a key to the editor to allow unencrypted http so a permanent solution to this would have to be something else than modifying the Info.plist of the editor.
Maybe creating a thin app bundle for the game and starting it with [[NSWorkspace sharedWorkspace] launchApplication:@"./MyDefoldGame.app"]
?
Thanks for the suggestion. Will add a feature request ticket in our internal Jira for using the same Info.plist when launching from the editor as when building a bundle.