After much trial and error, I have failed to come up with a solution for this problem. Hoping someone might know a way.
I want to pass my development machine hostname to the app, without hardcoding it.
My idea was to make a build phase script that captures the hostname and export it
export DEV_MACHINE_HOST=hostname
and then set it as a launch argument on the RUN scheme
-dev-machine $(DEV_MACHINE_HOST)
But to no avail.
Anyone know if this can be done?
Context:
I'm making a dev tool with a local server. I want to send http requests to this tool as long as I'm on the same network, so that it will work on device as well as the simulator.
See Providing custom variables for Info.plist for an example of this. Create a Script Phase that uses PlistBuddy with something like:
/usr/libexec/PlistBuddy \
-c "Add :DevMachineHost string `hostname`" \
"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_FOLDER_PATH}/Info.plist"
And then fetch it with Bundle.main.object(forInfoDictionaryKey:).
Alternately, you can write a script that generates a Swift file that defines a global for you. (But it's more typical to do this with Info.plist.)
A scheme can't do this, because that's just how Xcode launches the app in the debugger. It's not something that's stored with the app or that influences how the app is normally launched.
Related
I can't get local debug of IoT Edge modules working on VS Code, but part of the problem could be that I don't understand what I'm doing in the steps.
I'm following the Microsoft guide here. Can anyone explain to me when I run the command "Azure IoT Edge: Start IoT Edge Hub Simulator for Single Module" in VS Code, why do I need to pass an "input name"? Why doesn the simulator need to know this. I've got multiple input commands on my edge module and the fact I need to pass it is making me question what the simulator actually does. I want to be able to debug multiple inputs.
Also on the same documentation, I can't see how it defines which module I want to run in the simulator. Am I missing something or is the process confusing?
When you Start the IoT Edge Hub Simulator for a Single Module, you spawn two Docker containers. One is the edgeHub and the other is a testing utility. The testing utility acts as a server that you can send HTTP requests to, the requests specify the input name and the data. You can use this to send messages to various inputs on your module. Just looking at that, I understand why it is confusing to supply the input name to the simulator. But when you inspect the edgeHub container, you'll see the following environment values being passed:
"routes__output=FROM /messages/modules/target/outputs/* INTO BrokeredEndpoint(\"/modules/input/inputs/print\")",
"routes__r1=FROM /messages/modules/input/outputs/input2 INTO BrokeredEndpoint(\"/modules/target/inputs/input2\")",
"routes__r2=FROM /messages/modules/input/outputs/foo INTO BrokeredEndpoint(\"/modules/target/inputs/foo\")",
"routes__r3=FROM /messages/modules/input/outputs/input1 INTO BrokeredEndpoint(\"/modules/target/inputs/input1\")"
Just like on a real device, you need routes to talk to your module. The edgeHub container registers these routes with the values you supplied during the starting of the simulator. That input can be a comma-separated list. So if you are using more inputs, feel free to supply them when you start the simulator. Under the covers, that command runs:
iotedgehubdev start -i "input1,input2,foo"
Note: when I was testing this with the latest VS Code Extension, the first time I ran it, the textbox contained: "input1,input2".
I am using Google's Datastore (which is Firestore's support for the GCP) and the emulator to handle storage locally. Everything works fine as far as storing data. But there does not appear to be any way of actually viewing the data in the browser. I have a feeling that this is not yet implemented because the emulator is still in beta. Has anyone been able to view data in their browser? It should be stressed that this is the emulator provided by the Google Cloud Platform SDK and not the one that Firebase uses for its products. The emulator is started with:
gcloud beta emulators datastore start
As of January 2022
Debugging
Setting up Firebase Datastore Emulator (FDE)
The Firebase Datastore Emulator (FDE) emulates the Google Datastore in App Engine. This is meant to run on Java 8 platforms. When correctly setup, any Datastore operations are done locally and stored to a file called local_db.bin.
The documentation for using the Firebase Datastore Emulator can be found at:
https://cloud.google.com/datastore/docs/tools/datastore-emulator
It should be noted that this documentaton contains errors and is missing some important settings. To use Firebase Datastore Emulator, install the emulator by running the following command from a terminal:
gcloud components install cloud-datastore-emulator
Start the emulator in a terminal:
gcloud beta emulators datastore start --data-dir=fbdatastore --host-port=localhost:8100
The official documentation does not indicate to use the --host-port flag. If you leave this flag out, a random port will be selected. But experience has shown that letting the port be randomly selected can result in exceptions generated by the client library used to access the local datastore - even when the port is correctly set in the environment variables.
The --data-dir flag indicates the directory where the local database file is stored. Here, it is specified as fbdatastore but you can use any folder located anywhere. You should make sure that the folder already exists before you start the emulator. In the example shown here, no path is included. This means that when you start the emulator, the directory specified by --data-dir should be in the same folder where you are launching the emulator.
The emulator will only create the local_db.bin file when you initially write data to it. If you don't write any data, it will not be created. Even it isn't created, the client APIs will still work correctly when reading from it, typically returning null values for any entities that you attempt to access. No exception will be thrown if the database file does not exist.
If the --data-dir is set to fbdatastore as used here, the local_db.bin file will be created under:
fbdatastore/WEB-INF/appengine-generated/local_db.bin
After the emulator has started, you can verify that it is running but opening a browser window and navigating to the url:
http://localhost:8100
This will only display the text "ok".
Before you can start debugging the app, several environment variables need to be set. You need to open a new terminal window and execute the following commands to set several variables:
export DATASTORE_DATASET=[project-id]
export DATASTORE_EMULATOR_HOST=localhost:8100
export DATASTORE_EMULATOR_HOST_PATH=localhost:8100/datastore
export DATASTORE_HOST=http://localhost:8100
export DATASTORE_PROJECT_ID=[project-id]
export DATASTORE_USE_PROJECT_ID_AS_APP_ID=true
The client libraries for the Datastore expect the app id to be used. But it was found that using only the app id didn't work. The environment variable DATASTORE_USE_PROJECT_ID_AS_APP_ID needs to be set as well. This is not specified in the documentation.
It should be noted that the official docs show the following:
export DATASTORE_DATASET=my-project-id
export DATASTORE_EMULATOR_HOST=::1:8432
export DATASTORE_EMULATOR_HOST_PATH=::1:8432/datastore
export DATASTORE_HOST=http://::1:8432
export DATASTORE_PROJECT_ID=my-project-id
For MacOS, this is wrong. The variables with values set to ::1 is wrong. Using this will cause exceptions and probably prevent the emulator from even loading. The ::1 needs to be replaced with localhost, as shown above.
You can just copy the 6 lines shown above and paste them into a terminal and hit Enter. But it is easier to just place these into a bash file and execute it. These need to be set before the local development server is started. The following bash file will set the environment variables and then start the development server:
export DATASTORE_DATASET=[project-id]
export DATASTORE_EMULATOR_HOST=localhost:8100
export DATASTORE_EMULATOR_HOST_PATH=localhost:8100/datastore
export DATASTORE_HOST=http://localhost:8100
export DATASTORE_PROJECT_ID=[project-id]
export DATASTORE_USE_PROJECT_ID_AS_APP_ID=true
java_dev_appserver.sh --address=0.0.0.0 --port=8080 --disable_update_check --jvm_flag=-Xdebug --jvm_flag=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 build/exploded-website
Replace [project-id] with the project id shown in your Googel Cloud Platform console (don't include the square brackets).
The address parameter for java_dev_appserver.sh is set here to 8000. You will need to set this in your IDE. Also, the port for java_dev_appserver.sh is set to 8080. You can set this to whatever works on your system and doesn't conflict with any existing ports used elsewhere. The last parameter for java_dev_appserver.sh is the location of your war files, which is the compiled app. Here, it is located at build/web-site. Replace this with the location of your own build files.
To view the datastore locally in your browser, navigate to:
http://localhost:8080/_ah/admin/datastore
Details on the command parameters used to start the emulator can be found at:
https://cloud.google.com/sdk/gcloud/reference/beta/emulators/datastore/start
As far as I can understand what you want to do is to add data in the Datastore emulator running on your console and be able to see this data in the UI right?
Vieweing the data in the UI actually incurs in expenses for you because Datastore have to query the data to be able to display it on the UI.
I can still recommend you to create a Feature Request if you want to be able to see the entries form the Datastore emulator for free in the UI
I am trying to setup a proxy on my Ipad so that I can capture it's traffic using fiddler2 but for some reason it's not helping.
I am following this blog post,
http://blog.brianbeach.com/2013/01/using-fiddler-with-iphoneipad.html
Now when I try to create a profile in iPhone Configuration Utility and try to export certificate as shown in picture below, it asks me for password which I never setup neither know of.
when i open an app on my iPad which uses webservices, gives me this error,
Can't Verify Server Identity
myAPP Can't verify the identity of "me.myWebsite.com". would
you like to continue anyway ?
app works when i remove proxy.
You don't need to use the Configuration Utility.
You should simply follow these steps: http://fiddler2.com/blog/blog/2012/12/21/using-fiddler-with-apple-ios-devices
I am using self signed certificates for development and testing purposes. I have investigated various approaches to get android emulator to accept self signed certificates. Thus far I have found variations of the following approaches:
Providing your own security classes that will accept any certificate.
Create a keystore for your app that contains the self signed public key.
Setting property socket.relaxsslcheck to yes.
The first 2 options are very involved and introduces into your code a dependency on your environment, e.g. dev, test or prod.
Option 3 I like because the environment configuration drives behaviour, not unlike a web container that will provide the configured datasource to apps running in the container. A development environment will point to a development datasource etc. Unfortunately I am struggling to get it to work. I have tried the following:
Using adb to set the property
adb shell setprop socket.relaxsslcheck yes
Using System.setProperty
System.setProperty("socket.relaxsslcheck","yes")
Tried to make change /system/build.prop and default.prop
The first option just gets ignored. From what I have read it seems setting the property will take effect after restarted. But the property seems to be volatile, it does not survive an emulator restart.
The System.setProperty(...) approach seems to be too late as the Factory has already been created. Because of above concern (dev environment specific code in code) I would prefer not to go this route, unless there is no alternative.
The last option is supposed to survive emulator restart, but I am unable to write to those files even after running adb root.
I am new to Android dev and would appreciated some guidance on what the best approach is and how to get it to work.
Well, you have to exactly specify 'yes' with that option, i.e.:
-prop socket.relaxsslcheck=yes
The source code just compares the properties value against 'yes' (and does not bother to also test against equivalent values like 'true' or '1' ...)
Using the ADT bundle I set that option via
Run -> Debug Configurations... -> Android Application -> ProjectName -> Target
-> Additional Emulator Command Line Options
After a restart of the emulator SSLSocketCertificateFactory works at advertised, i.e. it accepts all certificates. One can verify that via looking at the logs:
12-08 18:10:52.382: W/SSLCertificateSocketFactory(763):
*** BYPASSING SSL SECURITY CHECKS (socket.relaxsslcheck=yes) ***
I tested it with a self-created certificate - without that property set connecting fails with a certificate verification error, with that property set (or using SSLCertificateSocketFactory.getInsecure()) the TLS socket connects just fine.
Btw, SSLSocketCertificateFactory seems to be tricky to use at times - for example I am struggling to get an actual instance from that very Factory - people posting workarounds that basically say: ignore that factory. Googling around some people even recommend against using that factory at all - but without giving much reasons.
First of all, I'm not sure if this is generic to services in general, but the problem I'm having is pretty specific, it has got to do with the SageTV service component.
Since there isn't much help over at the SageTV forums regarding this specific subject, I thought maybe this was a generic issue with services and therefore worth asking here at Stackoverflow.
Here goes:
I'm running the SageTV windows service with a plugin activated which is supposed to execute external programs. When running under the Local System Account (with the "Interact with the desktop option" enabled), this works fine. For testing purposes I'm using notepad.exe as the program to execute.
Then I created a new user (let's call it mediabrowser) and changed the SageTV service so it would run as that user. When I do that, the SageTV plugin no longer executes notepad. It just does nothing, I don't get any errors or anything, it's just that nothing happens when notepad should be getting executed.
The mediabrowser user has administrative priviliges. The option to interact with the desktop is only available for the Local System Account, and I believe that normal users are always allowed to interact with the desktop anyways.
Is this a general issue with services? If so, what permissions might my mediabrowser user need in order for this to work? I'm pretty sure this is because of permission differences between my mediabrowser user and the Local System Account.
Thanks in advance ...
Uhhh OK. Now I feel like an idiot. I just launched the tast manager on the machine and I can see that there are tons of notepad.exe processes under the mediabrowser user so I guess that notepad IS being executed correctly. It's just not being shown on the desktop.
So I guess this just works :-)