How to make an iOS asset bundle?

前端 未结 7 581
谎友^
谎友^ 2020-12-02 05:37

I saw a custom asset bundle in an iOS project I evaluated, so at least I know it\'s possible.

My issue is that I\'m using a CATiledLayer with about 22,000 tiles for

相关标签:
7条回答
  • 2020-12-02 06:02

    My notes on bundling and reading files in an Xcode project

    Steps:

    1. Create a test.txt file and add the text "testing" to it then put it in a folder named test.bundle
    2. Drag and drop it next to your .app file in Xcode (copy)
    3. print(Bundle.main.resourcePath!+"/temp.bundle/test.txt") Output: /Users/James/Library/Developer/Xcode/DerivedData/GitSyncMac-heiwpdjbtaxzhiclikjotucjguqu/Build/Products/Debug/GitSyncMacApp.app/Contents/Resources/temp.bundle/test.txt

    Example:

    print(content(Bundle.main.resourcePath!+"/temp.bundle/test.txt")) // testing
    static func content(_ path:String)->String?{
        do {
            let content = try String(contentsOfFile:path, encoding:String.Encoding.utf8) as String//encoding: NSUTF8StringEncoding
            return content
        } catch {
            return nil
        }
    }
    
    0 讨论(0)
提交回复
热议问题