Xcode 6 iPhone 시뮬레이터 응용 프로그램 지원 위치
Xcode 6에는 Core Data를 사용하는 앱이 있지만 iOS 8 iPhone Simulator의 응용 프로그램 지원에는 폴더가 없습니다. 내 파일과 Core Data sqlite 데이터베이스는 어디에 저장됩니까?
시뮬레이터 디렉토리는 Xcode 6 베타로 이동되었습니다 ...
~/Library/Developer/CoreSimulator
디렉토리를 앱의 Documents 폴더로 찾아 보는 것은 조금 더 힘든 일입니다.
~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite
SimPholders 를 사용 하여 시뮬레이터 파일을 찾는 것이 좋습니다 . 시뮬레이터 앱을 추적하고 해당 폴더와 컨텐츠로 직접 이동할 수있는 메뉴 표시 줄 항목입니다. 그것은 굉장.
SimulatorManager 응용 프로그램이 매우 유용하다는 것을 알았습니다 . 설치된 시뮬레이터의 응용 프로그램 폴더로 직접 이동합니다. 7.1, 8.0 및 8.1 시뮬레이터로 시도했습니다.
SimulatorManager는 시스템 트레이에 아이콘으로 있으며 "로그인시 시작"옵션을 제공합니다.
참고 : 이것은 Xcode 6 (필자의 경우 6.1.1) 이상에서만 작동합니다.
희망이 도움이됩니다!
.sqlite 파일이 AppDelegate.m에 저장된 위치를 알려면 다음 코드를 추가하십시오.
- (NSURL *)applicationDocumentsDirectory
{
NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
이제 AppDelegate.m에서이 메소드를 호출하십시오.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//call here
[self applicationDocumentsDirectory];
}
이것은 신속하게 나를 위해 일했습니다.
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
println("App Path: \(dirPaths)")
나는 얼마 동안 이것과 씨름했다. 단순히 내 지역 sqlite db에 도착하는 것은 큰 고통이되었습니다. 이 스크립트를 작성하고 XCode 내부의 코드 스 니펫으로 만들었습니다. 내 appDelegate 안에 appDidFinishLaunching 안에 넣습니다.
//xcode 6 moves the documents dir every time. haven't found out why yet.
#if DEBUG
NSLog(@"caching documents dir for xcode 6. %@", [NSBundle mainBundle]);
NSString *toFile = @"XCodePaths/lastBuild.txt"; NSError *err = nil;
[DOCS_DIR writeToFile:toFile atomically:YES encoding:NSUTF8StringEncoding error:&err];
if(err)
NSLog(@"%@", [err localizedDescription]);
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
NSString *aliasPath = [NSString stringWithFormat:@"XCodePaths/%@", appName];
remove([aliasPath UTF8String]);
[[NSFileManager defaultManager] createSymbolicLinkAtPath:aliasPath withDestinationPath:DOCS_DIR error:nil];
#endif
This creates a simlink at the root of your drive. (You might have to create this folder yourself the first time, and chmod it, or you can change the location to some other place) Then I installed the xcodeway plugin https://github.com/onmyway133/XcodeWay
I modified it a bit so that it will allow me to simply press cmd+d and it will open a finder winder to my current application's persistent Documents directory. This way, not matter how many times XCode changes your path, it only changes on run, and it updates your simlink immediately on each run.
I hope this is useful for others!
Open finder>Library>Developer>CoreSimulator>Devices
Then Change Arrangement icon from finder select Date Added
Select your app >data>Container>data>Applications>
choose your app >Documents>Here is your db file
In my case:
/Users/pluto/Library/Developer/CoreSimulator/Devices/A75107D2-A535-415A-865D-978B2555370B/data/Containers/Data/Application/265A12BC-FF5B-4235-B5EF-6022B83754B4/Documents/dboPhotoBucket.sqlite
Otherwise do this :
NSLog(@"app dir: %@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
- It will print the full path to data folder.
Swift:
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
println("App Path: \(dirPaths)")
Use Finder-->go to folder and enter given basepath to reach application folders
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSLog(@"%@",basePath);
The simulator puts the file in ~/Library/Developer/CoreSimulator/Devices/... but the path after /Devices is different for everyone.
Use this handy method. It returns the path of the temporary directory for the current user and takes no argument.
NSString * NSTemporaryDirectory ( void );
So in my ViewController class I usually put this line in my viewDidLoad just for a reference when I need to grab my CoreData stored file. Hope this helps.
NSLog(@"FILE PATH :%@", NSTemporaryDirectory());
(Note: to go to the path, from the finder menu click on Go and type ~/Library to open hidden directory then in the Finder Window you can click on the path shown on your console.)
This location has, once again, changed, if using Swift, use this to find out where the folder is (this is copied from the AppDelegate.swift file that Apple creates for you so if it doesn't work on your machine, search in that file for the right syntax, this works on mine using Xcode 6.1 and iOS 8 simulator):
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
println("Possible sqlite file: \(urls)")
The simulators are located under:
~/Library/Developer/CoreSimulator/
Here, they are listed as directories with UUID names. Use sort by 'Date modified' to find the latest one. Inside navigate to:
/data/Containers/Data/Application/
Here you will get a list of all the applications on that device. You can again sort this to get the latest app.
NOTE: Xcode changes the directory name every time you run the app, so don't rely on making alias/short cuts on desktop.
The easiest way is to use the app here, which does everything automatically.
I created this script that will zip the latest app built for any simulator and zip it to the desktop.
https://gist.github.com/Gerst20051/8ca49d5afbf09007b3696fab6e9f425c
#!/bin/bash
DESTINATION_DIR="$HOME/Desktop"
APP_PATH=$(find ~/Library/Developer/CoreSimulator/Devices/*/data/Containers/Bundle/Application/*/*.app -type d -maxdepth 0 -print0 | xargs -0 ls -td | head -n1)
APP_DIRNAME=$(dirname "$APP_PATH")
APP_BASENAME=$(basename "$APP_PATH")
FILE_NAME="${APP_BASENAME%.*}"
cd "$APP_DIRNAME"
zip -qr "$DESTINATION_DIR/$FILE_NAME.zip" "$APP_BASENAME"
1. NSTemporaryDirectory() gives this:
/Users/spokaneDude/Library/Developer/CoreSimulator/Devices/1EE69744-255A-45CD-88F1-63FEAD117B32/data/Containers/Data/Application/199B1ACA-A80B-44BD-8E5E-DDF3DCF0D8D9/tmp
2. remove "/tmp" replacing it with "/Library/Application Support/<app name>/" --> is where the .sqlite files reside
With Swift 4, you can use the code below to get your app's home directory. Your app's document directory is in there.
print(NSHomeDirectory())
I think you already know that your app's home directory is changeable, so if you don't want to add additional code to your codebase, SimPholder is a nice tool for you.
And further more, you may wonder is there a tool, that can help you save time from closing and reopening same SQLite database every time after your app's home directory be changed. And the answer is yes, a tool I know is SQLiteFlow. From it's document, it says that:
데이터베이스 파일 이름 또는 디렉토리 변경을 처리하십시오. 이로 인해 SQLiteFlow는 iOS 시뮬레이터의 SQLite 데이터베이스와 호환됩니다.
마지막으로 사용한 시뮬레이터 및 응용 프로그램에 대한 sh 는 다음과 같습니다 . sh를 실행하고 인쇄 된 텍스트를 복사하고 파인더에 표시하기 위해 명령을 붙여넣고 실행하십시오.
#!/bin/zsh
lastUsedSimulatorAndApplication=`ls -td -- ~/Library/Developer/CoreSimulator/Devices/*/data/Containers/Data/Application/*/ | head -n1`
echo $lastUsedSimulatorAndApplication
Swift 4 또는 Swift 5에서는을 사용할 수 있습니다 NSHomeDirectory()
.
Xcode 10 (또는 Xcode 11)에서 가장 쉬운 방법은 응용 프로그램을 중단 (예 : 중단 점에 도달 할 때)하고 디버거 콘솔 에서이 줄을 실행하는 것입니다.
po NSHomeDirectory()
po
인쇄 객체를 나타내며 대부분의 것을 인쇄합니다
참고 URL : https://stackoverflow.com/questions/24290989/xcode-6-iphone-simulator-application-support-location
'IT' 카테고리의 다른 글
C # 널 입력 가능 문자열 오류 (0) | 2020.06.24 |
---|---|
필드에 NULL이 포함 된 경우 MySQL CONCAT는 NULL을 반환합니다. (0) | 2020.06.24 |
프레임 워크 대 라이브러리 대 IDE 대 API 대 SDK 대 툴킷의 차이점은 무엇입니까? (0) | 2020.06.24 |
스위프트의 dealloc (0) | 2020.06.24 |
C #에서 부울의 크기는 얼마입니까? (0) | 2020.06.24 |