Creating custom framework in iOS - ios

I am trying to create my own iOS framework for my project. I am following the below link to create it:-
Creating custom framework in iOS
I am not getting any error as well as warning but not able to see the content of Product folder generated during project creation.
I am facing problem in this step:-
To build, select the target as iOS Device and press cmd+B to perform the build. Once completed, the libRWUIControls.a product in the Products group of the Project Navigator will turn from red to black, signaling that it now exists. Right click on libRWUIControls.a and select Show in Finder.
Looking for all yours help and support on this.

Suppose you are using Xcode 6, and Apple has provided an easier way to create a custom framework.
You can refer to some instruction on How to create an iOS Cocoa Touch Framework using Xcode
And you may still encounter some problems while using your custom framework in your app.
Here are 3 tips to solve the problems you may face.
Add your public headers:
In your custom framework project, please select TARGETS->Build Phases->Headers->Public, and drag and drop your headers here.
Build a static library framework:
In your custom framework project, please select TARGETS->Build Settings->Linking->Mach-O Type, and select it as Static Library.
To fix Xcode “Missing Submodule” warning while import your custom framework in your app:
Please refer the solution here.
Enjoy your own framework.

There are several parts to this "step"
Assuming since frameworks are fairly advanced that building is not your issue.
This tutorial uses multiple targets. To choose which target you want to build you must select it from the drop down menu at the top left of your Xcode window. This is immediately to the left (and loosely tied to) the drop down for choosing the device/emulator type. The target selected in the drop down becomes the active target and will respond to the build menu and shortcut keys.
Once a target is built the object created by the build will be displayed in the XCode Project Navigator inside the folder named "Products" In the default view the left most panel in XCode is the Navigator panel. Selecting the folder icon at the top of this panel will display the Project Navigator and the projects file structure. This is where you will find the Products folder containing your newly created file.
If the file is still red then the build did not complete correctly.
If it is black then you can right click on the file and choose "Show in Finder" to see the file.
If the file remains red or as an alternative to finding the file location you can use the build log.
To show the build log - in the Navigation Panel select the "Report Navigator". This is the right most icon at the top of the panel and looks like a cartoon text bubble. In the Report Navigator highlight the "Build" Entry associated with your static library. You can now review the build log to determine why the target didn't build correctly or if it did build correctly you will see an entry near the end of the log showing the path of build files.

Related

How to export/get xxx.framework by using Xcode 11.4?

