first, thanks for the article, nice introduction and step by step guide…
the question I have is how to build a framework that combines both the device and simulator targets, so when I ship the framework to a 3rd party, they can use it both on the simulator and device?
I’m not releasing the source code (well, my client isn’t, same difference), so setting up a repository and using cocoapods (which I’m not a fan of anyway) is out of the question.
You can combine these commands into a script to generate your framework when you need it.
However, if you generate your framework like this, the project that will integrate the framework will need to remove the simulator architectures when submitting to the App Store. Otherwise, your build will be rejected immediately. There are no other solutions that I’m aware of if you want to ship a .framework without the source code.
In order to prevent this, you should create another script that will be added as “Run Phase” in the project that includes the framework. Here’s the one I use:
Regarding Cocoapods, also know that it is possible to distribute pre-compiled .framework with it (but it will only work on iOS 8 and later). You’ll need to do is define a direct URL to the zipped .framework in your Podspec. More infos are available on the Cocoapods website.
Thanks for the answear, I have a really similar problem too. I think it’s a bit strange to ship a framework with a script to be able to actually use it. As far as I know e.g. facebook ships their SDK in a .framework, but they don’t need any script, besides it can be used in simulator.
Does anybody has any idea how are they doing it?
Not yet. But I didn’t found anybody complaining about beeing unable to send an iOS app to review 'cause the facbook sdk.
Otherwise thanks for the link, the built in script seems a bit sophisticated solution than giving the full “strip.sh”
@mkatz Hi. I am not able to install the pod in the final step after publishing it to my github account. I am getting the following error:
[!] The ThreeRingControl pod failed to validate due to 1 error:
- ERROR | source: The Git source still contains the example URL.
- WARN | source: The version should be included in the Git tag.
If you don’t, a project using the resulting framework, when building for the simulator, will not be able to see the classes contained in the framework…
otherwise, works like a charm… thanks, again
the thing I did “wrong” was that I did a build for both targets, not an archive… oh well
Great tutorial. The one thing that’s typically never discussed is best practices when depending on external frameworks when creating your own framework. For example your shared code will utilize AlamoFire or in my case the frustration of depending on CocoaLumberjack. (It’s for a private framework) Anyways thank you!
We have an app that is connecting to our server to get updates like new texts and pictures. We have a little logic in the app when we are doing payments etc, but mainly the app is just displaying data from the server. Now one of our customers wants a new GUI, but other customers wants to keep the old GUI. Is a framework for the app business logic and app database the app the right way to go?
Frameworks are good way to go about it. In fact that’s how we’ve divided up our app. Just be careful anywhere you’re referencing the bundle, since frameworks have their own.
→ ThreeRingControl (1.0.0)
- WARN | github_sources: Github repositories should end in .git.
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error and 1 warning.
Hi all! I just updated the tutorial to work with XCode 8, and Cocoapods 1.0. Hopefully this should clarify some of the build and pods errors that have been reported.