Access camera/photos


#44

This could potentially be an issue with iPhone X. But it could also be an issue with your wifi or the router/firewall preventing service discovery from working.

I use a command line tool called ios-deploy. Super easy to use. Follow the first two steps of the installation guide (note that you need Homebrew installed):

brew install node
npm install -g ios-deploy

Yes, it could be a problem. I haven’t tried the camera extension on an iPhone X.


#45

Ok, so how can i fix this? could i send you some log or something to look at, how can i get this log if there is some? how do you debug on device?


#46

I believe that crashes are written as logs on disk. They should be accessible from XCode->Some_menu->Devices->Your Device->Logs. There’s also a tool called deviceconsole that you can build and then run from the terminal to get live logs from a connected iOS device.


#47

Regarding installation via iTunes, you should be able to drag & drop via the XCode -> Windows -> Devices interface.


#48

Found the crash log, this is some readable text from that log.

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: TCC, This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
Triggered by Thread: 15


#49

Ah, I see. So that’s an iOS 10 requirement that the info.plist must specify why the app is using the camera. You can provide your own custom info.plist file. The original can be found inside bob.jar, downloadable from d.defold.com. Download bob.jar, change file extension from jar to zip and unpack. The info.plist is in /com/dynamo/bob/bundle/resources/ios/Info.plist. Make a copy and put it in your project. Add the NSCameraUsageDescription key and value. Point to the Info.plist from your game.project.


#50

Ok, sounds easy! :slight_smile: but when opening the file, where do i put this, and in what format, the file looks a little like this

<?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>BuildMachineOSBuild</key>
    <string>13A603</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>{{project.title}}</string>
    <key>CFBundleExecutable</key>
    <string>{{project.title}}</string>
    <key>CFBundleIconFiles</key>
    <array>
            <string>Icon-167.png</string>
            <string>Icon-60@3x.png</string>
            <string>Icon-60@2x.png</string>
            <string>Icon-76@2x.png</string>
            <string>Icon-76.png</string>

#51

Try putting it at the top, just inside the tag. The format is described in the link I shared in my previous post:

<dict>
    <key>NSCameraUsageDescription</key>
    <string>Some good reason for requiring camera usage</string>

#52

Yeah, sorry, found it. and then, do i put the file in the same directory as the game.project file? and that is the root of the project? so in the game.project input field i just write info.plist? It is now showing in git or defold editor as a new file when adding the it to this place.


#53

Put it in the root or a sub directory. The use the … button next to the entry in game.project to get a file browser and select it.

Ok, then it’s probably ignored for some reason. Please check your .gitignore file if it’s set to ignore .plist files.


#54

Sorry, so many questions now… just tell me to back off if you get enough of this!

.gitignore in my .git library in the branch dont have .plist, only these these:

.externalToolBuilders
.DS_Store
.lock-wscript
build
*.pyc
.project
.cproject
builtins
.internal

when clicking the “…” after infoplist input field the popup is empty, but thats probably because i cant se it at all in git or the editor?

also when running :

"ios-deploy --bundle app.ipa" 

im getting:

2017-12-07 08:23:31.814 ios-deploy[66764:1630694] [ !! ] Error 0xe8008015: A valid provisioning profile for this 
executable was not found. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)

#55

Yes. And you have the info.plist file right next to game.project? And you can see it in Finder or from the Terminal?

This indicates a problem with your provisioning profile. Hard to tell what’s wrong. Have you exported a matching provisioning profile for your device? Have you plugged in your device and gone to XCode->Devices and waited for the process that will enable the device for development?

Can you build and install non-Defold projects from XCode on your device?


#56

Yes, i have it next to game.project and i can se it in the finder and terminal.

when starting xcode and waited for the device to show, i now get another error when trying to deploy:

