StoreKit not working on tvOS

I’m trying to release my first tvos app and try to use this plugin. When uploading to iTunes Connect it complains about App thinning problem.

I’m using below settings in build.settings. I also tried to add supported platform then it was possible to upload and pass the Testflight process but the app doesn’t start, just a black screen. A runtime error. When I remove the plugin it works but then I can’t use IAP. :slight_smile:

I’m using the latest daily build.

["plugin.storeKit"] = {                 publisherId = "com.scottrules44",                 --supportedPlatforms = { tvos=true }             },

local store = require("plugin.storeKit") local json = require("json") ----=======================================--- -- Configure IAP ----=======================================--- store.init(function(e) print( "init") print( "------" ) print(json.prettify(e) ) print( "------" ) if e.transaction.state == "purchased" then native.showAlert("Success", "Thank you for the purchase", {"OK"}) box.iApUpgrade = true; box.receipt = e.transaction.originalReceipt box:save(); removeLocking() elseif e.transaction.state == "failed" then native.showAlert("Failed", "Your purchase failed. Please, try again.", {"OK"}) elseif e.transaction.state == "cancelled" then native.showAlert("Cancelled", "Your transaction was cancelled. Please, try again.", {"OK"}) end end)

It would be very helpful to have the actual error message you’re getting regarding app thinning. Also for the black screen, there are likely errors in your device’s console log. You can tether the AppleTV to your computer (you will need a USB-C cable to connect the AppleTV to your mac) and then use Xcode’s Windows->Devices option to get to the AppleTV device console. Please post those errors here as well.

Thanks

Rob

Here is the error message: “While processing your tvOS app, XXXXXX 1.0(2016.12.151323), errors occurred in the app thinning process, and your app couldn’t be thinned. If your app contains bitcode, bitcode processing may have failed. Because of these errors, this build of your app will not be able to be submitted for review or placed on the App Store. For information that may help resolve this issue, see Tech Note 2432.”

I will look into this, I think I know what the issue is.

Ok i just pushed a plugin update for store kit for apple tv

it may take an hour before updates take affect

Hi! 

I have tried again but it doesn’t work. 

When I follow the documentation and using this in build.settings

["plugin.storeKit"] = { publisherId = "com.scottrules44", },

I get this error when trying to upload the app.

ERROR ITMS-90171: “Invalid Bundle Structure - The binary file ‘Deep Ocean Aquarium.app/Frameworks/Corona_plugin_storeKit.framework/Corona_plugin_storeKit’ is not permitted. Your app can’t contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the tvOS app bundle structure.”

When adding ‘supportedPlatforms’ I can upload to iTunesConnect/Testflight…

["plugin.storeKit"] = { publisherId = "com.scottrules44", supportedPlatforms = { tvos=true }, },

…but then it looks like the plugin is not included in the build.

[Device] ERROR: Runtime error [Device] Runtime Error: Runtime error: module 'plugin.storeKit' not found:resource (plugin.storeKit.lu) does not exist in archive [Device] no field package.preload['plugin.storeKit'] [Device] no file '/var/containers/Bundle/Application/79A6A703-EAB6-4062-B284-73CCC787F0EA/Deep Ocean Aquarium.app/plugin/storeKit.lua' [Device] no file '/var/containers/Bundle/Application/79A6A703-EAB6-4062-B284-73CCC787F0EA/Deep Ocean Aquarium.app/plugin/storeKit.lua' [Device] no file './plugin/storeKit.so' [Device] no file '/var/containers/Bundle/Application/79A6A703-EAB6-4062-B284-73CCC787F0EA/Deep Ocean Aquarium.app/plugin/storeKit.so' [Device] no file './plugin.so' [Device] no file '/var/containers/Bundle/Application/79A6A703-EAB6-4062-B284-73CCC787F0EA/Deep Ocean Aquarium.app/plugin.so'plugin.storeKitluaopen\_plugin\_storeKit [Device] GC startmotion updates

I’m using daily build 3007.

Fixed please try rebuilding

Now I can build and copy to device if I exclude  

--supportedPlatforms = { tvos=true },

 in build.settings. But Then I can’t upload to iTunes Connect because of the App thinning problem.

When I include supportedPlatforms I can upload to iTunes connect and copy to device but then the device can’t find the plugin. 

supportedPlatforms = { tvos=true },

that is odd, what version of corona are you running? It may be a corona bug.

I’m using the latest daily build. 3007

