According to the Apple docs I can export a script in the Script pane of the Automation tool in Instruments by right clicking and choosing Export.
https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html
But I don't have that contextual menu item. e.g.
Any idea why not and how to fix?
You can export that script to file ONLY once - after first export script is representing by file and that option disappear from context menu. (I believe in 'scripts' section on the right of Instruments window You have 'script_name.JS' ATM)
Save option of trace also saves modifications to that file.
FIX:
Copy entire script, in 'scripts' section click Add->Create... , paste script and then Export to another file :)
Related
I'm doing an iOS framework and now i need to implement something like this: At the stage of the project assembly, I want to make a request to the server, get the JSON in response and write it to the project file. Thus, the user who downloaded the application, and opened it without the Internet will already have these files. In Android, it is possible to implement this function using the Gradle plugin. What the right way to implement this in iOS? Thanks in advance for the answer.
You can use a Run Script phase in the Build Phases section of your project.
Step 1
Add the initial version of the file to your project. Make sure it's added to the target.
Step 2
Select your project and go the build phases tab. You should be able to see the file being copied to the bundle in the Copy Bundle Resources section.
Step 3
Add a new Run Script to your build. Click the plus button at the top-left of the editor.
Give the phase a sensible name by double clicking the label.
Reorder the phase as early as possible by dragging it up the list.
Step 4
Using your favourite scripting language/command line thing download the new file and replace the existing file.
e.g (untested demo bash sample, probably wont work)
MYFILE=${TEMP_DIR}/something.json
curl -o $MYFILE https://myserver.com/stuff/something-latest.json
cp -f $MYFILE ${SRCROOT}/Sploopy/Resources/something.json
You can examine the environment with the build inspector and see what values you can use to get the file in place.
Ones that will come in handy are:
TEMP_DIR is a good place to put files temporarily.
SRCROOT so you know where to copy the downloaded file to.
CONFIGURATION so you can choose when to do this action. Personally I would only do it on Release but YMMV. It will be a blocking action.
Step 5
Profit
Before I run my App, I would like to run a external shell to update my Info.plist.
With Build Phases->Run Script, I can run my external shell. And here is my question, I saw Info.plist update the data when the program was building, but when I ran into my app, I found that the data read from plist was the former old data.
I also found another funny thing.
One side, if I just built the project(command + B), I saw plist update and then I ran the program, the data showed in UI was new data.
Another side,if I used the Run Button in Xcode, I saw the Info.plist update when Xcode show build successed, however, the data showed in UI was old data.
So, what happens? Could you help me to solve it to let my data be always the newest.
=============
Now, I have moved my 'Run Script' to run external shell before 'Compile Source(swift files)', and it works. However, I still can't understand, since it runs during build time, why the running program can't get the right data from Info.plist if I runs my 'Run Script' after 'Compile Source(swift files)'? does the program load in the data during its run time or compile time?
Building an app involves many different phases. Compiling sources is just one of them, there's also linking, copying resources, signing, etc. Some of them are explicitly listed in the "Build Phases" tab, others are not.
So it's really a matter of running the script at the appropriate time in the build process so that the Info.plist is modified before it is actually used by the build process.
If you click on the "Report Navigator" icon (last icon in the list at the top of the left-side panel), then on the last build, you'll see the report of that build which lists all the steps that were performed during the build process, including running scripts and processing the Info.plist.
Okay, here's a little bit of context:
I have just added a Mac OS Core Data Command Line Tool target to my iOS project. It's purpose is to simply use my iOS app's Core Data model and a JSON file (which I am adding default data to as I go) to create an SQLite database which I am going to use as the default database for my iOS app. The idea is to have this command line tool ready in my project so that when I add some default data to my JSON file, I just:
Run the command line tool
Go to products in the file navigator on the left
Control click the command line tool product and hit show in finder
Drag the .sqlite database that has been displayed along with all the other bundled files for my command line tool and drop it into my iOS app's resources
But, I can't do this because the command line tool product is showing red in the navigator window because Xcode is looking for it at this path:
/Users/kylejm/Library/Developer/Xcode/DerivedData/MyiOSApp-ggjlxrqiijmbqkgkucdargamkwld/Build/Products/Debug-iphoneos/
Where as the it is actually in:
/Users/kylejm/Library/Developer/Xcode/DerivedData/MyiOSApp-ggjlxrqiijmbqkgkucdargamkwld/Build/Products/Debug/
I have been inspecting the Build Locations in the Build Settings but all the resolved paths are correct for both my iOS app and the command line tool respectively.
What do I need to do to make Xcode look in the right place?
Thanks so much for any help in advance.
I just clarified my scenario/problem for the answer by bauerMusic like so:
Thanks for your answer but I don't think you quite understand my scenario or problem. The Command Line Tool (CLT) target is a part of my project, and therefore has a executable product in the product folder (shown in red until first build and run). When I run this command line tool, it's product in the products folder remains red because Xcode is looking for the product in the wrong place for it.
I've put it in the description so you all understand my question as clearly as possible.
You usually never add files to a project outside of Xcode, (meaning, simply place it in the folder) unless you want to have these sort of issues.
Try to remove it, restart the project (build and see that it has no broken links warnings), and drag the file to the navigator's folder in your open Xcode project.
Edit: Just to be clear, add through Xcode, not the Finder. Xcode should prompt you to either copy resource or not (check box).
I was going to suggest you Clean the project, but I then noticed how you actually added the file.
Xcode seems to allow specifying a custom compiler for source files via the Build Rules tab (copy the system C rule to the target, select "Custom Script". Just for testing the concept, I wrote echo $* as the script.
However it doesn't really run that script (no output is sent to the console); the end result is that no file gets built, so later I get a link error.
Am I using it wrong? What's the correct way of using a custom compiler in Xcode 4.x?
I tried your example. The script would not run unless I added an output file to the Output Files table for the build rule. Then the script ran, but the results appear in the build transcript instead of the console. Open the log navigator by choosing View > Navigators > Show Log Navigator. Select your build from the log navigator to open the build results window. There should be a run custom shell script step in the build results window. On the right side of the step is a small button with several horizontal lines. Click that button to show the build transcript.
If you want to use a custom compiler on some of the files in your project, you may find it easier to add a Run Script build phase to your target and add the files you want to compile to the Run Script build phase.
I'm trying to learn Ada from Wikibooks. I've downloaded and installed GNAT GPL 2011, created a project in the GPS IDE which comes with it and written an example hello world programme.
The problem I have is that the GPS IDE doesn't bind and link my programme. From here I've found out that gnatbind and gnatlink must be run after gcc. If I do it manually from the command line, the build succeeds and an executable file is correctly generated. But if I click "Build All" in GPS all I get is
gnatmake -d -PD:\path\to\project.gpr
gcc -c -I- -gnatA D:\path\to\hello.adb
[2011-06-23 13:05:17] process terminated successfully (elapsed time: 00.35s)
and only *.o and *.ali files are generated.
How do I make GPS bind and link my app?
In the Project menu, select "Edit Project Properties". Click the "Main Files" tab. Click the "Add" button.
You'll see a list of the files in your project.
Click the checkbox of the file that contains your main procedure. Just highlighting the line with the filename isn't enough, you have to check the box.
"Okay" your way out of the dialogs.
Now you can build by pressing F4, clicking Build/Project/Build All, or clicking on whichever of those icons is the "Build All" one.
You have to tell GPS (or rather gnatmake), which file should be considered the main routine.
This is done in the gpr-file with for Main use ("foo.adb"); or via the project properties in the tab "Main files".
Click F4.
That should be the shortcut to "Build Main Number 1". Check your shortcuts in Edit/Key shortcuts/Build
Good luck!