2016-10-22, 16:34
Hi,
first a few words adressed to Memphiz.
I would like to thank you for your effort, assistance and the tremendous work to bring us Kodi to the Apple TV 4.
Guy - you're incredible!
####################
So, let's start and first things first...
As the most of us i have only a free Apple Development Account. The annoying part of this solution is the 6 days refresh cycle of my provisioning profile.
I searched the Internet for a solution to automate the process, but without success. So i decided to write my own...
It's written in AppleScript and it's not perfect, but it works for me under macOS, tvOS 10 and xCode 8. So if you read further please keep in mind, it's my first project of this kind.
####################
What it does...
####################
Here's the magic soup!
####################
I use this script since 3 weeks on daily basis, without any problems
I tried to automated the process, because my Mac is on 24/7 and the Apple TV is connected to the Mac with a long USB-Cable. So why can't the refresh of the profiles and Kodi itself not run every night!?
It will - if you remove the dialogs in my script and set it up as a cron job, everything goes like magic.
How to set up a script as a cron job can be found here: http://alvinalexander.com/blog/post/mac-...-with-cron
####################
Here is the most important part. The Kodi *.deb file, the *.ipa file and the xCode Project must be in the same folder. E. g. /Users/efty/Documents/xCode/efty-kodi-atv4/
You can set this location, the source url and the name of your Apple TV in the --#### Block at the top of my script.
####################
I think the script is well documented, so you can change it on your own. I know, there is much room for improvement. E. g. the Save dialog of the iOS App Signer stays 3 to 4 seconds and i don't know why or the selection of the provisioning profile in the iOS App Signer can be done better, instead of push the down arrow 3 times... But for now and me - it works.
So - feel free to use it or make it better. But at your own risk and without any support and guarantee!
Efty
Updates
=====
2016-10-29: (CHECK) Works with xCode 8.1
2016-12-22: {FIX} The script works now with the standard Kodi Mirrors on http://mirrors.kodi.tv/test-builds/darwin/tvos/
first a few words adressed to Memphiz.
I would like to thank you for your effort, assistance and the tremendous work to bring us Kodi to the Apple TV 4.
Guy - you're incredible!
####################
So, let's start and first things first...
As the most of us i have only a free Apple Development Account. The annoying part of this solution is the 6 days refresh cycle of my provisioning profile.
I searched the Internet for a solution to automate the process, but without success. So i decided to write my own...
It's written in AppleScript and it's not perfect, but it works for me under macOS, tvOS 10 and xCode 8. So if you read further please keep in mind, it's my first project of this kind.
####################
What it does...
- On http://mirrors.kodi.tv/test-builds/darwin/tvos/ it checks if there's a newer version to download.
- If it so, it prompts for the permission to downloads it, or refresh the Codesigning of the existing one, or cancel the script
- If you continue it deletes the old xCode provisioning profiles in the local folder ~/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision NO PANIC! xCode downloads the new ones after you load the Kodi Project
- After this point it starts xCode and loads the Kodi Project which refreshes your provisioning profiles
- Then the iOS App Signer will start, all settings set and the Codesigning process and the build of the *.ipa file will start.
- In xCode the Device Manager will open, the Apple TV selected and the newly signed *.ipa file will be uploaded to your Device
- After the Apple TV is Ready again, the script finishes and closes all Applications.
- Done ...
####################
Here's the magic soup!
Code:
-- #####################################################
-- Set the path to the folder where the xCode Project and the Kodi*.deb file resists
set thePath to "/Users/efty/Documents/xCode/efty-kodi-atv4/"
-- Set the URL Source to the Kodi Test-Builds
set theKodiSource to "http://mirrors.kodi.tv/test-builds/darwin/tvos/"
-- Set the name of the Apple TV
set theAtvName to "Apple TV"
-- #####################################################
-- Get the full path of the *.xcodeproj, the *.deb and the old *.ipa files
tell application "System Events"
set theProjectFilePath to POSIX path of (files of folder thePath whose name ends with ".xcodeproj")
set theProjectFile to (name of files of folder thePath whose name ends with ".xcodeproj")
set theDebFilePath to POSIX path of (files of folder thePath whose name ends with ".deb")
set theIpaFilePath to POSIX path of (files of folder thePath whose name ends with ".ipa")
end tell
-- Retrieve the filename of the latest Kodi Test-Build
set theLatestKodi to (do shell script "curl -s '" & theKodiSource & "' --list-only | grep -o -m 1 '>kodi-.*deb' | grep -o 'kodi-.*deb'")
tell application "Finder"
-- Check if this Kodi Test-Build is still the same
if exists (thePath & theLatestKodi) as POSIX file then
-- Display a dialog when no new Kodi version is found
display dialog "There's no new Kodi Version.
Should i refresh and update the Codesigning of the installed one?" buttons {"Cancel", "Refresh"} default button "Refresh" with icon note
-- Stop the Execution if [Cancel] is pressed
if the button returned of the result is "Cancel" then
return
end if
else
-- Display a dialog when a new Kodi version is found
display dialog "NEW -> " & theLatestKodi & "
[Install] = Download and install the new Version
[Refresh] = Update the existing Version" buttons {"Cancel", "Refresh", "Install"} default button "Install" with icon caution
-- Stop the Execution if [Cancel] is pressed
if the button returned of the result is "Cancel" then
return
-- Download and Intall if [Install] is pressed
else if the button returned of the result is "Install" then
-- Delete the old Kodi version
if theDebFilePath is not {} then do shell script ("rm " & theDebFilePath)
-- Download the new Kodi version
do shell script ("curl -L -o " & thePath & theLatestKodi & " " & theKodiSource & theLatestKodi)
-- Change the value of the Kodi variable to the new one
set theDebFilePath to thePath & theLatestKodi
end if
end if
end tell
-- DELETE old Provisioning Profiles
try
do shell script "rm ~/Library/MobileDevice/'Provisioning Profiles'/*.mobileprovision"
end try
-- DELETE the old *.ipa file
if theIpaFilePath is not {} then do shell script "rm " & theIpaFilePath
-- Open xCode
tell application "Xcode"
-- open the xCode project
open theProjectFilePath
tell application "System Events"
activate "Xcode"
tell process "Xcode"
-- Wait until the Provisioning Profile is fixed
set theResult to "Waiting to repair..."
repeat until theResult = ""
set theResult to (value of static text 7 of group 2 of scroll area 1 of splitter group 1 of group 1 of splitter group 1 of group 2 of splitter group 1 of group 1 of window 1) as string
delay 0.5
end repeat
end tell
-- open AppSigner
delay 3.0
activate application "iOS App Signer"
tell process "iOS App Signer"
-- Enter path to 'Kodi*.deb' Input File
set value of text field 2 of window "iOS App Signer" to theDebFilePath
-- Select the Provisionig Profile
click pop up button 2 of window "iOS App Signer"
keystroke (ASCII character 31) -- down arrow key
keystroke (ASCII character 31) -- down arrow key
keystroke (ASCII character 31) -- down arrow key
delay 0.5
keystroke (ASCII character 3) -- enter key
-- Start the Codesigning process
click button 1 of window "iOS App Signer"
-- Save the *.ipa file
click button 1 of window "Save"
-- Wait until the Codesigning process has finished
repeat until (value of static text 6 of window "iOS App Signer" as string) contains "Done,"
end repeat
-- QUIT iOS App Signer
tell application "iOS App Signer" to quit
end tell
-- Open xCode
tell application "Xcode"
tell application "System Events"
activate application "Xcode"
tell process "Xcode"
-- Open the Devices window
click menu item "Devices" of menu 1 of menu bar item "Window" of menu bar 1
-- Select 'Apple TV' device
set maxRow to (count rows of table 1 of scroll area 1 of splitter group 1 of window "Devices")
repeat with theRow from 1 to maxRow
if text field 1 of UI element 1 of row theRow of table 1 of scroll area 1 of splitter group 1 of window "Devices" exists then
if (value of text field 1 of UI element 1 of row theRow of table 1 of scroll area 1 of splitter group 1 of window "Devices") = theAtvName then
select row theRow of table 1 of scroll area 1 of splitter group 1 of window "Devices"
end if
end if
end repeat
-- Press + Button
click button 4 of scroll area 1 of splitter group 1 of splitter group 1 of window "Devices"
-- Select the *.ipa file
set maxRow to (count rows of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of sheet 1 of window "Devices")
repeat with theRow from 1 to maxRow
if text field 1 of UI element 1 of row theRow of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of sheet 1 of window "Devices" exists then
set theFilename to value of text field 1 of UI element 1 of row theRow of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of sheet 1 of window "Devices"
if text -4 through -1 of theFilename = ".ipa" then
select row theRow of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of sheet 1 of window "Devices"
end if
end if
end repeat
-- Press OPEN to transfer the *.ipa file to the Apple TV
click button "Open" of sheet 1 of window "Devices"
-- Wait until the transfer has finished
set theResult to ""
delay 3.0
repeat until (offset of "Ready" in theResult) as integer > 0
set theResult to (value of static text 1 of group 1 of group 2 of toolbar 1 of window 2) as string
end repeat
end tell
end tell
end tell
-- QUIT Xcode
tell application "Xcode" to quit
end tell
end tell
display dialog "Finished..." with icon note giving up after 15
####################
I use this script since 3 weeks on daily basis, without any problems
I tried to automated the process, because my Mac is on 24/7 and the Apple TV is connected to the Mac with a long USB-Cable. So why can't the refresh of the profiles and Kodi itself not run every night!?
It will - if you remove the dialogs in my script and set it up as a cron job, everything goes like magic.
How to set up a script as a cron job can be found here: http://alvinalexander.com/blog/post/mac-...-with-cron
####################
Here is the most important part. The Kodi *.deb file, the *.ipa file and the xCode Project must be in the same folder. E. g. /Users/efty/Documents/xCode/efty-kodi-atv4/
You can set this location, the source url and the name of your Apple TV in the --#### Block at the top of my script.
####################
I think the script is well documented, so you can change it on your own. I know, there is much room for improvement. E. g. the Save dialog of the iOS App Signer stays 3 to 4 seconds and i don't know why or the selection of the provisioning profile in the iOS App Signer can be done better, instead of push the down arrow 3 times... But for now and me - it works.
So - feel free to use it or make it better. But at your own risk and without any support and guarantee!
Efty
Updates
=====
2016-10-29: (CHECK) Works with xCode 8.1
2016-12-22: {FIX} The script works now with the standard Kodi Mirrors on http://mirrors.kodi.tv/test-builds/darwin/tvos/