I'm looking for a way to dynamically add in information about the application during the build process of an iOS application.
During testing, it would be great to know when the application I have installed on my device was built and possibly who built it would be a good to know as well.
I'm envisioning a section in settings.app that would give basic build information for debugging purposes. I don't want to have to manually update a build information file before each build - the data should be generated dynamically.
You can also use standard macro __DATE__ which will result string like "Jun 25 1980" of course with proper current date of build.
You can write a shell script build phase in Xcode that runs at the end of your build process. In this phase you can use the defaults command to write data to an arbitrary file. I've used this technique to write to the Info.plist file, but you can write to any file you want[1].
Here's a sample script to write the current git version to Info.plist:
infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
gitversion="$(cd "$SRCROOT" && git describe --always --dirty 2>/dev/null)"
if [[ -n "$gitversion" ]]; then
defaults write "${infoplist%.plist}" GitVersion "$gitversion"
fi
You should be able to adapt this to point to the file you want (e.g. your Settings bundle) and write the info you want.
[1] Be careful if you write to Info.plist, Xcode has bugs that can prevent it from realizing Info.plist changed during the build, which can break the provisioning when doing a device build.
Related
I have the .pyx file that has key string in its code.
Key string must be changed for their own version like real, alpha, beta and so on.
So, I want to change the "Key string" belongs to version when building process.
How can I do this within below process? (Using Jenkins for building the code.)
Make .so file with cython build
Make binary file with pyinstaller
I guess, use the "Active Choices parameter" in Jenkins is required to do this, if it is right then guide me how.
Thanks.
I solve this like below.
Create key storage directory.
Store the various key strings to it.
Use build scenario, and copy the specific key file.
Use --add-file option with pyinstaller, and modify a code that use the file.
Is there any programmatic way to control the xcode > simulate location command? I have external location test scripts I'd like to run, and ideally the test suite could cause xcode to change the location of the connected phone at will.
Is this possible, and if so how?
Not sure if it's exactly what you're after, but you can have different unit test bundles use different locations (or GPX files) by setting it up in the scheme.
You could then have unit tests in each bundle which test what you need regarding that specific location.
xctool can also just run the unit tests in a specific target using the -only option:
path/to/xctool.sh \
-workspace YourWorkspace.xcworkspace \
-scheme YourScheme \
test -only SomeTestTarget
There is a GitHub project called Pokemon-Go-Controller that does exactly what you want.
Overview of the solution:
Create a gpx file
Create a blank project referencing (not copying) that gpx file and run it on your device
Run auto clicker which will constantly click update location in Xcode
Update gpx file using some script and the device location will be automatically updated
Instead of the auto clicker you can use this Apple Script:
#Will continue update the location to the location name below from Xcode:
property locationName : "pokemonLocation" #name of your gpx filex
###########################
tell application "System Events"
tell process "Xcode"
repeat while true
click menu item locationName of menu 1 of menu item "Simulate Location" of menu 1 of menu bar item "Debug" of menu bar 1
delay 0.2
end repeat
end tell
end tell
Yes, it is possible.
1. Set up the GPX files as described in #InsertWittyName 's answer, or as described in this blog post.
2. Use Instruments to run your app in the Simulator using the different GPX files.
I would write out the entire process, but someone more eloquent than myself already has.
As an avid S/O user, I would be bereft to leave what is basically a single-link answer. So here is some extra, bonus information.
You should definitely look into security testing your location aware features. I will be at Black Hat this year, so if you're there, let's talk about it!
If you don't like the previously linked/sort of explained answer, you could use XCTest with code to simulate different locations (like this).
It looks like there are also Apple Script solutions, like this one.
I hope I have at the very least provided enough information to qualify as more than just a lazy link-only answer. Enjoy, and good luck!
idevicelocation is a command line tool to mock geolocation in ios devices.
Usage:
$ idevicelocation [OPTIONS] LATITUDE LONGITUDE
Set the location passing two arguments, latitude and longitude:
$ idevicelocation 48.856614 2.3522219000000177
Passing negative values :
$ idevicelocation 77.432332 -- -7.008373564
Stopping Location Simulation:
$ idevicelocation --stop
Options:
-d enable connection debug messages.<br/>
-u specify device UDID.<br/>
-h help.<br/>
-s stop location simulation on device.
It uses libimobiledevice library to communicate with the process com.apple.dt.simulatelocation which is also used by Xcode internally for the same purpose.
Build instructions are there in the README file. Make sure to mount the correct developer image before going random places. Thanks to Angulo for writing this awesome utility.
This tool is not currently being shipped with libimobiledevice package although there's a Pull Request pending since long.
This is just a case of lack of documentation thus far, but when creating a production release build of an iOS React Native app, after setting the Build/Archive schemes to be Release instead of debug, do I need to manually create a main.bundle and uncomment the second jsCodeLocation line in AppDelegate.m, or does something handle that for me automatically?
I've been doing both steps manually thus far, but I'm sure there will be a day that I forget to do so, and I wanted to know what the compile and build scripts are doing for me and what I need to do myself.
(Using react-native#0.21 if applicable.)
on our App we have made that our Build System generate App.plist (with some env contextual client ids/tokens/api urls of service) and we have a property boolean that indicates if the app needs to use bundle or not.
Based on this we switch the mode to use (use bundle VS use live reload server).
I submitted some months ago a PR to bring this in the skeleton, this never goes through though, but feel free to implement your own: https://github.com/facebook/react-native/pull/2101
Also one interesting thing we use to generate our App.plist based on env is a script that basically do this: https://twitter.com/greweb/status/687575516862349312
Hope this helps
I'm a beginner in iOS development, and trying to build a practice app using Facebook Graph API.
When I integrate with the Facebook API, it requires me to store App ID into Info.plist file of
the project.(https://developers.facebook.com/docs/ios/getting-started#configure)
Although Facebook's app id is not super confidential, I want to open source my repository on GitHub, and having to upload App ID along with source code bothered me.
I could add such file to .gitignore, or make sure I delete confidential information whenever I upload it to GitHub, but they are apparently error prone, and not elegant at all.
Coming form the Java background, I used to store database passwords and other secretive information as system Environment Variables, or stored them in the build tool's setting file such as Maven's settings.xml, so that they are maintained separate from the source code.
Are there known best practices to decouple confidential information from repository in iOS development?
Thank you.
What about this scenario:
Create a file MyId.txt on your Mac (home directory or a directory that can be shared, for example ~/FacebookConfidential/) to store FacebookAppId.
Add Run Script in your Xcode project Build Phases, read MyId.txt file content and set it to info plist using plistbuddy. The purpose is to update information property list so that Facebook SDK can get the Id at run time.
INFO_PLIST="info.plist"
FACEBOOK_ID=$(<~/FacebookConfidential/MyId.txt)
if [ -n ${FACEBOOK_ID} ]; then
/usr/libexec/PlistBuddy -c "Set :FacebookAppID ${FACEBOOK_ID}" ${INFO_PLIST}
fi
Use git pre-commit hook to clean FacebookAppId in info plist or change it a stub value, which make sure FacebookAppId is not committed to repository. You may also want to invoke plistbuddy in the hook.
A collaborator need to do step 1 and create ~/FacebookConfidential/MyId.txt on his system.
This way, the FacebookAppId is saved on your system, the only thing to share is the path. Hope this shed light.
I am making an iOS app and I wanted to know what the build process is exactly. I don't mean want something like, it compiles, then it links and then its done. I want to know exactly what each step does like android has build steps viz. resource manager, pre-compiler, java builder, package builder, How are these steps taken care of in IOS. Secondly, what is the importance of .app file which is created with xcodebuild command to eventually create .ipa file.
Here are some links that might help:
Joshua Davies walks through building a simple Hello World app outside of Xcode:
http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art024
A .ipa file is just a zip archive with a predefined structure. The iPhone wiki describes it well:
http://theiphonewiki.com/wiki/IPA_File_Format