Discussion Forums  >  WebViews and HTML for Mobile

Replies: 5    Views: 802

Moto110
Aspiring developer
Profile
Posts: 205
Reg: Jul 26, 2011
Orlando, FL
8,700
02/06/13 01:12 PM (11 years ago)

Can I access an HTML file locally in an Xcode iOS project?

I have an HTML file that is also access a java script file to calculate a total based on a users input. I want to be able to have these files included in the iOS source code so the users do not need to have internet access for this to work. Is this possible with a Custom URL screen? I have read a few previous post where people got it to work on Android using the Custom URL screen and the path of file://directory/etc/etc.html
 
Korkut Ata
Aspiring developer
Profile
Posts: 108
Reg: Aug 09, 2011
Luxembourg
11,580
like
02/06/13 01:23 PM (11 years ago)
Yes, indeed. If you use HTML Doc plugin and include your document in the BT_Docs folder in your xcode project. Hope this helps.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/06/13 01:51 PM (11 years ago)
Yes, on iOS you don't need any unusual file pathes... Just plop it into BT_Docs (make sure you add the file in accordance with this doc) https://www.buzztouch.com/files/howtos/Adding_Files_To_A_Project_v1.0.pdf and just reference the resource by name. Cheers! -- Smug
 
Moto110
Aspiring developer
Profile
Posts: 205
Reg: Jul 26, 2011
Orlando, FL
8,700
like
02/06/13 02:12 PM (11 years ago)
Great information guys! Thanks for the quick responses. I don't know why I didn't think of using the HTML Doc Screen. I kept thinking I had to link to it using the Custom URL Screen for it to work.
 
Moto110
Aspiring developer
Profile
Posts: 205
Reg: Jul 26, 2011
Orlando, FL
8,700
like
02/06/13 09:55 PM (11 years ago)
I added the files html file and the Script.js to my project in the BT_Docs folder and I am able to link to the index.html file without any problems. However, the java script doesn't seem to run within the app. I enter data into the field and it does not calculate the results. Any other suggestions to get this working? It does work fine if the data is hosted on a web server.
 
Moto110
Aspiring developer
Profile
Posts: 205
Reg: Jul 26, 2011
Orlando, FL
8,700
like
02/07/13 06:38 PM (11 years ago)
I solved the problem with the Java Script not running when added to the Xcode project. I found out that when you add JavaScript to an Xcode project it will compile it. You have to tell Xcode not to compile it. Here is how to do that. To stop Xcode from trying to compile JavaScript and make it copy the file instead. In Xcode go to the app target (Targets) then click on the "app name" look to the right and find Build Phases, remove the JavaScript file from the "Compile Sources" section and add it to the "Copy Bundle Resources". The JavaScript will now just when called from an HTML Doc file.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.