반응형

참조: https://6developer.com/935

object-c: https://indra17.tistory.com/entry/ios-%ED%83%88%EC%98%A5%ED%8F%B0-%EC%B2%B4%ED%81%AC?category=533814

func hasJailbreak() -> Bool {
        guard let cydiaUrlScheme = NSURL(string: "cydia://package/com.example.package") else { return false }
        if UIApplication.shared.canOpenURL(cydiaUrlScheme as URL) {
            return true
        }
        #if arch(i386) || arch(x86_64)
        return false
        #endif
        
        let fileManager = FileManager.default
        if fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
            fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
            fileManager.fileExists(atPath: "/bin/bash") ||
            fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
            fileManager.fileExists(atPath: "/etc/apt") ||
            fileManager.fileExists(atPath: "/usr/bin/ssh") ||
            fileManager.fileExists(atPath: "/private/var/lib/apt") {
            return true
        }
        if canOpen(path: "/Applications/Cydia.app") ||
            canOpen(path: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
            canOpen(path: "/bin/bash") ||
            canOpen(path: "/usr/sbin/sshd") ||
            canOpen(path: "/etc/apt") ||
            canOpen(path: "/usr/bin/ssh") {
            return true
        }
        let path = "/private/" + NSUUID().uuidString
        do {
            try "anyString".write(toFile: path, atomically: true, encoding: String.Encoding.utf8)
            try fileManager.removeItem(atPath: path)
            return true
        } catch {
            return false
        }
    }
    func canOpen(path: String) -> Bool {
        let file = fopen(path, "r")
        guard file != nil else { return false }
        fclose(file)
        return true
    }
반응형

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크  (0) 2019.12.12
swift 타입체크 함수 (UIViewController)  (0) 2019.12.11
xcode에서 개발/운영 환경 설정  (0) 2019.03.28
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13
반응형

출처: http://bitxflow.synology.me/wordpress/?p=311%20

swift: https://indra17.tistory.com/entry/ios-%ED%83%88%EC%98%A5%ED%8F%B0-%EC%B2%B4%ED%81%ACswift

+(BOOL)isJailbroken{
#if !(TARGET_IPHONE_SIMULATOR)
    if ([[NSFileManager defaultManager] fileExistsAtPath:@”/Applications/Cydia.app”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/Library/MobileSubstrate/MobileSubstrate.dylib”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/bin/bash”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/usr/sbin/sshd”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/etc/apt”]){
        return YES;
    }
    return NO;

    NSError *error;
    NSString *stringToBeWritten = @"This is a test.";
    [stringToBeWritten writeToFile:@”/private/jailbreak.txt” atomically:YES encoding:NSUTF8StringEncoding error:&error];
    if(error==nil){
        //Device is jailbroken
        return YES;
    } else {
        //Device is not jailbroken
        [[NSFileManager defaultManager] removeItemAtPath:@”/private/jailbreak.txt” error:nil];
    }
    if([[UIApplication sharedApplication] canOpenUrl: [NSURL URLWithString:@”cydia://package/com.example.package”]]){
        //Device is jailbroken
    }
#endif
  
    //All checks have failed. Most probably, the device is not jailbroken
    return NO;
}
반응형

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크(swift)  (0) 2020.04.23
swift 타입체크 함수 (UIViewController)  (0) 2019.12.11
xcode에서 개발/운영 환경 설정  (0) 2019.03.28
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13
반응형

함수 정의,  UIViewController대신에 원하는 타입의 부모클래스를 넣으면 됨

func isAleadyVC<T>(_ vcs:[UIViewController]?, _ tp: T.Type) -> UIViewController? {
	for i in 0 ..< vcs!.count {
		if (vcs![i] as? UINavigationController) != nil {
			let nc = vcs![i] as! UINavigationController
			if let vc = isAleadyVC(nc.children, tp) {
				return vc
			}
		}
		else if (vcs![i] as? UITabBarController) != nil {
			let tc = vcs![i] as! UITabBarController
			if let vc = isAleadyVC(tc.children, tp) {
				return vc
			}
		}
		else { // always UIViewController
			let vc = vcs![i]
			if type(of: vc) == tp {
				return vc
			}
			if let vc = isAleadyVC(vc.children, tp) {
				return vc
			}
		}
	}
	return nil
}

 

사용

if let homeVC = isAleadyVC(self.window?.rootViewController?.children, HomeVC.self) as? HomeVC {
	...
}
반응형

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크(swift)  (0) 2020.04.23
ios 탈옥폰 체크  (0) 2019.12.12
xcode에서 개발/운영 환경 설정  (0) 2019.03.28
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13
반응형

프로젝트 생성 시 기본적으로 Debug, Release Scheme이 생성되어 있다.

Scheme설정 중 Archive는 Release, Run은 Debug가 기본 설정

 

1. 프로젝트 설정에서 개발, 운영 용 의 설정셋을 추가한다 (Debug설정으로 복사)

 

2. Scheme을 추가한다

 

3. scheme과 설정셋을 매핑

 

4. 개발/운영 설정을 설정셋에 추가한다

프로젝트 설정 - 타겟 - Build Settings - Active Compilation Conditions 의 개발/운영 환경에 macro define값을 추가 (여기선 dev만 구분)

 

5. 소스에서 macro define으로 구분

#if DEV

public static let DOMAIN = "http://개발서버주소"

#else

public static let DOMAIN = "http://운영서버주소"

#endif

 

6. 추가적으로 info.plist파일 복제하여 개발/운영에 따라 앱 이름, bundle ID 등을 변경

반응형

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크  (0) 2019.12.12
swift 타입체크 함수 (UIViewController)  (0) 2019.12.11
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13
ipa 커맨드라인으로 만들기 (xcode 9.2 대응)  (0) 2018.04.09
반응형

#ifdefine 은 사용할 수 없다

 

#if, #else, #endif를 사용

반응형
반응형

안드로이드 SQLiteOpenHelper참조하여 만듬

SQLiteOpenHelper.swift


프로젝트에 SQLite3 라이브러리 추가해야함

반응형
반응형

ipa파일이 프로비저닝 설정하는 방식이 plist파일을 쓰는 방식으로 변경되었다.

(8.3.0 버전 빌드)

(8.3.0 이전버전 빌드)



기존 


scheme = [

"dev_debug",

"prod_debug",

]


system("xcodebuild clean -project #{proj_name}/#{proj_name}.xcodeproj")

system("xcodebuild archive -project #{proj_name}/#{proj_name}.xcodeproj -scheme #{scheme[i]} -archivePath build/#{scheme[i]}.xcarchive")

system("xcodebuild -exportArchive -archivePath build/#{scheme[i]}.xcarchive -exportPath build/#{scheme[i]}.ipa -exportFormat ipa -exportProvisioningProfile #{profile}")



변경

system("xcodebuild clean -workspace #{proj_name}/#{proj_name}.xcworkspace -scheme #{scheme[i]}")

                system("xcodebuild archive -workspace #{proj_name}/#{proj_name}.xcworkspace -scheme #{scheme[i]} -archivePath build/#{scheme[i]}.xcarchive GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS DIST=1'")

                system("xcodebuild -exportArchive -archivePath build/#{scheme[i]}.xcarchive -exportPath build/ipas -exportOptionsPlist adhoc.plist")



plist 파일


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

    <key>compileBitcode</key>

    <false/>

    <key>method</key>

    <string>ad-hoc</string>

    <key>teamID</key>

    <string>팀ID(apple 개발자 사이트에서 확인)</string>

    <key>provisioningProfiles</key>

    <dict>

        <key>번들ID</key>

        <string>개발자사이트에 등록한 provisioning명</string>

    </dict>

</dict>

</plist>



반응형
반응형

Xcode 8.3.3 기준으로 작성


간단하게 indicator만 라이브러리에 추가 한 후 사용하는 방법으로 설명


1. 라이브러리 프로젝트 생성




2. 스토리보드에 UIViewController 추가

  - 스토리보드 이름에 유의 (프로젝트 명과 동일하게 만듬)







3. 번들 타겟 추가 및 수정








4. 번들에 리소스 추가




5. 번들에 있는 스토리보드 사용

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"testLib" bundle:[NSBundle bundleWithPath:[[NSBundle mainBundle]             pathForResource:@"testLibBundle" ofType:@"bundle"]]];

[self.view addSubView:((UIViewController *)[sb instantiateViewControllerWithIdentifier:@"IndicatorVC"]).view];



반응형
반응형

출처: http://freecandoall.blogspot.kr/2017/03/xcodebuild-error-invalid-option.html


기존에 정리한 xcode빌드 중 xcodebuild: error: invalid option '-exportFormat' 에러가 나면서 빌드 실패가 된다.

찾아보니 위에 잘 정리가 되어 있다. (감사^^)


8.3.0 이전 버전에서 경고가 나오긴 했었는데 무시하고 있다가 이번에 ios 10.3.1버전 빌드를 하기 위해 업데이트 했더니..... 


8.3.0 이전버전 빌드는 다음으로 가면 된다.




반응형
반응형

xcode에서 몇개의 Scheme를 추가해서 각 스킴에 맞춰 접속하는 서버를 변경하도록 코딩하고, 테스트 배포용으로 ipa파일을 만들기 위해 검색하여 만든 루비 스크립트 내용이다.


스크립트로 만들지 않고 직접 실행 할 경우 system함수의 내부 문자열만 복붙해서 사용하면 된다.


scheme = [

"dev_debug",

"prod_debug",

]


system("xcodebuild clean -project #{proj_name}/#{proj_name}.xcodeproj")

system("xcodebuild archive -project #{proj_name}/#{proj_name}.xcodeproj -scheme #{scheme[i]} -archivePath build/#{scheme[i]}.xcarchive")

system("xcodebuild -exportArchive -archivePath build/#{scheme[i]}.xcarchive -exportPath build/#{scheme[i]}.ipa -exportFormat ipa -exportProvisioningProfile #{profile}")



실행순서는 다음과 같다.


1. 프로젝트에서 생성된 파일들을 삭제

2.archive를 생성

3. ipa파일을 생성

3.1. ipa 파일 생성 시 사용하는 프로비저닝 프로파일은 xcode의 perference에서 계정탭 선택 후 보여지는 프로비저닝 프로파일의 이름이어야 한다.

(apple 개발자 사이트에서 프로비저닝 등록할 때 설정하는 이름이기도 하다)



반응형

+ Recent posts