Running an Applescript after build phase in Xcode - ios

I have an Applescript that opens the Safari developer tools. This saves me from the hassle of clicking Develop -> Inspect -> index.html every time I build a Cordova / Phonegap app.
I would now like to invoke this Applescript when I build the project and open it in the simulator.
I've tried adding a building phase and adding the script as instructed in https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaRunScriptBuildPhase.html.
However when I build the project in XCode I'm getting an error: "auto_opendevtools.applescript: bad interpreter: Permission denied". Seems all the permissions are fine.
How I entered the script in the build phase:
Leads to error:

The "Add Run Script Build Phase" need a shell command or a path of the shell script.
To run an AppleScript from a shell script, you must use the osascript command.
osascript "/the path of/auto_opendevtools.applescript"

Related

Where can I view the output of an XCode runscript phase when building for iOS with Flutter?

I am having an issue with one of my build phase scripts on XCode. I would like to view the output of my script which is trivial when I build using XCode (cmd + 9 on OS X). However, when I build using flutter, there is no log on XCode - nothing new shows up on that tab. I have an echo statement in my build phase script I would like to see the output of. Anybody know where to find this output?
try:
flutter build --verbose
from the command line

command fails on jenkins, but works on terminal

I'm working on using fastlane screengrab/snapshot to take screenshots of my android and ios app. When I run them locally on terminal, they work perfectly, but when I run them from jenkins, they fail. I'm using macOS.
Android:
/Users/shared/Library/Android/sdk/tools/emulator -avd Pixel_API_22 &
fastlane screengrab
(These 2 are in a .sh)
The first line failed: PANIC: Cannot find AVD system path. Please
define ANDROID_SDK_ROOT
iOS:
fastlane snapshot
it failed while trying to build a test because of an provisioning profile error:
xcodebuild -showBuildSettings -scheme UITests -project ./abc.xcodeproj
(this is a command that fastlane snapshot execute automatically)
Again, they both run smoothly on terminal (I ran them in the same workspace as junkins)
Double-check the environment settings after executing your job in Jenkins: you might see differences with the same environment settings as seen with your user account in command-line (where it is working)
The username might be different (if your Jenkins server/agent runs with another account).
The OP Son Nguyen confirms the PATH issue:
the developer who set up jenkins put a wrong path to android sdk, so I was able to run the android part by fixing the path.
And the OP adds:
fastlane was installed in /usr/local/bin while jenkins was in /User/myUser: So, somehow they didn't work well together.
I reinstalled fastlane in /User/myUser and it worked.
This got it working for me.
I had to include this at the top of my script :
#!/bin/zsh
source ~/.zshrc
and my .zshrc had this:
export PATH="$PATH:"/usr/local/bin/
export SSL_CERT_FILE=/etc/ssl/cert.pem # for openssl error
export ANDROID_HOME=/Users/jenkins/Library/Android/sdk

Cordova Build Creates xcarchive not an ipa. Why?

I am using Cordova to create and build my application. Today (12/12/17), I am using the current version of everything (cordova, xcode, etc). When I run:
cordova build ios --device --release
at the end of the build process that happens, I get no errors. But I do get this message:
Exported myappname.xcarchive to:
/Users/.../platforms/ios/build/device
** EXPORT SUCCESS **
I don't see anywhere in build logs that a .ipa file was created. Just a stupid .xcarchive.
Note: I cannot to edit project information or settings in XCode manually, because I am running this Cordova command as part of automated build process. I should be able to create an .ipa via Cordova CLI, without having to open XCode.
If you're having the same experience I did, check the actual physical directory for the .ipa file. Turns out even though my build log never said so, the .ipa file was actually being built alongside the .xcarchive. It should be in /platforms/ios/build/device/myappname.ipa.

How to build + run cordova app in 1 step on Mac OS X?

I use Cordova/PhoneGap to create an iOS app. During development, I do changes to HTML/CSS/JS files in www folder and thus have to rebuild regularly. I usually do this on my Mac:
In terminal, I type: cordova prepare
I press CMD + tab to switch to Xcode
I hit CMD + 'R' to run the app on my attached iPhone
This works but it's a little annoying to repeat these steps all the time. Is there a way to speed this up, e.g. by creating a shell script that automagically does all these steps?
Sure, on xcode go to "Build Phases", press the + button and select "New Run Script Phase".
Move it to be over the "Copy www directory"
And use this code:
cordova prepare ios
EDIT:
Is for some reason you can't move the new script over the "Copy www directory" one, I've found another way that will work.
Just open the "Copy www directory" (it's a build script too) and add the cordova prepare ios before the existing code
I found the best solution for me. First, I installed ios-deploy via npm:
$ npm install -g ios-deploy --unsafe-perm=true
Then I simply run this for iOS for example:
$ cordova run ios --device
The run command will internally automatically call prepare and thus copy the content of www and then launch the app on the device.

Showing the build command Xcode uses

Is there a way to see the xcodebuild command that Xode uses for building?
I have created a library file with Xcodebuild command from Terminal. But there are some differences between the files generated from terminal and Xcode UI.
I use this behavior to switch to the log when building starts.
.
In the log you can find all the commands Xcode is executing.

Resources