Before Xcode 11.4 I built project and I also could found xxx.framework in the path of xxx/Build/Products/Debug-iphoneos.
After using Xcode 11.4, I can't found any xxx.framework in that path.
I have seen the link, How to archive/export Framework in Xcode? I follow the step to get the framework but Xcode 11.4 doesn't.
Does anybody know how to get the framework by using Xcode 11.4?
Here's two methods.
Method 1 (The method you say is not working for you but most popular):
Clean your framework (Not necessary but good practice)
Shift + Command + K or Product > Clean Build Folder (Some ask: where is this Product. Just hover your mouse at the top of the screen whilst in Xcode, you'll see it there.)
Build your framework
Command + B or Product > Build
Export/Extract/Copy your framework
On the left panel of Xcode (Where you see all your folders and swift files), expand the folder that's named Products (tap on the little white arrow next to the folder Products to expand it and see its contents.)
Once you expanded the Products folder, you should see a very good looking framework staring right at you. The name should look something like this YourProjectName.framework
Now to finally answer your question - HOW TO EXPORT THE FRAMEWORK...well right click on the framework (the YourProjectName.framework) and click on Show in Finder.
Once you clicked on Show in Finder, you'll see your YourProjectName.framework folder. Yes yes, it looks like a normal folder. That's because it is. Everyone just makes it sound fancy.
And there you go. You can then just drag that fancy-ish YourProjectName.framework folder into you project.
Method 2 (Here I'll assume you already read method 1 so I'll explain with less detail):
Clean your framework (Not necessary but good practice)
Archive your framework
Product > Archive (Don't be surprised if you wait a couple of seconds for it to archive.)
Once it's done archiving. You'll see it opens a new Xcode like window. If you don't see this window, it means you were busy with other stuff on your mac at the time it finished. Don't worry haha, just look around on your mac until you find it. If you still don't find it, chances are the archiving failed. If it failed, Xcode will give you an error log. Read it, fix it, try archiving again.
Once it finished archiving and you see the Xcode-like window. Your archive will be highlighted. It just shows its selected.
Export/Extract/Copy your framework
Right click on the archive and say Show in Finder
The finder will open and have your archive selected.
Right click on that archive and select Show Package Contents
The finder will open your archives contents.
Navigate to your framework which is located under Products > Library > Frameworks
There you'll find your YourProjectName.framework folder. select that folder and drag it into your project.
If none of the above methods worked for you, I guess it opens the opportunity for you to find another way. When you do, come back to this answer and add your method so we all can learn.

What is causing Base Localization to create duplicate storyboard files?

I have an iPhone app that needs to be physically cleaned to prevent the following build error:
This is what I have in the Navigator:
And this is what I have in the Localization section of Build Settings:
It works, but I'm not sure this ever worked the way it was supposed to; it was written several (like 4) years ago. Now, I am trying to clean it up so I can convert it to a universal app (first I need to make sure it works as designed before making any drastic changes.)
Can someone please point me in the right direction for cleaning this up? (I.e. what files to delete, or ?)
Here is what probably happen in that project:
This xx.lproj file is a legacy. You should be able to find it in Finder but not in a Project Navigator. Like this:
This is only the internal structure of xcode so just remove references from project navigator for all this ``xx.lproj` groups without removing files from project and you'll be fine.
If the app stop building you may need to re-add this files to your target, to do this just select a "parent" storyboard and go to "File Inspector" (first tab on Utilities panel) and select desired target.

Xcode won't add "Embedded binary" after deleting "DerivedData"

Alternative titles to aid search:
Adding Embedded Binaries fails in Xcode
Xcode won't link framework from separate project
App crashes on device because of missing framework, works in simulator
Overview
After deleting the "DerivedData" folder (or performing a "Product > Clean") in xcode6, I cannot add CocoaTouch frameworks from another project to the "Embedded Binary" section (under General tab).
Or, Xcode hits a linker error because it cannot find a framework that if previously could.
Other symptoms
Clicking on the + under "Embedded Binaries" shows the Framework selector but selecting a framework in different project in the workspace does nothing.
When you add the framework to the Embedded Binaries, there will be a reference added to your project for it. If you select that reference after your steps above, you will probably find that it has an Absolute Path reference to the framework rather than a relative one, which we'd like. Change the location to Relative to Build Products and the reference should always be discoverable if do a "hard" clean or use another computer etc.
I have made a video which describes how best to add a built framework from one project to an app target in another sibling project.
This it the only way i have discovered to restore the embedded binaries, please leave comments if you find some steps are not required.
Prerequisites: Read Daniel Tull's answer.
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
Just to add to #Daniel's answer, if your Location dropdown is greyed out you may have selected the wrong file. Make sure to select the framework that's in your app project (not framework project).

How to share files between two xcode projects in workspace?

I learnt about Xcode workspace .I know how to share the static library but i want to share the files between two xcode projects in workspace and is it possible to run multiple targets at a time?Can you provide me the information of how to do this.
Thanks in advance
Sharing files between projects in the same workspace is easy, even if the projects are on the same level (no subprojects):
Assume you want to share constants between Project1 and Project2, and these constants are defined in a file SharedConstants.swift, which is defined in Project1.
In order to be used in Project2, it must be compiled there.
Thus, activate in the project navigator Project2, select the target and open the Build Phases tab.
Open there Compile Sources by tapping the little triangle left.
Tap the + button below the listed sources for this target. This will show you a list of files of Project2. There you cannot select your shared constants, because they do not belong to this project.
However left bottom is a button Add other…
Tapping it will open a standard file selection window where you can select SharedConstants.swift from Project1.
After tapping Open, a 2nd window opens with a Destination: Copy items if needed checkbox.
Important: Do not check this box!
If you would check it, a copy of SharedConstants.swift would be used in Project2, and any changes that you make in Project1 would not be visible in Project2. Instead, it you uncheck it, only a reference to SharedConstants.swift in Project1 would be used in Project2, and any changes will affect both projects.
To share the files you can probably use the bundles
Targets are manipulated with Schemes in Xcode 4, you can launch several targets in the same time if you select the different destinations (with OS X you can probably have the same destination :) )
You'll see a little triangle below the stop button indicating that you can long-press it to select which operation should be terminated:
You can switch the console with the popover at the Debug area where you see the target name and icon - that's a button.
You can drag Xcode projects into other Xcode projects to nest them.
More info here:
How should I manage dependencies across projects in an Xcode workspace?

How to update a framework in an iOS app?

I'm writing an app using Nuance's SpeechKit framework. I've just downloaded a newer version of the framework that contains new methods in some of the classes. To upgrade, I deleted the framework and the re-added the new one. When I right-click on the framework in Xcode and click "reveal in finder", it shows the new framework. When I open up the "Headers" subfolder of the framework in Xcode, I see the new methods.
The problem is that my class seems to still be referencing the header file in the old location, as the new methods are not visible within my application.
How do I upgrade a framework properly? Is there somewhere else in Xcode that contains a path reference to the SDK?
You need to delete Derived Data for the project - it is an option of the project in the XCode Organizer, on the projects tab. It will remove the cached build of the framework, forcing XCode to use the new one.
Choose Window/Organizer from the top menu
Click "Projects" pseudo-tab-thing, along the top of organizer window (icon looks like an XCode project file"
Select the project from the list on the left
Click "Delete" next to "Derived Data" in the area immediately below the project info header.
List item
EDIT: as of XCode 12 (should work with Xcode 8 and above), you can delete derived data like this:
Go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment.
Then click over the little grey arrow under Derived data section and select your project folder to delete it in Finder.
I found what cause this issue for us.
When you build a new version you must update "Current Library Version".
There is also a "Compatibility Version"
In Xcode selector your framework target and in build settings search for linking and you will se this setting there.
We created a build script to bump this version number every time we build.
Xcode caches the frameworks and uses the cache if possible. That's why you need to change this number.
If you are using CocoaPods, run pod update [PODNAME].

Resources