<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oğuzhan Karakuş on Medium]]></title>
        <description><![CDATA[Stories by Oğuzhan Karakuş on Medium]]></description>
        <link>https://medium.com/@oguzhankarakus?source=rss-51648632f5e9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wNPOEfnPcHpxgpq1ABqAnQ.png</url>
            <title>Stories by Oğuzhan Karakuş on Medium</title>
            <link>https://medium.com/@oguzhankarakus?source=rss-51648632f5e9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 13:28:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oguzhankarakus/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Distribute your XCFramework — How to create a XCFramework]]></title>
            <link>https://medium.com/plus-minus-one/distribute-your-xcframework-how-to-create-a-xcframework-cde8cdff00eb?source=rss-51648632f5e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cde8cdff00eb</guid>
            <category><![CDATA[xcframework]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-package-manager]]></category>
            <dc:creator><![CDATA[Oğuzhan Karakuş]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 09:59:32 GMT</pubDate>
            <atom:updated>2022-12-29T09:59:32.410Z</atom:updated>
            <content:encoded><![CDATA[<h3>Distribute your XCFramework — How to create a XCFramework</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZHRG9KMWXUA9jedc" /><figcaption>Photo by <a href="https://unsplash.com/es/@bugsster?utm_source=medium&amp;utm_medium=referral">Taras Shypka</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Are you tired of dragging &amp; dropping the same code to every new project you create? XCFramework is here to help! In this article, we’ll show you how to create and distribute your own XCFramework, making it easier to reuse your code across multiple projects.</p><p>At <a href="https://www.plusminusone.co/">PlusMinusOne</a>, we develop, maintain, and deploy numerous iOS applications. We often use Xib and Storyboard to create and layout view objects in our apps, but we also configure these views programmatically. This requires us to write the variable names of the view objects we have created frequently. To address this problem, we created auxiliary extensions for the view classes provided by UIKit, inspired by the Builder Design Pattern.</p><p>However, adding these helper extensions to our other apps by drag and drop seems a bit lazy. In this article, I’d like to tell you how to create a XCFramework and distribute it via CocoaPods and SPM.</p><p>Before we dive into the main topic, let me briefly introduce PMOUISetter to you. PMOUISetter is a useful framework that allows us to configure view objects we have created in a chain way. It is also easy to use. If you’d like to learn more about it, you can find it <a href="https://github.com/plusminusone-tr/PMOUISetter.git">here</a>.</p><h3>Why do we need framework?</h3><p>XCFramework is a powerful tool for iOS developers who are working on multiple projects and want to efficiently reuse their custom frameworks and libraries. By creating and distributing your own XCFramework, you can eliminate the need for copy-pasting code and save time during the build process. Additionally, because frameworks are precompiled, they don’t add extra load to your projects, resulting in faster build times. Consider using XCFramework to streamline your development process and make it easier to reuse your code across multiple projects.</p><p>So let’s start building the framework.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F0NwSQpGY6ipgOSt8LL%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F0NwSQpGY6ipgOSt8LL%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F0NwSQpGY6ipgOSt8LL%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="362" frameborder="0" scrolling="no"><a href="https://medium.com/media/04e653dd47d7cc4611fdb29d521abe63/href">https://medium.com/media/04e653dd47d7cc4611fdb29d521abe63/href</a></iframe><h3>Creating a XCFramework</h3><p>First, let’s click on <strong><em>File&gt;New&gt;Project</em></strong> via Xcode. The <strong>Choose a template for your new project </strong>screen will appear, let’s choose the <strong>Framework</strong> from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*R-o2Lq_6i85WVKT2sZDb7A.png" /><figcaption><strong>Choose a template for your new project</strong></figcaption></figure><p>In this article, I will proceed by choosing the team part as none.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*fOT17emlGeT4rcc5tUT9hg.png" /></figure><p>This is the final version of our very useful project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BdMS5II7Dn8BE55OAkKDvw.png" /></figure><p>I will proceed with Dynamic Library in this article. If you want to change it, you can find it by searching <strong>Mach-O Type</strong> under build settings.</p><blockquote>The Dynamic Library links when the application is first launched and increases the launching time, but does not increase the size of the application by much.<br>On the other hand, Static Library increases the size of the application but does not increase the application launch.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*hnoRf36lTbWdxwALjxtCpA.png" /></figure><p>For ABI stability, we need to set the <strong>Build Libraries for Distribution</strong> value to Y<strong>es</strong>.</p><blockquote>If we do not do this, when a new swift version is published, we will have to compile and distribute our framework in the new swift version.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*8IMCUW_-YZlnQkWrNm4H1g.png" /></figure><p>Finally, we need to archive our XCFramework for iOS devices and Simulators. I will share a script with you to speed up this process and not drown in terminal commands.</p><pre>#!/bin/sh<br><br># -------------- config --------------<br><br># Uncomment for debugging<br>set -x<br><br># Set bash script to exit immediately if any commands fail<br>set -e<br><br>moduleName=&quot;your-module-name&quot;<br><br>iphoneosArchiveDirectoryPath=&quot;/$moduleName-iphoneos.xcarchive&quot;<br>iphoneosArchiveDirectory=&quot;$( pwd; )$iphoneosArchiveDirectoryPath&quot;<br><br>iphoneosArchiveDirectoryPath=&quot;/$moduleName-iphonesimulator.xcarchive&quot;<br>iphoneosSimulatorDirectory=&quot;$( pwd; )$iphoneosArchiveDirectoryPath&quot;<br><br>outputDirectory=&quot;$( pwd; )/$moduleName.xcframework&quot;<br><br>## Cleanup<br>rm -rf $iphoneosArchiveDirectory<br>rm -rf $iphoneosSimulatorDirectory<br>rm -rf outputDirectory<br><br># Archive<br>xcodebuild archive -scheme $moduleName \<br>     -archivePath $iphoneosArchiveDirectory \<br>     -sdk iphoneos \<br>     SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES<br>      <br>xcodebuild archive -scheme $moduleName \<br>     -archivePath $iphoneosSimulatorDirectory \<br>     -sdk iphonesimulator \<br>     SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES<br><br>## XCFramework<br>xcodebuild -create-xcframework \<br>    -framework &quot;$iphoneosArchiveDirectory/Products/Library/Frameworks/$moduleName.framework&quot; \<br>    -framework &quot;$iphoneosSimulatorDirectory/Products/Library/Frameworks/$moduleName.framework&quot; \<br>    -output $outputDirectory<br><br>## Cleanup<br>rm -rf $iphoneosArchiveDirectory<br>rm -rf $iphoneosSimulatorDirectory</pre><p>Adding this script to the project directory and go to that directory in the terminal and run the <strong>sh GenerateXCFramework.sh</strong> command will be enough for us to create a framework.</p><p>We have finished our new XCFramework, now we can move on to the distribution phase.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o7btNa0RUYa5E7iiQ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7btNa0RUYa5E7iiQ%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExangyN3FpbTM2MHhqMHRzM2MwdG1kbHBvcG9teTh3anoybXQ0OGZvbiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3o7btNa0RUYa5E7iiQ%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/d001754c664e3f68da1a3ab6eb47009b/href">https://medium.com/media/d001754c664e3f68da1a3ab6eb47009b/href</a></iframe><h3>Let’s Distribute our XCFramework via CocoaPods</h3><p>Actually, distributing your custom framework through CocoaPods is quite easy. To do so, you will need to create a .podspec file in your project directory and include information about your framework, such as its name, version, and dependencies. In this case, the .podspec file would be named “VeryUsefulFramework.podspec”. Next, push the .podspec file and your framework to your GitHub repository.</p><p>You can edit this <strong>.podspec</strong> file according to your own case.</p><pre>Pod::Spec.new do |s|<br>    s.name         = &quot;VeryUsefulFramework&quot;<br>    s.version      = &quot;0.0.1&quot;<br>    s.summary      = &quot;VeryUsefulFramework: VeryUsefulFramework&quot;<br>    s.description  = &quot;your description&quot;<br>    s.homepage     = &quot;https://github.com/oguzhankarakus/VeryUsefulFramework.git&quot;<br>    s.license = { :type =&gt; &quot;MIT&quot;, :file =&gt; &quot;LICENSE&quot; }<br>    s.author             = { &quot;Oguzhan Karakus&quot; =&gt; &quot;your@mail.com&quot; }<br>    s.source       = { :git =&gt; &quot;https://github.com/oguzhankarakus/VeryUsefulFramework.git&quot;, :branch =&gt; &quot;main&quot;, :tag =&gt; &quot;#{s.version}&quot; }<br>    s.vendored_frameworks = &quot;VeryUsefulFramework.xcframework&quot;<br>    s.platform = :ios<br>    s.swift_version = &quot;5.7&quot;<br>    s.ios.deployment_target  = &#39;16.0&#39;<br>    s.requires_arc = true<br>end</pre><h4>We are ready to publish our XCFramework.</h4><p>To distribute your custom framework through CocoaPods, you will first need to register as a user on the CocoaPods website. After completing the registration process, CocoaPods will send you an email with further instructions on how to finish the registration. Simply follow the instructions in the email to complete the process.</p><p>Keep in mind that you will need to have a valid email address and GitHub account in order to register on CocoaPods. Once you have completed the registration process, you will be able to submit your custom framework for distribution through CocoaPods and make it available for installation by other developers</p><pre>$ pod trunk register orta@cocoapods.org &#39;Orta Therox&#39; --description=&#39;macbook air&#39;</pre><p>Then we enter this command, the magic happens :D</p><pre>$ pod trunk push</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ga9DiRmiRK9C4aOLMCTvkQ.png" /></figure><h3>Publish our XCFramework via SPM</h3><p>We only need <strong>package.swift</strong> file to publish our XCFramework via SPM.</p><pre>// swift-tools-version:5.6<br>import PackageDescription<br><br>let package = Package(<br>    name: &quot;VeryUsefulFramework&quot;,<br>    platforms: [<br>        .iOS(.v11)<br>    ],<br>    products: [<br>        .library(<br>            name: &quot;VeryUsefulFramework&quot;, <br>            targets: [&quot;VeryUsefulFramework&quot;])<br>    ],<br>    targets: [<br>        .binaryTarget(<br>            name: &quot;VeryUsefulFramework&quot;, <br>            path: &quot;VeryUsefulFramework.xcframework&quot;)<br>    ])</pre><blockquote>“// swift-tools-version:5.6” is not only comment line, it really defines <strong>swift tools version</strong></blockquote><p>When we pushed the package file to our repo on GitHub, we also distributed it with SPM.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FM3i6XHZUcBJc4JVtVE%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FM3i6XHZUcBJc4JVtVE%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FM3i6XHZUcBJc4JVtVE%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c16db2ea28846aafa5f190b8df1554f/href">https://medium.com/media/7c16db2ea28846aafa5f190b8df1554f/href</a></iframe><p>To learn more about our development experiences, you can have look at our <a href="https://medium.com/plus-minus-one">medium page</a>. At <a href="https://www.plusminusone.co/">Plus Minus One</a>, we love to learn and share our experiences. We hope this article makes your life easier 🙏🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cde8cdff00eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plus-minus-one/distribute-your-xcframework-how-to-create-a-xcframework-cde8cdff00eb">Distribute your XCFramework — How to create a XCFramework</a> was originally published in <a href="https://medium.com/plus-minus-one">Plus Minus One</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>