How to make the same iOS Swift app with some differences in code and assets with scalable and clean mode

I need it.

I developed an application and I want to duplicate it. I can copy and paste the project, but if I do it 10 times, a problem may arise. The problem is that if I find an error in the 10th duplicate, I have to consider all other projects, and I do not want to do this.

Is there a clean way to solve this problem?

In other words, I only have one big code. The differences between the applications I have to deploy are:

  • Launch icon
  • HTTP request domain
  • Package name
  • Screensaver
  • app name
  • Some integers inside the application
  • Some assets

On Android, I do this with gradle, in particular with aromas. How can I do the same with Swift?

+2
3

. info.plist , , .

+3

Git:

:

  • , , , .. Constants.swift.

  • , .xcassets. (, , ) . , , ( -).

  • ( , ). , , , , .

, . , .

-, . .

0

:

(1) Framework.

- , , , .xib - . App/Bundle ID ( "com.company.framework" ), , App Store. , " API " , .

, , . , / Xcode. , :

public func returnKernel(_ named:String) -> String {
    let myBundle = Bundle.init(identifier: "com.company.framework")
    let kernelPath = (myBundle?.path(forResource: "cikernels", ofType: "bundle"))! + "/" + named + ".cikernel"
    do {
        return try String(contentsOfFile: kernelPath)
    }
    catch let error as NSError {
        return error.description
    }
}

(2) , .

, "". , :

import Kernel

, ( ): .

(3a) .xcodeproj .

PROS: () (b) .

CON: app, Xcode , .

(3b) Kernel.framework .

PRO: .

CONS: (a) , , , (b) .

" ", . , , . , .

:

  • Changes made to the structure while working in application # 1 will be raised when you open the "application number 2".

  • I have separate Git repositories for (a) each application and (b) my framework, both locally and on GitHub. It works great.

  • I have separate Bundle / App identifiers (and versions) configured for (a) each application and (b) my infrastructure in the developer portal.

  • App Store arrival time, I archive the application and download it. The frame is suitable for riding.

0
source

Source: https://habr.com/ru/post/1665004/


All Articles