Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 472 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the difference between an "app" project and a "framework" project in Xcode?

#1
I am working on a project with SwiftUI and it originally started with creating a new project as an "App" (Xcode, clicked on file, new, project, click on "App") but was then later asked to put it into a pod as a framework. I did it successfully (Xcode, clicked on file, new project, click on "Framework"), however I am unsure what the differences are and I'm unsure why I would want to do that. To me they look very similar, except that I'm unable to launch my project as a framework in the simulator. Luckily SwiftUI offers the canvas preview window however it is a bit finicky when it comes to certain button interactions, which is why I am wanting to use the simulator.

Two places of confusion:

- What is the difference between an app and a framework project?
- Why is it more advantageous to have my project as a framework?
Reply

#2
An App is a standalone application that can be launched and run. For example, all of the apps that you have on your phone are just that -- apps. You tap on them and they launch and run, presenting a user interface, accepting input, etc.

A framework is something else entirely. It's a collection of code that is bundled together into a package that is used by another framework or by an app. Some frameworks are provided by the system -- for example, SwiftUI is a framework that it sounds like you're using in your app. Other frameworks are provided by 3rd parties. For example, you can find many frameworks via CocoaPods or the Swift Package Manager -- Alamofire is a common example. Also, you can make your own frameworks and use them in your own code as a form of organization and separation of responsibilities.

> Why is it more advantageous to have my project as a framework?

It is not -- they are two almost completely different concepts (besides both ultimately being collections of code and resources). If you intend to build an app that is launch-able on someone's device, your only choice is to make an app. If you intend to make a collection of reusable code for use in your or someone else's app, than you would make a framework.
Reply

#3
Excellent answer (and upvoted) by @jnpdx. Let me give you a physical example:

(1) Create a *project* in Xcode that is a framework. Call it "MyAppKit". Inside it create, well, basically anything - a `View`, `UIView`, or more likely a function that will be *shared* by several views. (Let's go with that.)

public func setLoginName(_ login:String) -> String {
return ""Hello, " + login + "!";
}

Pretty simple. Call it, pass in something, and it returns a string saying hello. Please note the `public` piece. It matters. (And there's much more there. This is a simple example.)

(2) Now we get to your app or apps. Let's say you have two apps that need to use this (again, **very simple**) code. One is SwiftUI, one is UIKit. (It doesn't matter except for syntax.) Sine my forte is UIKit I'll use that. (And it can be several dozen apps too.)

import MyAppKit

let myLoginMessage = setLoginName("World").

Pretty much, it's "Hello, World!'

Again, this is really a nonsensical example. But it should get you started on what the difference in Xcode is between a Framework project and an App project is.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through