I will give this a test in a bit, but the way you were doing it above should work both ways. I mean, I only have one tvOS plugin. I would “try” the latest stable build until I figure out what is up. But will look into it

Keep in mind that “supportedPlatforms” is exclusionary. That is if you leave it out, it says include the plugin for any platform. If you include it, it says only load it for that particular platform. If you’re building for a platform that the plugin is valid for, having the line and not having it are identical. 

Please post your complete build.settings.

Thanks

Rob

settings = { plugins = { ["plugin.onDemandResources"] = { publisherId = "com.coronalabs", supportedPlatforms = { appletvos=true } }, --[["plugin.storeKit"] = { publisherId = "com.scottrules44", --supportedPlatforms = { tvos=true }, }, --]] }, --[[] osx = { entitlements = { ["com.apple.security.network.client"] = true, }, }, --]] tvos = { onDemandResources = { { tag="TwilightPartB", resource="odr/02.mp4", type="install" }, { tag="MidnightPartA", resource="odr/03.mp4", type="install" }, { tag="MidnightPartB", resource="odr/04.mp4", type="install" }, }, -- tvOS app icons require multiple layers, and you must provide both a small and a large size icon = { -- A collection of 400x240 pngs, in order of top to bottom small = { "Icon-tvOS-Small-LogoA.png", "Icon-tvOS-Small-LogoB.png", "Icon-tvOS-Small-Background.png", }, -- A collection of 1280x768 pngs, in order of top to bottom large = { "Icon-tvOS-Large-LogoA.png", "Icon-tvOS-Large-LogoB.png", "Icon-tvOS-Large-Background.png", } }, -- A 1920x720 image file, displayed when your app is on the "top shelf" topShelfImage = "Icon-tvOS-TopShelf.png", -- A 2320x720 image file, displayed when your app is on the "top shelf" of a widescreen TV topShelfImageWide = "Icon-tvOS-TopShelfWide.png", -- A 1920x1080 png file, displayed briefly as your app loads launchImage = "Icon-tvOS-Launch.png", }, excludeFiles = { -- Exclude all Android icon files and .ogg files iphone = { "Icon-\*dpi.png", "\*.ogg" }, -- Exclude iOS "retina" image files and .aac files android = { "Icon.png", "\*@2x.png", "\*.aac" }, -- Exclude unnecessary assets from OS X desktop apps osx = { "Default\*.png", "Icon\*.png", "Icon\*.ico", "Icon\*.icns", "\*.aac" }, -- Exclude unnecessary assets from Win32 desktop apps win32 = { "Default\*.png", "Icon\*.png", "Icon\*.ico", "Icon\*.icns", "\*.aac" }, -- Exclude all Android icon files and .ogg files tvos = { "Icon-\*.png", "\*.ogg" }, }, orientation = { default = "landscapeLeft", supported = { "landscapeLeft", "landscapeRight" }, }, window = { suspendWhenMinimized = true, defaultViewWidth = 960, defaultViewHeight = 640, titleText = { default = "Pew Pew!", }, }, }

I just tried to use build 2992 (latest public build) but no still the same problem…


While processing your tvOS app, XXXXXXXXX.0(2016.12.211454), errors occurred in the app thinning process, and your app couldn’t be thinned. If your app contains bitcode, bitcode processing may have failed. Because of these errors, this build of your app will not be able to be submitted for review or placed on the App Store. For information that may help resolve this issue, see Tech Note 2432.

I pushed out update.

Thanks! I will make a test asap. :slight_smile:

Hi!

It looks like the IAP is working now. both with 2992 and the latest build, 3011. Thanks!

But it looks like store.restore() doesn’t work? When calling store.restore() nothing is returned. In store.init I’m checking for e.isError but isError is nil. Also e.transaction.state is nil.

Then there is a very odd thing. After the purchase I’m moving to a new scene and try to play an audiofile but all audio channels seems to be muted in someway (only after purchase). It’s impossible to play an audiofile and even if I’m loading the audiofile again or changing the volume is still muted. After trying maybe 100+ different solutions only work-around I have found is to remove all scenes and reload the main-menu. Maybe this isn’t connected to storeKit at all but it only happens right after a purchase (tvos). 

I can look into the restore not working, I don’t know about the audio bug. I will see what I can do. Thanks for your patience.

I can’t speak for Scott’s implementation but in our store.* API (IAP for iOS) The restore action will only return items if the user has made purchases of non-consumable items and they’ve deleted and re-installed the app. There is not a “there is nothing to restore” event. Go “restore doing nothing” is a perfectly valid state.

Rob