Upload
yoshi-sakai
View
778
Download
0
Embed Size (px)
Citation preview
Rhodes
Ruby to iPhone, Android Native Application
Yoshi Sakai / Twitter @bluemooninc
Rhodes is
• Rhodes makes multiple native application as the iPhone, Android from single code.
• Ruby + HTML MVC Framework
• MIT License
• Rhodes deploy to device with the Xcode and Android SDK,NDK.
Install Rhodes
• Open the Gems Folder
– sudo chmod 775 /Library/Ruby/Gems/1.8
• $ gem install rhodes
Install homebrew
• $ ruby -e "$(curl -fsSkLraw.github.com/mxcl/homebrew/go)"
• $ sudo chmod 775 /usr/local
• $ sudo chown -R $USER /usr/local/*
• $ brew update
Homebrew is the package system for UNIX Tool on Macintosh. Homebrew is compact and simple than MacPorts.
Install gcc
• $ brew tap homebrew/dupes
• $ brew install autoconf automake apple-gcc42
Install Xcode
• https://developer.apple.com/devcenter/ios/index.action
Additional install on Xcode
• Boot xCode, Click preference. After that Install the iOS Simulator and Command line Tools
Install Android SDK/NDK
• Download the android JDK from Apple
– http://support.apple.com/downloads/#java
• Download Android SDK/NDK
– http://developer.android.com/sdk/index.html#download
• Select a 64bit version When you use MoutainLion
– http://support.apple.com/kb/HT3696
Android NDK is Native(C、C++) Development kit
Path set for Android SDK
• Open the terminal window and goto home.
• Make a .bash_profile by Editor (vim etc…)
• open .bash_profile is easy to edit on Mac
.bash_profile
• .bash_profile-------------------------------------------• export PATH=$PATH:/Users/bluemooninc/android_sdk/sdk/tools
• #Android NDK PATH• ANDROID_NDK=/Users/bluemooninc/android_ndk/toolchains• export PATH=$PATH:${ANDROID_NDK}
• #Android SDK PATH• ANDROID_SDK=/Users/bluemooninc/android_sdk/sdk/platform-
tools• export PATH=$PATH:${ANDROID_SDK}• -------------------------------------------------------------
Make sure the path
• $ printenv
• PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/rvm/bin:/Users/bluemooninc/android_sdk/sdk/tools:/Users/bluemooninc/android_ndk/toolchains:/Users/bluemooninc/android_sdk/sdk/
• Check the Android SDK/NDK path
• Close terminal or below command to refresh
– $source ~/.bash_profile
Set build parameter
• $ rhodes-setup >> build.yml will made
– We will ask you a few questions below about your devenvironment.
– JDK path (required) (/Library/Java/Home): /System/Library/Flameworks/JavaVM.flamework/Home
– Android SDK path (blank to skip) (): /Users/bluemooninc/android_sdk/sdk/
– Android NDK path (blank to skip) (): /Users/bluemooninc/android_ndk/
Get Ruby 2.0!
• Ruby1.8.7 (Mac OS X Default) is old and error stop on compile. You can get Version2 below.
• $ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
• $ brew install rbenv
• $ brew install ruby
Set UTF-8
• /Library/Ruby/Gems/1.8/gems/highline-1.6.18/lib/highline.rb:621:in `say': undefined method `default_external' for Encoding:Class(NoMethodError)
• default_external to 'UTF-8’
Generate a Application
• $ rhodes app storemanager
– >> Ganerate an Application folder and template files.
• $ cd storemanager
– >> move to project folder
• $ rhodes model storemanager name
– >> Ganarate a scaffold for MVC framework
Run the Android simulator
• rhodes/platform/android/build/androidcommon.rb
– Add "_64” to androidcommon.rb When you drive 64 bit as the Android NDK
– $ndkhost = `uname -s`.downcase!.chomp! + "-x86_64”
• $ rake run:android:rhosimulator
– >> Quick simulate for debug
1 bug fix
• As the 3.5.1.12 has one bug(Already fixed at github)– There is a bug in build script that causes this error.
It is already fixed at master. You may fix it yourself in your rhodes.Open /var/lib/gems/1.9.1/gems/rhodes-3.5.1.12/platform/android/build/android_tools.rb
– At line 211 And make this line to look as Class name
– FileUtils.rm_f $applog_path if !$applog_path.nil?
Prepare the Android Virtual Device
• Boot eclipse on android_sdk, Select AVM manager on Window menu
Change build.yml
• build.yml for AVD ---------------------------------
• android:
• minSDK: 11
• version: 4.0.3
• emulator: galaxyS2
• android_title: 0
• orientation: portrait
• --------------------------------------------------------
Run the Emulator
• $ adb start-server >> Start the adb server
• rake run:android:rhosimulator >>Quick debug
• $ rake run:android >> Deploy to the emulater
Make the iOS Development
• Edit build.yml --------------------------------
• iphone:
• configuration: Debug
• sdk: iphonesimulator6.1
• provisionprofile:
• codesignidentity: "iPhone Developer"
• -------------------------------------------------------
Run the simulator
• rake run:iphone:rhosimulator >> Quick debug
• rake run:iPhone >> Deploy to iOS simulator
Deploy to Android Device
• $ CD $home >> move to home directory
• open .android/adb_usb.ini
• Connect USB your device and Check the Manufacture ID by the system profiler on your Macintosh
Example of Galaxy SII
• Manufacturer ID for Samsung
• 0x04e8
Check Device and Build
• Cd ~/android_sdk/sdk/platform-tools/• android update adb• adb devices
List of devices attached4*************c device >> You will see your Android device serial number
• Goto project folder and build it.rake run:android:deviceIf you’ve get the error: device not found, Then Try it below ex.
• /Users/bluemooninc/android_sdk/sdk/platform-tools/adb -d install -r /Users/bluemooninc/RhodesProject/storemanager/bin/target/android/storemanager-debug.apk
Success mean finish
Deploy to iPhone Device
• Edit build.yml---------------------------------
• iphone:
• configuration: Release
• sdk: iphoneos6.1
• provisionprofile:
• codesignidentity: "iPhone Developer"
• entitlements: ""
• BundleIdentifier: com.xoopsec.ios.* >> from iOS developper
• BundleURLScheme: StoreManager001 >> from iOS developper
Generate a iPhone package
• $ rake device:iphone:production
– Will ganarate iOS folder below ex.RhodesProject/bin/target/iOS/iPhoneos6.1/Release/storemanager.app
Build the Xcodeprj
• $ rake switch_app
• $ rake build:iphone:setup_xcode_project
Library/Ruby/Gems/1.8/gems/rhodes-3.5.1.12/platform/iphone/rhorunner.xcodeproj
Deploy to Real device
• Double click to Library/Ruby/Gems/1.8/gems/rhodes-3.5.1.12/platform/iphone/rhorunner.xcodeproj
• Connect iPhone to USB and Click Run
• After pages are Apple Developer registration
https://developer.apple.com
Make a certification data
• Boot key chain from utility folder and select Assistant• Keep blank a CA email address,Save to disk, set the key pear info.• Input (2048bit, RSA to key pear parameter)• CertificateSigningRequest.certSigningRequest will save on your disk
Entry your CertificationSelect
Certification. After while you will get a email
for Approve.
Install the certification on your Mac
• Double click the downloaded developer_identity.cer file from Apple
Entry the iOS device info
• Connect your iOS device on your Mac
• Boot Xcode, Click device at Window Organizer
Copy this 40th strings
Entry the Identifier to Developer
Get the AppID
• Wildcard App ID: opsit the domain name for unique name
• App ID Name: as you like.
ex)com.xoopsec.ios.*
App name etc.
Entry the Provisioning Profiles
• Profile Name:As any• Certificates:check• App ID:Choice in this time• Device:Check
Set Code Signing Identity
• Open the Xcode project on Rhodes folder• Select Code Signing Identity in Build Setting