How to build Xcode project from the command line?
After having a working configuration in Xcode, open a shell and navigate to the directory, where your <NAME>.xcodeproj
resides.
After running:
xcodebuild -list -project <NAME>.xcodeproj/
you see a list of Schemes.
Copy the desired scheme name and run:
xcodebuild -workspace <WORKSPACE NAME> -scheme <SCHEME NAME> build
You can install [ios-deploy][1] i.e. via:
npm install -g ios-deploy
Copy the app path from the end of the xcodebuild output and run:
ios-deploy --debug --bundle <APP PATH>
Now the app should be launched on i.e. a connected device. [1]: https://github.com/phonegap/ios-deploy
Related videos on Youtube
14wml
Updated on July 09, 2022Comments
-
14wml almost 2 years
I've tried reading the Xcode Tools documentation Apple provides, so that I can use the Terminal to build a
.app
file and run the resulting app on the Simulator. Essentially what I want to do is do the same thing asCmd
+R
does on Xcode.So far I've attempted to build my
.xcodeproj
like this:xcodebuild -configuration Debug build
However, when I install & run it on the Simulator I get an app w/ a black screen:
// Boot device xcrun simctl boot "iPhone 7" // Install app xcrun simctl install "iPhone 7" "/Users/.../MyApp/build/Debug-iphoneos/MyApp.app" // Open simulator open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app // Launch app using its bundle id xcrun simctl launch booted "com.example.apps.MyApp"
Not to mention the
xcrun simctl launch booted "com.example.apps.MyApp"
line never terminates and on the Simulator it keeps trying to open and reopen the app, but the app only ever shows a black screen.If anyone could tell me what I'm doing wrong with the building of the
.xcodeproj
that would be great!