[  5%] Copying META-INF/ to device
[  6%] Copying META-INF/com.apple.ZipMetadata.plist to device
[  8%] Copying Payload/ to device
[ 10%] Copying Payload/Gifts.app/ to device
[ 12%] Copying Payload/Gifts.app/_CodeSignature/ to device
[ 14%] Copying Payload/Gifts.app/_CodeSignature/CodeResources to device
[ 16%] Copying Payload/Gifts.app/embedded.mobileprovision to device
[ 18%] Copying Payload/Gifts.app/Info.plist to device
[ 20%] Copying Payload/Gifts.app/Gifts to device
[ 40%] Copying Payload/Gifts.app/game.arcd to device
[ 44%] Copying Payload/Gifts.app/game.arci to device
[ 46%] Copying Payload/Gifts.app/game.dmanifest to device
[ 48%] Copying Payload/Gifts.app/game.projectc to device
[ 48%] Copying Payload/Gifts.app/game.public.der to device    
[ 52%] CreatingStagingDirectory
[ 57%] ExtractingPackage
[ 60%] InspectingPackage
[ 60%] TakingInstallLock
[ 65%] PreflightingApplication
[ 65%] InstallingEmbeddedProfile
[ 70%] VerifyingApplication
2017-12-07 09:20:39.445 ios-deploy[92910:1735930] [ !! ] Error 0xe8000067: There was an internal API error.         
AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)

#57

Can you install via XCode or do you get an error there as well? Google AMDeviceSecureInstallApplication and see what you get.


#58

Got it to work finally, in the new editor, 2 i could find the info.plist. i can now install the builds and the info.plist worked, it throws up the native “Wanna use camera” and then i can use it.

But! hehe… now when trying to capture an image nothing happens, guess i am getting som error, but i cant se that when on the device!? it works on OSX.


#59

This rows doesn’t work in the device, any idea what i can do about that @britzl

io.open(“camerasnapshot.png”, “wb”)
local file = io.open(“camerasnapshot.png”, “rb”)

no crash, no errors, the app just stops where it is.


#60

Are you running both lines of code, one after the other?

If the call to io.open fails it will return nil plus an error message. Check for it and handle appropriately. Something like this:

local file, err = io.open(“camerasnapshot.png”, “rb”)
if not file then
  print(err)
  return
end

#61

No, they are made on different places, the first one when I capture an image and the second one when I want to make a file to send it to the server. Is it possible to make a file directly from the png_bytes instead so I don’t have to use these 2 lines at all? at the moment i need the file in this code to be able to sent it to the server.

local file = io.open("camerasnapshot.png", "rb")	
local current = file:seek()      -- get current position
local file_size = file:seek("end")    -- get file size
file:seek("set", current)        -- restore position

local resp = {}
local body,code,headers,status = httpSocket.request{
	url = "http://server.se/upload.php",
	method = "POST",
	headers = {
		["Content-Type"] = "application/x-www-form-urlencoded",
		["Content-Length"] = file_size,
		["filename"] = imageFileName
	},
	source = ltn12.source.file(file),
	sink = ltn12.sink.table(resp)
}

#62

Ok, so one problem is that you’re likely not saving and loading the file from a writable folder on your device. You need to use sys.get_save_file(), like this:

local path = sys.get_save_file("yourappnamehere", "camerasnapshot.png")
local file = io.open(path, "rb")

I didn’t mention this in my original reply. Sorry about this.

BUT if you want to send the bytes immediately and never save them then I believe you can do:

local file_size = png_bytes:len()
local imageFileName = "camerasnapshot.png"
local resp = {}
local body,code,headers,status = httpSocket.request{
	url = "http://server.se/upload.php",
	method = "POST",
	headers = {
		["Content-Type"] = "application/x-www-form-urlencoded",
		["Content-Length"] = file_size,
		["filename"] = imageFileName
	},
	source = ltn12.source.string(png_bytes),
	sink = ltn12.sink.table(resp)
}

#63

Yes, that “sys.get_save_file…” solved my problem, thx alot, you want to hear my next 2 ones? probably not huh!!

  1. I cant get the GUI/App to resize over my whole screen, 2436 × 1125, at the moment i have 750x1334 in game.project on the resolution input, that looks the best it shows full width(scaled i guess) but only 3/4 of the height, but at least centered so this looks the best so far.

  2. Also the app icon i have in different sized images on every input in game.project input, but they all come out the same on the phone, a small version, maybe 2/4 sized inside a black app icon in the correct size that probably the device itself fixes.