as I added some new function in my app , there are more troubles found.
first one is solve. just for share here.
in codea in pad, this not happened. when I test on true phone / iPhone se , I cannot download file as url is blocked which is shown in debug area.
way to solve : in the biggest info.plist, add ket/dict as following :
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
you can get more information on this page :
the next has trouble me for 2 days. I did many test. cannot pass.
I hv 1 txt files on internet named ver.txt. there are only 3 numbers in the file. such as 101 .
I hv 1 ver.txt in app and 1 versus.txt in app. same or different number as above.
at beginning of my app, I download the ver.txt on net into local and write it as versub.txt.
when I want to do is: down ver.txt to local and save as versub first, I get the number in versub and compare with the number in ver.txt in local .
in test, the number on web is 108. in local ver txt is 105 , in local versub is 106.
if number is same, the button is gray. we need not download other new files.
if number is diff, the button is active. we can press to download all new files. ( many other txt files. the last one is the ver.txt , down it into local as ver.txt which cover the old , then button could be gray)
the code can work well in codea in pad. but cannot work well in simulated. and true phone.
app can download , open or made new file, write and close file ( as I print something in function) , but finally the number is still the old. it means the versub is not rewrite well.
I also os.remove the versub.txt in local before write new file. remove can work well. I can see this by test.
but after writing the new, the versub.txt still has 106 in file. not 108 .
also I found other txt files cannot be changed once it is already in app(after the first building) . even though I changed text in local file and build app again ( also cleaned) , the text in txt file never changed.
it looks apple has done something for protection. I don’t know more.
so what can I do next? really headache in these days. pls help . thanks a lot.
ps my download versub code :
after url request , then
function downVer(data,status,headers) -- print("connected") if file_exists(generalPath.."versub.txt") then os.remove(generalPath.."versub.txt") end writeVer("versub.txt",data) end function writeVer(fileName,data) local file = generalPath..fileName wFd, err = io.open(file, "w") if wFd == nil then error("\ \ Error creating/editing file " .. fileName .. "\ \ Error: " .. err) end wFd:write(data) wFd:close() print("downed") print(generalPath..fileName)