xcodebuild
单写一个xcodebuild,工程编译使用默认的scheme和编译配置。
scheme、targets、配置、目标设备、SDK和导出数据位置可以在后面自定义配置
archive打包操作
xcodebuild archive -workspace PROJECT_NAME.xcworkspace -scheme SCHEME_NAME -configuration release -archivePath EXPORT_ARCHIVE_PATH -archivePath:设置项目的归档路径
导出ipa文件
xcodebuild -exportArchive -archivePath EXPORT_ARCHIVE_PATH -exportPath EXPORT_IPA_PATH -exportOptionsPlist ExportOptionsPlistPath -allowProvisioningUpdates -exportArchive:导出ipa -exportPath:导出ipa文件的路径 -exportOptionsPlist:文件导出时的配置信息 -allowProvisioningUpdates:允许xcodebuild与苹果网站通讯,进行自动签名,证书自动更新,生成。
单元测试
xcodebuild test -project PROJECT_NAME.xcodeproj -scheme SCHEME_NAME -destination ‘platform=iOS Simulator,name=iPhone 6s,OS=11.2‘ - configuration Debug -derivedDataPath output -derivedDataPath:产生的缓存文件放在./output目录下 configuration:编译环境,选择Debug/Release -destination :选择test时的目标设备和系统版本号
xcodebuild test -project PROJECT_NAME.xcodeproj -scheme SCHEME_NAME -destination ‘platform=iOS Simulator,name=iPhone 6s,OS=11.2‘ -only-testing:TARGET_NAME/CLASS_NAME/FUNC_NAME -quiet -only-testing: 只测试某一个方法,target名/类名/方法名 -quiet : 除了错误和警告不打印任何信息
self.app = [[XCUIApplication alloc] initWithBundleIdentifier:@"com.xxx.id"]; [self.app launch];
xcodebuild test-without-building -workspace PROJECT_NAME.xcworkspace -scheme doctor -destination ‘platform=iOS Simulator,name=iPhone 6s,OS=12.0‘ -only-testing:TARGET_NAME/CLASS_NAME/FUNC_NAME
//1.产生xctestrun文件 xcodebuild build-for-testing -project PROJECT_NAME.xcodeproj -scheme SCHEME_NAME -destination ‘platform=iOS Simulator,name=iPhone 6s,OS=11.2‘ - configuration Debug -derivedDataPath output -derivedDataPath: derivedDataPath/Build/Products目录下生成一个.xctestrun文件,包含测试信息 //2.使用xctestrun文件(不带-workspace/-project/-scheme参数) xcodebuild test-without-building -destination ‘platform=iOS Simulator,name=iPhone 6s,OS=12.0‘ -xctestrun DerivedDataPath.xctestrun -only-testing:TARGET_NAME/CLASS_NAME/FUNC_NAME -xctestrun:有这个选项就从指定的路径下寻找bundle,没有这个选项在derivedDataPath下寻找bundle -only-testing:TARGET_NAME/CLASS_NAME/FUNC_NAME
xcodebuild常见action
genstrings -a /path/to/source/files/*.m
ibtool --generate-strings-file Localizable.strings en.lpoj/Interface.xib
原文:https://www.cnblogs.com/zhou--fei/p/11371019.html