ãããžã§ã¯ããéçºç°å¢ã®ã»ããã¢ãããã©ã€ãã©ãªãã¹ããããã®æ¥ç¶
ããã¯æåã§æãç°¡åã§ããããŸã éèŠãªã¢ã¯ã·ã§ã³ã®1ã€ã§ããã this ã this ã thisãªã©ã ããã«ã€ããŠå€ãã®èšäºãæ¢ã«æžãããŠããããããç¥ããªãéçºè ã¯ã»ãšãã©ããªãã®ã§ãããã§ãããŸããã ãŸããXcodeçšã®éåžžã«å€ãã®äŸ¿å©ãªãã©ã°ã€ã³ãäœæãããŠããŸããXcodeã®æŠèŠã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã
ã«ã¹ã¿ã CocoaPodsãªããžããª
CocoaPodsãä»ããŠãã®ãããžã§ã¯ãã®ãæ°ã«å ¥ããŸãã¯å¿ èŠãªã©ã€ãã©ãªãæ¥ç¶ããããšã«å ããŠãæãäžè¬çãªããã«ããŒé¢æ°ãã䜿çšããŠç¬èªã®ãªããžããªãè¿œå ã§ããŸãã ããšãã°ã次ã®ãããªã³ãŒããæžãããšã«ããããããŠããªã人ïŒ
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
ãŸãã¯
NSData *data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; return [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
ããããªããããã«ã GitHubã®ãªããžããªã䜿çšããŠãã³ãŒãã®èšè¿°ãå€§å¹ ã«åæžãã䟿å©ãªã«ããŽãªã䜿çšããŸãã ããã䜿çšããŠãããããã¹ãŠã次ã®ããã«æžãæããããšãã§ããŸãã
[self removeAllSubviews]; return responseString.JSON;
ã¢ããªã±ãŒã·ã§ã³ã®ããŒã«ãªãŒãŒã·ã§ã³
ã»ãšãã©ã®å Žåãå°ãªããšã2ã€ãŸãã¯3ã€ã®ãããžã§ã¯ããã±ãŒã·ã§ã³ãäœæããå¿ èŠããããŸãã Xcodeã«ã¯ãã®ããã®ç¬èªã®ããŒã«ããããããããæ¹åããããã«Appleã®éçºè ã«ä¿¡çšãäžããå¿ èŠããããŸãããç¹ã«ã¢ããªã±ãŒã·ã§ã³ããã§ã«AppStoreã«ãããã¢ããããŒãããªãªãŒã¹ããå¿ èŠãããå Žåãããã¯æã䟿å©ãªæ¹æ³ã§ã¯ãããŸãã-Base Internationalizationãªã©ã®ååãªåé¡ããããŸãã Localizable.Stringsã䜿çšããŸãã æ¢ã«ããã«ééãã人ã¯ãXcodeãStoryboardã®ããŒã«ã©ã€ãºããã* .stringsãã¡ã€ã«ã®å€ãè¿œå ãŸãã¯æŽæ°ã§ãããgenstringsãŠãŒãã£ãªãã£ããã¹ãŠã®ãšã³ããªãåçæããå Žåãé€ããæ°ããè¿œå è¡ã®ã¿ãå ¥åããããšãç¥ã£ãŠããŸãã
Localizable.Stringsããå§ããŸãããã NSLocalizedStringã®åå¥ã®hãã¡ã€ã«ãããšãã°StringConstants.hã匷調衚瀺ããŸãããã®ãã¡ã€ã«ã§ã¯ãããŒã«ã©ã€ãºãããæååã#defineã«ãã£ãŠå®çŸ©ãããŸãã ãã®ã¢ãããŒãã§ã¯ã1ã€ã®ç³ã§2矜ã®é³¥ã殺ãããšãã§ããŸãã
- ãCancelãããLogoutãããInvalid username or passwordããªã©ããããžã§ã¯ãã«ååšããå¯èœæ§ã®ããäžè¬çãªãã¬ãŒãºãšåèªãåéããæ¢è£œã®è¡ã§æã¡éã¶ããšãã§ããããã«ããŸã
- é·ããŠäžå¿«ãªNSLocalizedStringãã¯ããæ¯åå ¥åããã«ããããžã§ã¯ãå ã®æ¢åã®è¡ãåå©çšããŸã
[[[UIAlertView alloc] initWithTitle:kErrorString message:kInvalidLoginOrPasswordString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
ããŒã«ã©ã€ãºããããã¡ã€ã«ã®çæã«é¢ããŠã¯ããã®ããã«ã2çªç®ã®hãã¡ã€ã«ã§ããNewStringConstants.hã䜿çšããŸãããã®ãã¡ã€ã«ã§ã¯ãããŒã«ã©ã€ãºããå¿ èŠããããšã³ããªãè¿œå ããŠããåé€ããŸãã Localizable.Stringsã«çŽæ¥ããã«ããã§ãŒãºã®ã¹ã¯ãªããã«ãã£ãŠæ°ãããšã³ããªãè¿œå ãããŸãã
cd ${PROJECT_DIR}/MyProject genstrings -a -o Base.lproj NewStringConstants.h genstrings -a -o ru.lproj NewStringConstants.h genstrings -a -o pt-PT.lproj NewStringConstants.h genstrings -a -o es.lproj NewStringConstants.h
ãããè¡ãããåŸãLocalizable.Stringsãã¡ã€ã«ã«ããŒã«ã«æååå€ãæžã蟌ãã ãã§ãã
Storyboardã䜿çšãããšãã¿ã¹ã¯ãã¹ã¯ãªããã§è§£æ±ºãããŸããã¹ã¯ãªããã«ã€ããŠã¯ã ãã®èšäºã§è©³ãã説æããŸãã ããã§ãã¹ã¯ãªããã®æ¬è³ªã¯ãibtoolãŠãŒãã£ãªãã£ã䜿çšããŠStoryboardããè¡ãæœåºããåŒã³åºããããšãã«å€æŽãçºçãããã©ããã確èªããããšã§ããããšãç°¡åã«è¿°ã¹ãããšæããŸãã åŸè ãååšããå ŽåãããŒã«ã©ã€ãºãããæååã®ãšã¯ã¹ããŒããè¡ããããã®åŸããŒã«ã©ã€ãºããããã¡ã€ã«ãããŒãžãããŸãã ç¹°ãè¿ããŸãããããŒã«ã©ã€ãºããããã¡ã€ã«ãä¿®æ£ããããã«æ®ã£ãŠããŸãã AppleGlotããŒã«ã«ã€ããŠãèšåããããšæããŸããããã¯äžèšã®èšäºã§èšåãããŠããŸãããããŒã«ã©ã€ãºã®å埩çãªæŽæ°ã§ã¯ç°ãªãã¢ãããŒããåããŸãã ç¹å®ã®ããŒã«ã®éžæã¯ãéçºè ã®å¥œã¿æ¬¡ç¬¬ã§ãã
ã¢ããªã±ãŒã·ã§ã³ãã¹ã
ããã§ã¯ãéãããæ°ã®ããã€ã¹ã§ã®ã¢ããªã±ãŒã·ã§ã³ã®æåãã¹ãã«çŠç¹ãåœãŠãŸãã åäœãã¹ãã§ã«ããŒãããã³ãŒãã®éã«é¢ä¿ãªããæåãã¹ããé€å€ããããšã¯ã§ããŸããã åºæ¬çã«ãéçºè èªèº«ãã¢ããªã±ãŒã·ã§ã³ã®äœæäžã«ãããè¡ããŸãããæºåãã§ããããç®ãããŒãããŠããªãããäœæ¥ã®ãã¹ãŠã®è©³çŽ°ã§å¹³åçãªãŠãŒã¶ãŒãšããŠã¢ããªã±ãŒã·ã§ã³ã䜿çšããäžè¬ãŠãŒã¶ãŒã«ã¢ããªã±ãŒã·ã§ã³ã転éããå¿ èŠããããŸãã ãµããŒããããŠãããã¹ãŠã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãæèŒããããã€ã¹ã»ããå šäœãããã°è¯ãã®ã§ãããåºæ¬çã«ããã§ã¯ãããŸããã ããã€ã¹ã®ã©ã€ã³å šäœãååšããå Žåã§ããååãšããŠããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®çš®é¡ã«éãã¯ãããŸãããããã¯åºæ¬çã«ã¯ãã¡ããå¿ èŠã§ã¯ãããŸãããã確èªããã®ã«å®³ã¯ãããŸããã iOSã·ãã¥ã¬ãŒã¿ãŒãå©ãã«ãªããŸããããã¯ãããããããŠã³ã¡ãã¥ãŒããç®çã®é ç®ãéžæããããšã§æ§æã§ããŸãã ãã ããè¿œå ã®ã¢ã¯ã·ã§ã³ããªããã°ããã¹ã¿ãŒã¯ãœãŒã¹ã³ãŒãã転éããå¿ èŠããããŸãããããã¯åžžã«åãå ¥ãããããšã¯éããŸããã 次ã«ãiOSã·ãã¥ã¬ãŒã¿ãŒã§ã®ãã¹ãçšã«ã¢ã»ã³ãã«ãããã¢ããªã±ãŒã·ã§ã³ã転éããæ¹æ³ãšããã®ããã«è¿œå ã§ã€ã³ã¹ããŒã«ããå¿ èŠããããœãããŠã§ã¢ã«ã€ããŠèª¬æããŸãã
sim_launcherãšios-simãã€ã³ã¹ããŒã«ããŸã
gem install sim_launcher brew install ios-sim
sim_launcherã䜿çšãããšãã·ãã¥ã¬ãŒã¿ã§HTTP GETãªã¯ãšã¹ããä»ããŠiOSã¢ããªã±ãŒã·ã§ã³ãå®è¡ã§ããŸãã ããã¯ããŠãŒã¶ãŒã«ç«¯æ«ã³ãã³ããèšæ¶ãããããšãªãããã¹ãã®ããã®ãã¹ãŠã®ç·šæäœæ¥ããã©ãŠã¶ãŒã§ç·šæã§ãããã䟿å©ã§ãã ios-simã¯ãã¿ãŒããã«ã³ãã³ãã®äžçš®ã®ã©ãããŒã§ãããã·ãã¥ã¬ãŒã¿ãŒã§ã®äœæ¥ãç°¡çŽ åããŸãã sim_launcherã¯ãã°ããæŽæ°ãããŠããªããããios-simã®ææ°ããŒãžã§ã³ãšäºææ§ããªãããã§ãã sim_launcherã€ã³ã¹ããŒã«ãã©ã«ããŒã«ããsimulator.rbãã¡ã€ã«ã®ä»¥äžã®æ©èœãä¿®æ£ããå¿ èŠããããŸãã
simulator.rbãä¿®æ£
def start_simulator(sdk_version, device_family) sdk_version ||= SdkDetector.new(self).latest_sdk_version run_synchronous_command( :start, '--devicetypeid', sdk_version, '--exit' ) end def launch_ios_app(app_path, sdk_version, device_family, app_args = nil) if problem = SimLauncher.check_app_path( app_path ) bangs = '!'*80 raise "\n#{bangs}\nENCOUNTERED A PROBLEM WITH THE SPECIFIED APP PATH:\n\n#{problem}\n#{bangs}" end sdk_version ||= SdkDetector.new(self).latest_sdk_version args = ["--args"] + app_args.flatten if app_args run_synchronous_command( :launch, app_path, '--devicetypeid', sdk_version, '--exit', *args ) end
ã·ãã¥ã¬ãŒã¿ãŒã§ãã«ããå®è¡ãã
sim_launcher
ãã®ã³ãã³ãã¯ãããŒã8881ã®WebãµãŒãã¹ã解é€ããŸãã <path-to-app>ã®ä»£ããã«.appãã¡ã€ã«ãžã®ãã«ãã¹ãæå®ããŠã httpïŒ// localhostïŒ8881 / launch_iphone_appïŒSdk = com.apple.CoreSimulator.SimDeviceType.iPhone-6ãïŒ 208.1ïŒapp_pathã®ãã©ãŠã¶ãŒã«ç§»åããŸã= <path-to-app> ã iOS 8.1ã§iPhone 6ã·ãã¥ã¬ãŒã¿ãŒãéãå Žåããã¹ãŠæ£åžžã«æ©èœããŠããŸãã ãã©ãŠã¶ãŠã£ã³ããŠã«ãšã©ãŒã衚瀺ãããå Žåã¯ãsim_launcherã®ãœãŒã¹ã³ãŒãã«åé¡ãããããã·ãã¥ã¬ãŒã¿ã§ã®äœæ¥ã.appãã¡ã€ã«ã§ãµããŒããããŠããªãå¯èœæ§ããããŸãã 次ã®ã³ãã³ãã䜿çšããŠãã·ãã¥ã¬ãŒã¿ãŒã®ã¢ã»ã³ããªãäœæã§ããŸãã
xcodebuild -workspace MyProject.xcworkspace -scheme MyProject -arch i386 -sdk iphonesimulator
æåŸã®ä»äžã
ãã©ãŠã¶ãŒããã·ãã¥ã¬ãŒã¿ãŒãå®è¡ããã®ã¯äŸ¿å©ã§ãããã¢ãã¬ã¹ãæåã§å ¥åããã®ã¯ããŸããããããŸããã ãã¹ã¿ãŒã«ââ䟿å©ãªUIãæäŸããå°ããªhtmlããŒãžãäœæã§ããŸãã æãç°¡åãªå®è£ ã¯æ¬¡ã®ãšããã§ãã
HTMLã³ãŒã
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Testing utility</title> </head> <body> <form action="http://localhost:8881/launch_iphone_app" method="get" target="_blank"> <p><select name="sdk" size="15"> <option disabled>Select a device</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 7.1">iPhone 4s iOS 7.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-5, 7.1">iPhone 5 iOS 7.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 7.1">iPhone 5s iOS 7.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPad-2, 7.1">iPad 2 iOS 7.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 7.1">iPad Retina iOS 7.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPad-Air, 7.1">iPad Air iOS 7.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 8.1">iPhone 4s iOS 8.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-5, 8.1">iPhone 5 iOS 8.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus, 8.1">iPhone 6 Plus iOS 8.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPhone-6, 8.1">iPhone 6 iOS 8.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 8.1">iPhad Retina iOS 8.1</option> <option value="com.apple.CoreSimulator.SimDeviceType.iPad-Air, 8.1">iPad Air iOS 8.1</option> </select></p> <p><input name="app_path"/></p> <p><input type="submit" value="Run"/></p> </form> </body> </html>
çŸåšios-simãä»ããŠèµ·åã§ããã·ãã¥ã¬ãŒã¿ã®ãªã¹ãã¯ã次ã®ã³ãã³ãã䜿çšããŠååŸã§ããŸãã
ios-sim showdevicetypes
ãã¶ã€ã³ã«ãã
iOSã®éçºè ã®å€ãã¯ãçµéšããªããŠããAdobe Photoshopã®éåžžã«äžçŽã®ãŠãŒã¶ãŒã§ããããšæããŸããæã«ã¯ãã¬ã€ã¢ãŠãããäœããå€æŽãŸãã¯ãšã¯ã¹ããŒãããå¿ èŠãããããã§ãã ã€ã³ã¿ãŒãã§ã€ã¹èŠçŽ ãã«ããããã«ã¯ãæ°åã¯ãªãã¯ããã ãã§ãããå®è¡ããã¹ã¯ãªãããæ¥ç¶ã§ããŸãã
ã¢ããªã±ãŒã·ã§ã³ãå ¬é
AppStoreã®ã¢ããªã±ãŒã·ã§ã³ããŒãžãé©åã«èšèšããã«ã¯ãé©åãªã¹ã¯ãªãŒã³ã·ã§ãããæäŸããå¿ èŠããããŸãã ãµããŒããããŠããããã€ã¹ããšã«äœæããå¿ èŠãããããšã«å ããŠããã¹ãŠã®ããŒã«ã©ã€ãºã«ã泚æããå¿ èŠããããŸãã èªååãè¡ããªãå Žåããã®ããã»ã¹
ããã«ã€ããŠã¯ããã®èšäºãå®æãããããšæããŸãã iOSã®éçºã®æ¥œãããåŠã³å§ãã人ãèå³ãæã£ãŠãã人ã ãã§ãªããéå±ãªäœæ¥ã®å€ããã³ã³ãã¥ãŒã¿ãŒã«ä»»ããŠæãé¢çœãéçºãä»»ããããšãç¥ããªãçµéšè±å¯ãªéçºè ã«ã圹ç«ã€ããšãé¡ã£ãŠããŸãã ã³ã¡ã³ãã§ã¯ãäžéšã®ã¿ã¹ã¯ãé«éåãŸãã¯ç°¡çŽ åããããã®ãã®ä»ã®ããŒã«ããã³æ¹æ³ãããã°ããããè°è«ããããšãææ¡ããŸãã