I get bunch of serial numbers when I explorer following.
cd ~/Library/Developer/CoreSimulator/Devices/
I exactly know which simulator (for example iPhone 5 with iOS8.1) I've used to run my application. But sometimes, I find it difficult to explore simulators to check documents directory & other stuff. Everything is with serial number.
Is there a trick to explore simulators with ease like follows?
iPhone 5 with iOS 8.1
iPhone 6 Plus with iOS 8.1 etc.
You can just run xcrun simctl list to see what each simulator device's UDID is or you can just pull it out of device.plist directly.
Here is an easy way to get to the simulator's tmp, documents or other folders of the app running in Simulator using Swift. Put this in the AppDelegate.swift didFinishLaunchWithOptions, and it will provide an output of the file path in the console window. Then you can copy that and paste into the Finder > Go > Go To Folder...
if UIDevice.currentDevice().model == "iPhone Simulator" || UIDevice.currentDevice().model == "iPad Simulator" {
var locale:String = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).description
locale = (locale as NSString).substringFromIndex(8)
locale = (locale as NSString).substringWithRange(NSRange(location: 0, length:(locale as NSString).length - 1))
println("\n\n\(locale)\n\n")
}
Here's a sample output from the console window of Xcode:
/Users/brope001/Library/Developer/CoreSimulator/Devices/59E93965-6DEA-4A06-95EC-01FA155226D7/data/Containers/Data/Application/59115DEA-25C7-4400-8548-8A6ADD02E339/Documents/
Here is the shell script for above request.
cd ~/Desktop
mkdir Simulators_Shortcuts
destination="`pwd`/Simulators_Shortcuts"
cd $destination
cd ~/Library/Developer/CoreSimulator/Devices/
for d in *; do
if [ -d $d ] ; then
cd $d;
deviceName=`/usr/libexec/PlistBuddy -c "print :deviceType" device.plist | sed -e 's/com.apple.CoreSimulator.SimDeviceType.//g'`
osName=`/usr/libexec/PlistBuddy -c "print :runtime" device.plist | sed -e 's/com.apple.CoreSimulator.SimRuntime.//g'`
linkName="$deviceName-$osName"
currentPath=`pwd`
ln -s $currentPath "$destination/$linkName"
cd ..
fi
done
cd $destination
Here is the snap-shot of what is the output as folders.
Related
I recently purchased a new MacBook and I am trying to re-configure my system.
The app is inside the Applications folder as 'Sublime Text.app'
I have edited the sublime.plugin.zsh file via other advice I found online to 'Sublime Text 3.app' as well as 'Sublime Text.app' with no luck on either:
elif [[ $('uname') == 'Darwin' ]]; then
local _sublime_darwin_paths > /dev/null 2>&1
_sublime_darwin_paths=(
"/usr/local/bin/subl"
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
)
for _sublime_path in $_sublime_darwin_paths; do
if [[ -a $_sublime_path ]]; then
alias subl="'$_sublime_path'"
alias st=subl
break
fi
done
fi
alias stt='st .'
I still get
zsh: command not found: st
I am simply at a loss on where to go next
I had the same problem with zsh and this did the job:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Then you launch a open a file my_file.txt with Sublime:
subl ./my_file.txt
Don't specify any file if you just want to open Sublime. I hope this helps ;)
First, try to first launch the sublime binary manually (interactively) via zsh.
To do that, you'll have to discover where this binary is. There are two practical options here, choose what you are most comfortable with:
Check manually those listed binaries, see which of them exist.
Slightly modify your script to echo something inside your if:
if [[ -a $_sublime_path ]]; then
echo "Sublime found: $_sublime_path"
alias subl="'$_sublime_path'"
alias st=subl
break
fi
After finding the correct one, create the st alias in your .zshrc file:
alias st="/correct/path/to/subl"
If you don't find anything in the first step, then your original script is really not supposed to work.
Just moved to App in mac
Check your current path
echo $PATH
Add a sym link from Sublime App to one of your path. Choose /usr/local/bin for example
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
Then back to terminal and run sublime. You should be open the sublime through terminal
To setup alias for mac users;
open ~/.zshrc using the below command
vi ~/.zshrc
Add the following alias
alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
run subl . command should work properly.
Official documentation: https://www.sublimetext.com/docs/command_line.html#mac
ZSH
If using Zsh, the default starting with macOS 10.15, the following command will add the bin folder to the PATH environment variable:
echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.zprofile
I am building an application that exists of two different "versions". Each version has a different layout (different strings, images, colors and fonts). I accomplished this using macro's: there's one header file (let's call it Layout.h for now) that is included in all classes. Layout.h contains a #define statement that determines what version should be built. If this statement, let's call it DARK_STYLE, is true, DarkStyle.h is imported. If the statement is false, BrightStyle.h is included. Both DarkStyle.h and BrightStyle.h contain the same defines, but with different values. For example:
<DarkStyle.h>
#define TEXT_COLOR [UIColor blackColor]
<BrightStyle.h>
#define TEXT_COLOR [UIColor whiteColor]
So far so good. Now I have come to the point where the application has to be shipped. Unfortunately, each version has a different app icon and different splash screen. What I'm trying to do now is to get the app's Icon.png and Default.png files generated automatically based on the DARK_STYLE macro from Layout.h using an Xcode build script.
The build script I have at this point is able to determine whether DARK_STYLE is set to 1 or 0. The next step is the one I have trouble with: copy the Icon.png and Default.png assets belonging to the dark style to the application's bundle (the build script is executed after the "Copy Bundle Resources" phase).
The following does not work:
if find $SRCROOT -name "Layout.h" -exec echo {} \; -exec grep "#define DARK_STYLE" {} \; -exec grep 1 {} \;
then
# Copy dark style resources and rename them
find $SRCROOT -name "dark_icon.png" -exec cp "{}" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/" \;
mv "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/dark_icon.png" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Icon.png"
else
find $SRCROOT -name "bright_icon.png" -exec cp "{}" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/" \;
mv "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/bright_icon.png" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Icon.png"
fi
What am I missing here?
Create a separate build target in your Xcode project for each version of the app. Make sure each target includes the correct version of each asset.
Is it possible to remove a file using a build phase in xcode 4 based on if it is release or dev?
If so has anyone got an example?
I have tried :
if [ "${CONFIGURATION}" = "Debug" ]; then
find "$TARGET_BUILD_DIR" -name '*-live.*' -print0 | xargs -0 rm
fi
This prints CopyStringsFile
"build/Debug-iphonesimulator/Blue Sky.app/PortalText-live.strings" CDL/PortalText-live.strings
cd "/Users/internet/Desktop/iPhone Template/iPhonePortalTemplate/CDL.Labs"
setenv PATH "/Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-copyStrings --validate --inputencoding utf-8 --outputencoding binary --outdir "/Users/internet/Desktop/iPhone Template/iPhonePortalTemplate/CDL.Labs/build/Debug-iphonesimulator/Blue Sky.app" -- CDL/PortalText-live.strings
But does actually remove the file from the bundle.
The only way I've ever had different files, is having a separate Target, and only include certain files in certain targets.
EDIT WITH AN EXAMPLE
Ok, I've done exactly the same in another project. We had a DefaultProperties.plist file, which was included in the target.
We then had 3 copies of this, NOT included in the target, ProdProperties.plist, TestProperties.plist, UatProperties.plist.
We built for environments on the command line, using xcodebuild, as it was built using an automated build server (Bamboo).
Prior to executing xcodebuild, we would run this:
cp -vf "./Properties/Environments/${environment}Properties.plist" ./Properties/shared/DefaultProperties.plist
touch Properties/shared/DefaultProperties.plist
with $(environment) being passed into the script.
You could do something like this with the RunScript phase in Xcode.
I am looking for a way to extract my iPhone (OS v3.0) UUID without using iTunes. I tried "UUID Revealer" from Cydia Store but that is not working on my system. I could SSH with WinSCP and I have a Terminal Program Installed. Any chances using one of those tools (or another one) to bring to light my UUID? Thanks
Connect your iPhone to the Mac(mine is OS10.8).
Launch System Information under Utilies
the UUID of your iPhone is list under USB/iPhone/Serial Number
On an apt-compatible Linux use:
sudo apt-get install libimobiledevice-utils
Now you can do
idevice_id -l
to get the device UUID while it's connected by USB.
This is super easy on Windows.
You can also go to Control Panel > Devices and printers in win 7.
Plug in the phone
Device Manager > Iphone
Right - click
Properties > Hardware Tab
Properties > Details Tab
Property > Device Instance Path
UUID is the last device path listed.
USB\VID_05AC&PID_1297\UUID String
Enjoy skipping itunes installation.
There are probably 20 "UUID Display" apps in the app store. I think the best thing to do is to try a few and see what works for you. Like almost everything else in the App Store, the apps to show UUID is saturated.
HI just tried a free app (I have no affiliation with this app) and it worked on my 3G.
ShareAbout - Share Device ID on iTunes
Just go to Finder, find your device. Trust it, click xx.xxGB and it will switch among uuid、ime and xxx.GB. Right click the content and copy it. Done :)
You can get this by opening up XCode. The device will have a label called "Identifier". This is your UUID.
You could try iStat (99¢) from Bjango or you could plug your iPhone into your computer, and open the Organizer (Window » Organizer) and it will show it there). Or you could take #wkw's idea to do it programatically.
open cydia and at the bottom on the homescreen you'll find the UUID. no need for windows either
On VMWare:
open the VMWare-Logs (On Linux: in your VMWare Directory, vmware.log).
Plugin your Iphone and connect it in VMware as USB-Device
Search in the logs for: "USB: Device [name:Apple". In this Line, you find serialnum:. This is the UUID you"re searching for.
First of all, connect your iOS device to Linux/Unix machine, and then run this simple Linux command to get UDID:
lsusb -s `lsusb | grep "Apple" | cut -d ' ' -f 2`:`lsusb | grep "Apple" | cut -d ' ' -f 4 | sed 's/://'` -v | grep iSerial | awk '{print $3}'
or for some Linux distros, use this:
lsusb -s :`lsusb | grep iPhone | cut -d ' ' -f 4 | sed 's/://'` -v | grep iSerial | awk '{print $3}'
This question already has answers here:
Adding images or videos to iPhone Simulator
(35 answers)
Closed 9 years ago.
I have photos on my Mac that I would like to add to the iPhone Simulator to test my application.
In other words: how do I add photos to the iPhone Simulator?
Edit : What about iphone Simulator 4.0 ? iphone Simulator 3.0 & 4.0 both working differently.
Thanks in advance for helping me...
Open the Window in mac where your images are stored.
Open your simulator another side.
Now drag your image from mac window to simulator,
simulator will open safari, and in a safari tab your image will be shown.
Tap & press down on image in simulator,
There will be message to "save image",
save image.
It will be added to your iPhone simulator.
Edit :
First just look at following image.
In iPhone simulator 4.0 ( iphone/iphone simulator ), itself it maintains a sqlite database for added images. So, if you want copy paste system - first make insert entries & then copy paste. That would be ridiculous way.
Ok. Let me explain simpler way of doing it.
open the finder in which you have bulk images that you want to add in simulator.
drag & drop first image into iphone simulator
on image - tap & hold for 1 second.
action sheet will appear - tap on save option
repeat same process for all images
this will do sqlite entries also.
now, open the /Users/YourUserName/Library/Application Support/iPhone Simulator/4.0
make a back up of Media directory. ( for example copy it & paste it on desktop )
when you reset your iphone simulator, all images will be gone
you need not to repeat all the process again, you have back up of it.
just copy & paste from back up to 4.0
A more easy to understand version of sagar's answer:
Open a Finder window to where your images are stored and the iPhone Simulator. Then drag the images from the Finder window into the simulator. The simulator will open Safari with your image. Click and hold to save the image to the iPhone camera roll. You can now use those images as you normally would.
I had the same question recently. The drop-the-photo-on-Safari approach works well enough if you're doing one at a time. For several images at once, I found a great blog post that explains where the simulator finds it's images.
The same poster links to a bash script to load a directory of images into the simulator. I now use this to reset my simulator's environment to a known good state as part of my build. That way, I can keep my images together with my code instead of depending on the state of the simulator's directory tree.
EDIT The original script was on a server that seems to be gone. I've pasted it here with the change needed for iPhone SDK 3.0. Credit for the script properly goes to the author of "Of Code and Men".
#!/bin/bash
simPath="$HOME/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE"
thmPath="$simPath/.MISC"
if [ -z "$1" ]; then
echo usage: $0 "<folder>"
exit 1
fi
if [ ! -d "$simPath" ]; then
mkdir -p "$simPath"
mkdir -p "$thmPath"
fi
# Find out which incremential number we're at currently.
index=1
for i in `ls $1/*.{jpg,png,gif,bmp} 2>/dev/null`; do
while [ -f "$simPath/`printf IMG_%04d.JPG $index`" ]; do
let index=$index+1
done
jpgName=`printf IMG_%04d.JPG $index`
thmName=`printf IMG_%04d.THM $index`
echo $i "->" $simPath/$jpgName
sips -s format jpeg $i --out "$simPath/$jpgName" > /dev/null 2> /dev/null || continue
sips -s format jpeg -z 96 96 $i --out "$thmPath/$thmName" > /dev/null 2> /dev/null || continue
let index=$index+1
done
For a few images:
Add image files to folder->
Add folder to xcode project->
(this will keep everything together for this project and folder can be removed from project at your discretion)
open xcode and simulator in same window->
open "photos app" in simulator->
drag and drop from xcode to simulator->
(image(s) will open in safari)
click and hold image in simulator->
chose save->
Image(s) will now be in the 'photos app' album in simulator. This was quickest and cleanest way for me.
3 Simple Steps
1) Drag & Drop image onto simulator
- this will open a browser with your image
2) Click & hold image
- this will open options
3) save image
- this will copy image onto simulator
Watch YouTube Video ( add images to iphone simulator)
I've edited the script to create a structure that works with the iPhone 4.0.1 simulator. On my system I have subfolders for iphone simulator 3.2, 4.0 and 4.0.1. So I've kept the original output of the script and modified the structure as it needs to create a PhotoData folder for the thumbnails. After running the script I create sym links for the 3.2 4.0 and 4.0.1 simulator directories as follows:
ln -s $HOME/Library/Application\ Support/iPhone\ Simulator/User/Media/DCIM/ $HOME/Library/Application\ Support/iPhone\ Simulator/4.0.1/Media/DCIM
ln -s $HOME/Library/Application\ Support/iPhone\ Simulator/User/Media/PhotoData/ $HOME/Library/Application\ Support/iPhone\ Simulator/4.0.1/Media/PhotoData
future runs of the script will update all simulators. Here's the modified script:
#!/bin/bash
rootPath="$HOME/Library/Application Support/iPhone Simulator/User/Media"
relPath="100APPLE"
simPath="$rootPath/DCIM/$relPath"
thmPath="$rootPath/PhotoData/$relPath"
if [ -z "$1" ]; then
echo usage: $0 "<folder>"
exit 1
fi
if [ ! -d "$simPath" ]; then
mkdir -p "$simPath"
mkdir -p "$thmPath"
fi
echo "Finding pictures..."
# Find out which incremential number we're at currently.
index=1
for i in `ls $1/*.{JPG,jpg,png,gif,bmp} 2>/dev/null`; do
echo "considering $i..."
while [ -f "$simPath/`printf IMG_%04d.JPG $index`" ]; do
let index=$index+1
done
jpgName=`printf IMG_%04d.JPG $index`
thmName=`printf IMG_%04d.THM $index`
echo $i "->" $simPath/$jpgName
echo $i "->" $thmPath/$thmName
sips -s format jpeg $i --out "$simPath/$jpgName" > /dev/null 2> /dev/null || continue
sips -s format jpeg -z 96 96 $i --out "$thmPath/$thmName" > /dev/null 2> /dev/null || continue
let index=$index+1
done
I've been updating the script to try and add enough data to the SqlLite databases. As soon as you save a photo from safari the following data is entered:
sqlite> select * from Photo;
primaryKey|type|title|captureTime|width|height|userRating|flagged|thumbnailIndex|orientation|directory|filename|duration|recordModDate
43|0|IMG_0037|320336214.0|640|427|0|0|0|1|DCIM/100APPLE|IMG_0037.JPG|0.0|320336214.933387
sqlite> select * from PhotoExtras;
primaryKey|foreignKey|identifier|sequence|value
142|43|1|-1|DCIM/100APPLE
143|43|2|-1|IMG_0037.JPG
144|43|3|-1|76616
145|43|6|-1|
streamtyped???#???NSMutableDictionary
146|43|7|-1|286
147|43|8|-1|
streamtyped???#???NSValue
148|43|9|-1|8252
149|43|10|-1|1
150|43|13|-1|0
The Photo table data seems quite simple although I'm currently assuming captureTime is not relevant. The PhotoExtras stuff is a bit more involved and seems necessary as my current script, which needs image magicks identify command, is not working.
identifier 1 is directory name
identifier 2 is jpg name
identifier 3 is file size in bytes
If anyone can help with the others..
The script as it stands is below:
#!/bin/bash
rootPath="$HOME/Library/Application Support/iPhone Simulator/4.2/Media"
relPath="100APPLE"
simPath="$rootPath/DCIM/$relPath"
sqlDB="$rootPath/PhotoData/Photos.sqlite"
if [ -z "$1" ]; then
echo usage: $0 "<folder>"
exit 1
fi
if [ ! -d "$simPath" ]; then
mkdir -p "$simPath"
fi
echo "Finding pictures..."
# Find out which incremential number we're at currently.
index=1
for i in `ls $1/*.{JPG,jpg,png,gif,bmp} 2>/dev/null`; do
echo "considering $i..."
while [ -f "$simPath/`printf IMG_%04d.JPG $index`" ]; do
let index=$index+1
done
imgName=`printf IMG_%04d $index`
jpgName=`printf IMG_%04d.JPG $index`
thmName=`printf IMG_%04d.THM $index`
jpgWidth=`identify -format %w $i`
jpgHeight=`identify -format %h $i`
echo $i "->" $simPath/$jpgName
jpgSize=`stat -f %z $i`
jpgDir="DCIM/100APPLE"
sips -s format jpeg $i --out "$simPath/$jpgName" > /dev/null 2> /dev/null || continue
sqlite3 "$sqlDB" "insert into Photo (title,width,height,directory,filename) values ('$imgName',$jpgWidth,$jpgHeight,'$jpgDir','$jpgName')"
foreignKey=`sqlite3 "$sqlDB" "select primaryKey from Photo where title='$imgName'"`
sqlite3 "$sqlDB" "insert into PhotoExtras (foreignKey,identifier,value) values ($foreignKey,1,'$jpgDir'); \
insert into PhotoExtras (foreignKey,identifier,value) values ($foreignKey,2,'$jpgName'); \
insert into PhotoExtras (foreignKey,identifier,value) values ($foreignKey,3,$jpgSize);"
let index=$index+1
done
I'll edit if I get further, the next stage is identifying what the various .ithmb files contain. Hopefully some sort of stack of jpg thumbnails.
I've been using an automated technique I originally found at iPhone Dev SDK. Include the images in your app's resources, then:
UIImage *image = [UIImage imageWithName:#"imageName.jpg"];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
http://www.iphonedevsdk.com/forum/iphone-sdk-development/2225-no-photos-in-iphone-simulator-how-to-add-photos.html