Run a .js script when bundling react native code with Xcode - xcode

I have this script:
node src/runlink.js
that I'm running with npm run link but I would like to run it when building my code with Xcode.
is there any way to do that ? I tried to do it with the build phase but haven't succeed

You need to run a script in Build Phases.
On the Project Navigator (left column) select your project.
Then on the Targets select your desired target
Clic on Build Phases tab
Click on the + sign to create New Run Script Phase
Type node "${SRCROOT}/../src/runlink.js"

Related

Where to put the carthage file when using the AWS-sdk-iOS

The cartFile creates a MyProject.xworkspace.
It seems that this file is not in the same folder as the MyProject.xcodeproj.
Is it a problem ?
Secondly, when I istall the AWS librairies with Carthage, I have to add :
Under the Build Phases tab in your Target, click the + button on the top left and then select New Run Script Phase. Then setup the build phase as follows. Make sure this phase is below the Embed Frameworks phase.
Shell /bin/sh
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework/strip-frameworks.sh"
When I add "import AWSCore" in a source file, I get "No such modue AWSCore". Could it be that the path is wrong ?
Is it possible to get the value of BUILT_PRODUCTS_DIR ?, of FRAMEWORKS_FOLDE_PATH ?

Copy build to a different directory after finishing building

When I build my project with Xcode 8, it saves the final build in ~/Library/Developer/Xcode/DerivedData/MyProject-[add-lots-of-random-chars-here]/Build/Products/Release-iphoneos. Is there any way to make Xcode copy the app bundle to a user-specified path after building it? e.g. how can I make Xcode copy the built app bundle to /MyBuilds after building it?
I know that I can change the path for storing derived data in my project's settings in Xcode but doing so will of course make Xcode store all data (including intermediate stuff like object code etc) in this location which I don't want. I really only want Xcode to copy the final, ready-for-distribution app bundle to a user-specified location without any intermediate files used in the build process.
How can I do that?
The solution using a script in "Build Phases" does not work properly since Xcode is not finished building the app when running the script. Here is a solution with a script that runs after all build tasks are finished:
Go to "Edit Scheme"
Click on the triangle next to "Build"
Select "Post-action"
Press the + button and select "New Run Script Option"
Select your app name in "Provide build settings from"
Add the following shell script:
Script:
PRODUCT="${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app"
cp -R "${PRODUCT}" ~/Desktop
Add a shell script to your build phases to copy the product:
Script:
PRODUCT="${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app"
cp -R "${PRODUCT}" ~/Desktop
Certainly replace ~/Desktop with a target directory of your choice.

Changes in the MobileFirst project is not reflect in the application

When I made any changes (JS, HTML, or even app version) in the MobileFirst project, then rebuild and redeploy the app to device or simulator/emulator, nothing appears to change in the application. If I uninstall the app from the device and redeploy the app, then the changes are visible in the app. This is not related to direct update. This only happens with iOS environment.
How to resolve this?
Apparently, the Run Script is missing in my Xcode project so the buildtime.sh file was never executed. As a result, buildtime property was not updated. With the same buildtime, nothing was updated in the app.
Solution:
In Xcode, select your project and open the Build Phase tab. Click on the + icon on the top left to Add a New Build Phase. Select the new Run Script Phase and copy/paste the following to the new script:
script_file="buildtime.sh"
echo "Running a custom build phase script: $script_file"
unsecure_project_path=${PROJECT_DIR}
secure_project_path="${unsecure_project_path// /\ }"
eval ${secure_project_path}/${script_file}
scriptExitStatus=$?
echo "DONE with script: ${script_file} (exitStatus=${scriptExitStatus})\n\n"
exit "${scriptExitStatus}"
The Run Script should look like this:

Getting a list of locales of a xcode project from a run script pahse

Is there a way of loading the list of locales added to a xcode project in a run script phase ? I need to create the proj folders automatedly.

applying mvn commands via intelliJ IDEA

How to run following mvn commands via intelliJ IDEA? I can run these commands from terminal but how to do the same in the IDE for the project opened in it?
--mvn clean dbmaintain:updateDatabase
--mvn clean package
Go to "Edit Configuration" and create a new "Maven Run/Debug Configuration". There you can define the command line and the working directory.
An other way of doing the same is : open de maven projects view (on right edge of the window) expend your module, expand the "Life-cycle", select the phase you need to run. Then a simple rigth click shows a popup allowing you to "run" the phase or create a run configuration preconfigured with the working dir and the phase. (you can always edit it)

Resources