Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The config file - which unless specified in the cli should live in `./owl.config
| **ios config** | | |
| `ios.workspace` | true | Path to the `.xcworkspace` file of your react-native project |
| `ios.scheme` | true | The name of the scheme you would like to use for building the app |
| `ios.configuration` | true | The build configuration that should be used. Defaults to Debug |
| `ios.buildCommand` | false | Overrides the `xcodebuild` command making the above options obselete |
| `ios.binaryPath` | false | The path to the binary, if you are using a custom build command |
| `ios.quiet` | false | Passes the quiet flag to `xcode builds` |
Expand Down
1 change: 1 addition & 0 deletions example/owl.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ios": {
"workspace": "ios/OwlDemo.xcworkspace",
"scheme": "OwlDemo",
"configuration": "Release",
"device": "iPhone 13 Pro",
"quiet": true
},
Expand Down
2 changes: 2 additions & 0 deletions src/cli/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('build.ts', () => {
ios: {
workspace: 'ios/RNDemo.xcworkspace',
scheme: 'RNDemo',
configuration: 'Debug',
device: 'iPhone Simulator',
},
};
Expand All @@ -38,6 +39,7 @@ describe('build.ts', () => {
ios: {
workspace: 'ios/RNDemo.xcworkspace',
scheme: 'RNDemo',
configuration: 'Debug',
quiet: true,
device: 'iPhone Simulator',
},
Expand Down
6 changes: 5 additions & 1 deletion src/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const buildIOS = async (
`xcodebuild`,
`-workspace ${config.ios?.workspace}`,
`-scheme ${config.ios?.scheme}`,
`-configuration Debug`,
`-configuration ${config.ios?.configuration}`,
`-sdk iphonesimulator`,
`-derivedDataPath ios/build`,
];
Expand All @@ -24,6 +24,8 @@ export const buildIOS = async (
buildCommand.push('-quiet');
}

logger.info(`[OWL] Building the app with: ${buildCommand.join(' ')}.`);

await execa.command(buildCommand.join(' '), { stdio: 'inherit' });
};

Expand All @@ -43,6 +45,8 @@ export const buildAndroid = async (
? undefined
: path.join(process.cwd(), '/android');

logger.info(`[OWL] Building the app with: ${buildCommand.join(' ')}.`);

await execa.command(buildCommand.join(' '), { stdio: 'inherit', cwd });
};

Expand Down
32 changes: 31 additions & 1 deletion src/cli/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,35 @@ describe('config.ts', () => {
await expect(validate()).resolves.toEqual(config);
});

it('accepts a target for iOS', async () => {
const config = {
ios: {
workspace: 'ios/RNDemo.xcworkspace',
scheme: 'Test',
configuration: 'Release',
device: 'iPhone Simulator',
},
};

const result = await validateSchema(config);

expect(result?.ios?.configuration).toEqual('Release');
});

it('defaults the target to Debug for iOS', async () => {
const config = {
ios: {
workspace: 'ios/RNDemo.xcworkspace',
scheme: 'Test',
device: 'iPhone Simulator',
},
};

const result = await validateSchema(config);

expect(result?.ios?.configuration).toEqual('Debug');
});

it("rejects an ios config that doesn't have either workspace/scheme or buildCommand", async () => {
const config = { ios: {} };

Expand Down Expand Up @@ -143,10 +172,11 @@ describe('config.ts', () => {

describe('getConfig', () => {
it('returns a validated config', async () => {
const expectedConfig = {
const expectedConfig: Config = {
ios: {
workspace: 'ios/RNDemo.xcworkspace',
scheme: 'RNDemo',
configuration: 'Debug',
device: 'iPhone Simulator',
},
android: {
Expand Down
3 changes: 2 additions & 1 deletion src/cli/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const validateSchema = (config: {}): Promise<Config> => {
type: 'object',
properties: {
workspace: { type: 'string', nullable: true },
configuration: { type: 'string', nullable: true, default: 'Debug' },
scheme: { type: 'string', nullable: true },
buildCommand: { type: 'string', nullable: true },
binaryPath: { type: 'string', nullable: true },
Expand Down Expand Up @@ -45,7 +46,7 @@ export const validateSchema = (config: {}): Promise<Config> => {
additionalProperties: false,
};

const ajv = new Ajv();
const ajv = new Ajv({ useDefaults: true });
const validate = ajv.compile(configSchema);

return new Promise((resolve, reject) => {
Expand Down
1 change: 1 addition & 0 deletions src/cli/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('run.ts', () => {
ios: {
workspace: 'ios/RNDemo.xcworkspace',
scheme: 'RNDemo',
configuration: 'Debug',
device: 'iPhone Simulator',
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getIOSBundleIdentifier = (appPath: string): string => {

export const runIOS = async (config: Config, logger: Logger) => {
const stdio = config.debug ? 'inherit' : 'ignore';
const DEFAULT_BINARY_DIR = '/ios/build/Build/Products/Debug-iphonesimulator';
const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${config.ios?.configuration}-iphonesimulator`;
const cwd = config.ios?.binaryPath
? path.dirname(config.ios?.binaryPath)
: path.join(process.cwd(), DEFAULT_BINARY_DIR);
Expand Down
2 changes: 2 additions & 0 deletions src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type ConfigIOS = {
workspace?: string;
/** The scheme to build. */
scheme?: string;
/** The build configuration that should be used for this target. Usually Debug or Release. */
configuration?: string;
/** Overrides the `xcodebuild` command making the workspace & scheme options obselete. */
buildCommand?: string;
/** Path to the .app that will get generated by a custom build command. Ignored when not using a custom build command. */
Expand Down
Loading