12

I have an app implemented in native iOS (Swift). There is a web version of the app as well. A client wants to embed my app to its own app and suggested I use an iFrame and load the web version. I understand this is a tricky solution as Apple might reject the app for not using native implementation.

What I want to ask is if there is a way to package my app entirely as a Framework and load it that way (app size is fairly big, with several viewControllers and functionality).

I understand that I won't have access to App-load functions like the AppDelegate.

Also what happens if my app has Library dependencies ? (such as Alamofire)

Any other things I should be concerned about ?

Thank you

PoolHallJunkie
  • 1,345
  • 14
  • 33
  • 2
    Yes as you said above you won't get AppDelegate and other stuffs like Notification facility. But you can do one thing just convert the core concepts of your app to framework – Ephrim Daniel May 03 '19 at 09:23
  • If your client doesn't need to add more functionality, you should simply deploy your app as a white label, there's no need to embed your whole project into a framework. – Dávid Pásztor May 03 '19 at 09:25
  • This is not a branding issue. There is a need for the app to be embed rather than a separate app. – PoolHallJunkie May 03 '19 at 09:50
  • What is the web app do? is it a replica of the native app? – Febin Fathah May 23 '19 at 12:39

1 Answers1

13

There are obviously a lot of options around this as far as design/approach.

I've done this multiple times (with apps live on the app store) and really it's just like developing any Framework.

First: AppDelegate. The easy way around this is to have the app's AppDelegate subclass your Framework's AppDelegate:

@UIApplicationMain class ParentAppDelegate: FrameworkAppDelegate { }

Just make sure the App calls super on all the relevant methods.

Second: Dependencies. This is probably the most annoying part since Frameworks can't embed other frameworks. But you still have a few easy options:

  1. Have the enclosing app embed the needed framework
  2. Add the sources of the needed framework directly to your framework.
  3. Use a dependency manager (e.g. cocoapods) that takes care of this for you.

Other Concerns: One trap you can easily run into is working with Bundles. Anytime you dynamically load images/strings/IB references/etc. you will need to specify you're using the Framework's bundle, as at times it can default to using the app's bundle. The easiest way to do this is with this init e.g. Bundle(for: self.self)

Also keep in mind that the settings in info.plist and entitlements your framework needs will need to be added by the parent app.

General Comments on Approach: My advice (take it or leave it ☺️) would be caution around simply adding your full application to a client's application. Aside from IP and App-Review concerns, it can result in adding a lot of complexity or a fork of your current application to support it, making future maintenance a hassle.

Instead I would recommend putting only the portions of the application your client requires into a separate framework that both you and your client use for your separate applications.

GetSwifty
  • 7,568
  • 1
  • 29
  • 46