본문 바로가기
iOS

설정앱에 라이센스 내용 추가하기

by vapor3965 2021. 10. 20.

목차

     

    이전에 만든 앱에는 앱내에서 설정화면을 따로 만들어, 거기서 라이센스 관련된 내용들을 추가했었다.

     

    이번에는 앱내에서가 아니라, 아이폰 - 설정앱에서 나의 앱에 추가하는 방법을 알게되면서 이를 이번에 팀 프로젝트에 사용해보려고 한다. 

     

    다음과 같이 구현하고자 한다.  ( 쏘카앱이 다음과 같이 구현되어있어 참고했다 ) 

     

     

    우선 프로젝트에 Settings Bundle 을 클릭하여 추가한다. 

     

    그러면 아래와 같이 파일이 생성되는데, 

     

    Root.plist를 확인해보면 다음과 같이 Default로 작성되어있다. 

    이를 실행해보면, 위의 내용들이 아래와 같이 반영되어 나타난다. 

     

     

    위의 요소들은 아래와 같은 특정 타입으로 특정 컨트롤로 나타낼 수 있다. 

     

    나는 Child pane이 필요한데,  Property List에서는 Child pane이 나타나지 않는다. 

    이는 소스코드로 직접 추가해주어야한다. 

     

     

    Childe pane의 키는 아래에서 확인할 수 있다. 

    https://developer.apple.com/library/archive/documentation/PreferenceSettings/Conceptual/SettingsApplicationSchemaReference/Articles/PSChildPaneSpecifier.html#//apple_ref/doc/uid/TP40007017-SW1

     

    Child Pane Element

    Child Pane Element Table 1 lists the keys that may be placed in a dictionary that is associated with the PSChildPaneSpecifier type. This element displays a preferences row, that when tapped loads a new page of preferences. You can use this element type to

    developer.apple.com

     

    Root.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>StringsTable</key>
    	<string>Root</string>
    	<key>PreferenceSpecifiers</key>
    	<array>
    		<dict>
    			<key>Type</key>
    			<string>PSChildPaneSpecifier</string>
    			<key>Title</key>
    			<string>Licenses</string>
    			<key>File</key>
    			<string>LicenseList</string>
    		</dict>
    	</array>
    </dict>
    </plist>

     

    그럼 다음과 같이 나타난다. 

    ( 약간 해맸던 부분인데, 기본적으로 Root.plist에서는 *** SETTINGS 그룹이 있다 ) 

     

    그럼 이제 다음 페이지인 License의 리스트를 plist파일로 새로 만들고, Settings.bundle 안에 넣어준다. 

    이 파일 또한 마찬가지로 위의 타입을 이용하여 작성하면 된다. 

     

    <?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>StringsTable</key>
    	<string>LicenesList</string>
    	<key>PreferenceSpecifiers</key>
    	<array>
    		<dict>
    			<key>Type</key>
    			<string>PSGroupSpecifier</string>
    			<key>Title</key>
    			<string>Licenses</string>
    		</dict>
    		<dict>
    			<key>Type</key>
    			<string>PSChildPaneSpecifier</string>
    			<key>Title</key>
    			<string>RxSwift</string>
    			<key>File</key>
    			<string>RxSwiftLicense</string>
    		</dict>
            <dict>
                <key>Type</key>
                <string>PSChildPaneSpecifier</string>
                <key>Title</key>
                <string>SwiftGen</string>
                <key>File</key>
                <string>SwiftGenLicense</string>
            </dict>
            <dict>
                <key>Type</key>
                <string>PSChildPaneSpecifier</string>
                <key>Title</key>
                <string>SwiftLint</string>
                <key>File</key>
                <string>SwiftLintLicense</string>
            </dict>
            <dict>
                <key>Type</key>
                <string>PSChildPaneSpecifier</string>
                <key>Title</key>
                <string>Fastlane</string>
                <key>File</key>
                <string>FastlaneLicense</string>
            </dict>
    	</array>
    </dict>
    </plist>

     

     

    위의 코드를 보면, 그룹안에 ChildPane을 또 가지고, 그것이 각 라이브러리의 세부화면이 되니까, 

    ***.plist를 또 만들어준다. 

    RxSwiftLicense.plist를 다음과 같이 만들었다. 

     

    Group 타입안에 FooterText가 있어, 이를 활용한다. 

    https://developer.apple.com/library/archive/documentation/PreferenceSettings/Conceptual/SettingsApplicationSchemaReference/Articles/PSGroupSpecifier.html#//apple_ref/doc/uid/TP40007009-SW1

     

    Group Element

    Group Element Table 1 lists the keys that may be placed in a dictionary that is associated with the PSGroupSpecifier type. This type defines a group element, which is a way to visually group preferences on a page. This element should be placed in front of

    developer.apple.com

     

    <?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>StringsTable</key>
    	<string>RxSwift</string>
    	<key>PreferenceSpecifiers</key>
    	<array>
    		<dict>
    			<key>Type</key>
    			<string>PSGroupSpecifier</string>
    			<key>FooterText</key>
    			<string>RxSwift</string>
    		</dict>
    	</array>
    </dict>
    </plist>

     

     

    FooterText에 RxSwift를 넣었는데,  FooterText가 Localizable이 가능하므로, 

    RxSwift.strings에서 RxSwift에 대응하는 실제 라이센스 내용을 넣어주도록 한다. 

     

     

    RxSwift.strings 

    "RxSwift" =
    "
    The MIT License Copyright © 2015 Krunoslav Zaher, Shai Mishali All rights reserved.
    
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    ";

     

     

     

     


    https://stackoverflow.com/questions/29969078/no-child-pane-option-in-settings-bundle-root

     

     

    No 'Child Pane' option in settings bundle root

    I've added a settings bundle to the app using Xcode 6.3.1. According to the documentation I should be able to create hierarchical structure by adding the 'Child Pane' key (PSChildPaneSpecifier) to a .

    stackoverflow.com

     

    https://abhimuralidharan.medium.com/adding-settings-to-your-ios-app-cecef8c5497

     

    Adding settings to your iOS app

    Source: Apple docs.

    abhimuralidharan.medium.com

    https://developer.apple.com/library/archive/documentation/PreferenceSettings/Conceptual/SettingsApplicationSchemaReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007071

     

    Introduction

    Introduction Preferences for iOS and tvOS apps are displayed by the system-provided Settings app. Preferences for WatchKit extensions are displayed by the system-provided Apple Watch app. A settings bundle contains the information needed by these system ap

    developer.apple.com

     

     

     

    http://minsone.github.io/mac/ios/ios-write-licenses-using-settings-bundle

     

    [iOS]Settings Bundle을 이용하여 라이센스를 설정 내에 표시하기

    얼마전 tmax 발표를 보고 오픈소스 라이센스를 표시해놓아야 겠다는 생각이 많이 들었습니다. 앱 내에 UI를 만들고 넣어야 하나라는 생각이 들어서 설정에 추가하는 방식으로 선회를 하였습니다.

    minsone.github.io

     

     

    댓글