Skip to content

Commit

Permalink
Merge pull request #3 from luodongseu/master
Browse files Browse the repository at this point in the history
适配Xcode12+
  • Loading branch information
YorkShen authored Nov 5, 2021
2 parents c844b81 + 4f403a1 commit 369e1a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
2 changes: 2 additions & 0 deletions packages/@weex/plugins/build/src/ios/ios-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default class IosBuilder extends Builder {
'-scheme': projectInfo.scheme,
'-configuration': 'Debug',
'-sdk': 'iphonesimulator',
'-arch': 'x86_64', // 与-destination可以任意保留一个
'-destination': `"platform=iOS Simulator,id=${options.deviceId}"`,
'-derivedDataPath': IOS_DERIVE_DATA_PATH,
}

Expand Down
36 changes: 18 additions & 18 deletions packages/@weex/plugins/device/src/ios/ios-devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default class IosDevices extends Devices {

private getIosDevicesList(): Array<DeviceInfo> {
// Doctor TODO `xcrun`
const text = runAndGetOutput('xcrun instruments -s devices')
const text = runAndGetOutput('xcrun xctrace list devices')
const devices = []
const REG_DEVICE = /(.*?) \((.*?)\) \[(.*?)]/
const REG_DEVICE = /^([^\(]*) \((.*?)\).*\((.*)\)$/;

const lines = text.split('\n')
for (const line of lines) {
Expand Down Expand Up @@ -64,24 +64,24 @@ export default class IosDevices extends Devices {

async launchById(id: DeviceInfo['id']): Promise<String> {
try {
await exec(`xcrun instruments -w ${id}`, {
event: this,
})
} catch (error) {
if (error) {
if (
error.toString().indexOf('Waiting for device') !== -1 ||
error.toString().indexOf('No template (-t) specified') !== -1 ||
error.toString().indexOf('Could not create output document') !== -1
) {
// instruments always fail with 255 because it expects more arguments,
// but we want it to only launch the simulator
return
await exec.exec(`xcrun simctl boot ${id}`, {
event: this,
});
}
catch (error) {
if (error) {
if (error.toString().indexOf('code=405') >= 0 ||
error.toString().indexOf('Waiting for device') !== -1 ||
error.toString().indexOf('No template (-t) specified') !== -1 ||
error.toString().indexOf('Could not create output document') !== -1) {
// instruments always fail with 255 because it expects more arguments,
// but we want it to only launch the simulator
return;
}
throw error;
}
throw error
}
}
}
}

async run(options: RunDeviceOptions) {
const deviceInfo = this.getDeviceById(options.id)
Expand Down
2 changes: 1 addition & 1 deletion packages/@weex/plugins/run/src/base/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class Runner extends EventEmitter {
this.watchFileChange()
this.emit(messageType.state, runnerState.watchFileChangeDone)

appPath = await this.buildNative(options)
appPath = await this.buildNative(Object.assign(this.config, options))
this.emit(messageType.state, runnerState.buildNativeDone)

await this.installAndLaunchApp(appPath)
Expand Down

0 comments on commit 369e1a3

Please sign in to comment.