参考
xcode开发套件IDE
编译第一个项目
git clone https://github.com/appium/ios-uicatalog.git
使用xcode打开
编译
GenerateDSYMFile /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app.dSYM /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app/UICatalog (in target: UICatalog)
cd /Users/seveniruby/temp/appium/ios/ios-uicatalog
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app/UICatalog -o /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app.dSYM
CodeSign /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app (in target: UICatalog)
cd /Users/seveniruby/temp/appium/ios/ios-uicatalog
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
/usr/bin/codesign --force --sign - --timestamp=none /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app
Touch /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app (in target: UICatalog)
cd /Users/seveniruby/temp/appium/ios/ios-uicatalog
/usr/bin/touch -c /Users/seveniruby/Library/Developer/Xcode/DerivedData/UICatalog-dfavfehsvaabuqdpmxouzqphclvl/Build/Products/Debug-iphonesimulator/UICatalog.app
基于模拟器的自动化测试
找模拟器
instruments -s devices
An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65 xcodebuild error message: 2019-05-29 20:34:28.757 xcodebuild[29168:7334636] Error Domain=IDETestApplcationDependencyMapperErrorDomain Code=2 "The bundle identifier for WebDriverAgentRunner-Runner.app couldn’t be read." UserInfo={NSLocalizedFailureReason=The application may be damaged or incomplete: “/Users/seveniruby/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app”., NSURL=file:///Users/seveniruby/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/, NSFilePath=/Users/seveniruby/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app, NSLocalizedDescription=The bundle identifier for WebDriverAgentRunner-Runner.app couldn’t be read.} Testing failed: 'RoutingHTTPServer/RoutingConnection.h' file not found Test session results and logs: /Users/seveniruby/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Logs/Test/Test-WebDriverAgentRunner-2019.05.29_20-34-22-+0800.xcresult ** TEST EXECUTE FAILED ** Testing started on 'iPhone X'
解决方法:XCUITest Real Devices (iOS) - Appium
[XCUITest] Beginning test with command 'xcodebuild build-for-testing test-without-building -project /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=882B0870-756A-4395-925F-2578E60CBB08 IPHONEOS_DEPLOYMENT_TARGET=12.2 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO' in directory '/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
使用xcode打开项目,并进行配置,设置好签名即可
WDA webdriveragent
/usr/local/lib/node_modules/appium/node_modules/_appium-xcuitest-driver@2.114.1@appium-xcuitest-driver/WebDriverAgent
iOS
模拟器
真机
WebView
TODO
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {"desiredCapabilities":{"bundleId":"com.example.apple-samplecode.UICatalog","arguments":[],"environment":{},"eventloopIdleDelaySec":0,"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}}[debug] [WD Proxy] Got response with status 200: {"value":"+[XCAXClient_iOS sharedClient]: unrecognized selector sent to class 0x10afb4880\\n\\n(\\n\\t0 CoreFoundation 0x000000010c0506fb __exceptionPreprocess + 331\\n\\t1 libobjc.A.dylib 0x000000010b5f4ac5 objc_exception_throw + 48\\n\\t2 CoreFoundation 0x000000010c06e9b4 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132\\n\\t3 CoreFoundation 0x000000010c055443 ___forwarding___ + 1443\\n\\t4 CoreFoundation 0x000000010c057238 _CF_forwarding_prep_0 + 120\\n\\t5 WebDriverAgentLib 0x0000000123529724 __37+[FBApplication fb_activeApplication]_block_invoke + 36\\n\\t6 WebDriverAgentLib 0x000000012350003a -[FBRunLoopSpinner spinUntilTrue:error:] + 138\\n\\t7 WebDriverAgentLib 0x00000001234fff86 -[FBRunLoopSpinner spinUntilTrue:] + 86\\n\\t8 WebDriverAgentLib 0x0000000123529478 +[FBApplication fb_activeApplication] + 136\\n\\t9 WebDriverA...
[warn] [WD Proxy] Got an unexpected response: {"value":"+[XCAXClient_iOS sharedClient]: unrecognized selector sent to class 0x10afb4880\\n\\n(\\n\\t0 CoreFoundation 0x000000010c0506fb __exceptionPreprocess + 331\\n\\t1 libobjc.A.dylib 0x000000010b5f4ac5 objc_exception_throw + 48\\n\\t2 CoreFoundation ...
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[debug] [XCUITest] Failed to create WDA session (An unknown server-side error occurred while processing the command. Original error: +[XCAXClient_iOS sharedClient]: unrecognized selector sent to class 0x10afb4880
[debug] [XCUITest]
[debug] [XCUITest] (
[debug] [XCUITest] \t0 CoreFoundation 0x000000010c0506fb __exceptionPreprocess + 331
[debug] [XCUITest] \t1 libobjc.A.dylib 0x000000010b5f4ac5 objc_exception_throw + 48
[debug] [XCUITest] \t2 CoreFoundation 0x000000010c06e9b4 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
[debug] [XCUITest] \t3 CoreFoundation 0x000000010c055443 ___forwarding___ + 1443
[debug] [XCUITest] \t4 CoreFoundation 0x000000010c057238 _CF_forwarding_prep_0 + 120
[debug] [XCUITest] \t5 WebDriverAgentLib 0x0000000123529724 __37+[FBApplication fb_activeApplication]_block_invoke + 36
[debug] [XCUITest] \t6 WebDriverAgentLib 0x000000012350003a -[FBRunLoopSpinner spinUntilTrue:error:] + 138
[debug] [XCUITest] \t7 WebDriverAgentLib 0x00000001234fff86 -[FBRunLoopSpinner spinUntilTrue:] + 86
[debug] [XCUITest] \t8 WebDriverAgentLib 0x0000000123529478 +[FBApplication fb_activeApplication] + 136
[debug] [XCUITest] \t9 WebDriverAgentLib 0x00000001235133be -[FBSession application] + 318
[debug] [XCUITest] \t10 WebDriverAgentLib 0x000000012351ab17 +[FBSessionCommands currentCapabilities] + 87
[debug] [XCUITest] \t11 WebDriverAgentLib 0x000000012351a9e9 +[FBSessionCommands sessionInformation] + 233
[debug] [XCUITest] \t12 WebDriverAgentLib 0x0000000123519fd8 +[FBSessionCommands handleCreateSession:] + 1432
[debug] [XCUITest] \t13 WebDriverAgentLib 0x00000001234feac6 -[FBRoute_TargetAction mountRequest:intoResponse:] + 182
[debug] [XCUITest] \t14 WebDriverAgentLib 0x00000001234f3fd9 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 553
[debug] [XCUITest] \t15 RoutingHTTPServer 0x00000001235b2c18 -[RoutingHTTPServer handleRoute:withRequest:response:] + 136
[debug] [XCUITest] \t16 RoutingHTTPServer 0x00000001235b34fa __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 47
[debug] [XCUITest] \t17 libdispatch.dylib 0x00000001109dbd02 _dispatch_client_callout + 8
[debug] [XCUITest] \t18 libdispatch.dylib 0x00000001109e86e8 _dispatch_async_and_wait_invoke + 109
[debug] [XCUITest] \t19 libdispatch.dylib 0x00000001109dbd02 _dispatch_client_callout + 8
[debug] [XCUITest] \t20 libdispatch.dylib 0x00000001109e7a50 _dispatch_main_queue_callback_4CF + 1276
[debug] [XCUITest] \t21 CoreFoundation 0x000000010bfb78a9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
[debug] [XCUITest] \t22 CoreFoundation 0x000000010bfb1f56 __CFRunLoopRun + 2310
[debug] [XCUITest] \t23 CoreFoundation 0x000000010bfb1302 CFRunLoopRunSpecific + 626
[debug] [XCUITest] \t24 Foundation 0x000000010b0bf044 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 277
[debug] [XCUITest] \t25 WebDriverAgentLib 0x00000001234f2dec -[FBWebServer startServing] + 348
[debug] [XCUITest] \t26 WebDriverAgentRunner 0x00000001234e603a -[UITestingUITests testRunner] + 122
[debug] [XCUITest] \t27 CoreFoundation 0x000000010c0574cc __invoking___ + 140
[debug] [XCUITest] \t28 CoreFoundation 0x000000010c054a45 -[NSInvocation invoke] + 325
[debug] [XCUITest] \t29 XCTest 0x000000010aeaab74 __24-[XCTestCase invokeTest]_block_invoke.194 + 78
[debug] [XCUITest] \t30 XCTest 0x000000010af028a4 -[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
[debug] [XCUITest] \t31 XCTest 0x000000010af027c2 -[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
[debug] [XCUITest] \t32 XCTest 0x000000010aeaa804 __24-[XCTestCase invokeTest]_block_invoke + 848
[debug] [XCUITest] \t33 XCTest 0x000000010af08d01 -[XCUITestContext performInScope:] + 128
[debug] [XCUITest] \t34 XCTest 0x000000010aeaa3f1 -[XCTestCase testContextPerformInScope:] + 116
[debug] [XCUITest] \t35 XCTest 0x000000010aeaa4a7 -[XCTestCase invokeTest] + 137
[debug] [XCUITest] \t36 XCTest 0x000000010aeabf73 __26-[XCTestCase performTest:]_block_invoke_2 + 43
[debug] [XCUITest] \t37 XCTest 0x000000010af028a4 -[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
[debug] [XCUITest] \t38 XCTest 0x000000010af027c2 -[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
[debug] [XCUITest] \t39 XCTest 0x000000010aeabe8a __26-[XCTestCase performTest:]_block_invoke.316 + 88
[debug] [XCUITest] \t40 XCTest 0x000000010af133b7 +[XCTContext runInContextForTestCase:block:] + 225
[debug] [XCUITest] \t41 XCTest 0x000000010aeab5f8 -[XCTestCase performTest:] + 676
[debug] [XCUITest] \t42 XCTest 0x000000010aeeed6c -[XCTest runTest] + 57
[debug] [XCUITest] \t43 XCTest 0x000000010aea60d7 __27-[XCTestSuite performTest:]_block_invoke + 365
[debug] [XCUITest] \t44 XCTest 0x000000010aea58b3 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
[debug] [XCUITest] \t45 XCTest 0x000000010aea5b6f -[XCTestSuite performTest:] + 290
[debug] [XCUITest] \t46 XCTest 0x000000010aeeed6c -[XCTest runTest] + 57
[debug] [XCUITest] \t47 XCTest 0x000000010aea60d7 __27-[XCTestSuite performTest:]_block_invoke + 365
[debug] [XCUITest] \t48 XCTest 0x000000010aea58b3 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
[debug] [XCUITest] \t49 XCTest 0x000000010aea5b6f -[XCTestSuite performTest:] + 290
[debug] [XCUITest] \t50 XCTest 0x000000010aeeed6c -[XCTest runTest] + 57
[debug] [XCUITest] \t51 XCTest 0x000000010aea60d7 __27-[XCTestSuite performTest:]_block_invoke + 365
[debug] [XCUITest] \t52 XCTest 0x000000010aea58b3 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
[debug] [XCUITest] \t53 XCTest 0x000000010aea5b6f -[XCTestSuite performTest:] + 290
[debug] [XCUITest] \t54 XCTest 0x000000010aeeed6c -[XCTest runTest] + 57
[debug] [XCUITest] \t55 XCTest 0x000000010af1d986 __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 171
[debug] [XCUITest] \t56 XCTest 0x000000010af1da57 __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.80 + 68
[debug] [XCUITest] \t57 XCTest 0x000000010aebd474 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 588
[debug] [XCUITest] \t58 XCTest 0x000000010af1d73d -[XCTTestRunSession runTestsAndReturnError:] + 623
[debug] [XCUITest] \t59 XCTest 0x000000010ae8a41c -[XCTestDriver runTestsAndReturnError:] + 446
[debug] [XCUITest] \t60 XCTest 0x000000010af0f56f _XCTestMain + 2333
[debug] [XCUITest] \t61 WebDriverAgentRunner-Runner 0x000000010abbb053 -[_XCTRunnerAppDelegate applicationWillResignActive:] + 0
[debug] [XCUITest] \t62 WebDriverAgentRunner-Runner 0x000000010abbaf51 _XCTRunnerRunTests + 0
[debug] [XCUITest] \t63 CoreFoundation 0x000000010bfb7aec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
[debug] [XCUITest] \t64 CoreFoundation 0x000000010bfb72b0 __CFRunLoopDoBlocks + 336
[debug] [XCUITest] \t65 CoreFoundation 0x000000010bfb1b34 __CFRunLoopRun + 1252
[debug] [XCUITest] \t66 CoreFoundation 0x000000010bfb1302 CFRunLoopRunSpecific + 626
[debug] [XCUITest] \t67 GraphicsServices 0x00000001145352fe GSEventRunModal + 65
[debug] [XCUITest] \t68 UIKitCore 0x000000010cf8aba2 UIApplicationMain + 140
[debug] [XCUITest] \t69 WebDriverAgentRunner-Runner 0x000000010abbb21b main + 183
[debug] [XCUITest] \t70 libdyld.dylib 0x0000000110a49541 start + 1
[debug] [XCUITest] )). Retrying...[debug] [BaseDriver] Event 'wdaSessionAttempted' logged at 1559139439652 (22:17:19 GMT+0800 (CST))
[debug] [XCUITest] Sending createSession command to WDA
[debug] [WD Proxy] Matched '/session' to command name 'createSession'