3

We have two different apps : one for iPhone, and one for iPad, which are not linked using workspace. So, think of them as being in two different unlinked folders.

Now, I have created an iOS framework (Cocoa Touch Framework) which I want to include it in both iPhone and iPad. So, as per tutorials I encountered, I created a reference to the Xcode-Project file of framework in the iOS App project, but when I follow the next step i.e. to "Add Target Dependencies", this framework is not shown.

I don't know how to proceed. I want to include the framework to both without creating further copies of Framework.

Thanks in Advance.

Shubham Aggarwal
  • 41
  • 1
  • 1
  • 5
  • You can go through the video https://www.youtube.com/watch?v=HmfEuhb8Lls this may help you . – Reshmi Majumder Feb 02 '16 at 09:02
  • This is the normal way that I am aware. I was thinking to avoid this as I had to always find the .framework folder and then add it to the project whenever anything is changed in the .framework folder – Shubham Aggarwal Feb 02 '16 at 12:26

5 Answers5

2

Target>Project>Build Phase>Link Binary with Libraries>Add items(+)>Add Others>Path to external framework.

enter image description here

BADRI
  • 643
  • 8
  • 26
2

I add more information. Make sure that:

1 Target>Project>Build Phase>Link Binary with Libraries>Add items(+)>Add Others>Path to external framework.

2 Build settings > Framework Search Paths > add the framework parent path

Based on the two setting , you can link the external framework outside project.

Victor Choy
  • 4,006
  • 28
  • 35
  • Xcode is so awful. I click and drag the framework from group of "Products" from the library workspace to the "Frameworks, Libraries, and Embedded Content" of my test project, and it appears to work: it adds the framework to the group of "Frameworks". I click on that, it accurately shows the full path of the framework. The build fails because the framework search path isn't set. Xcode "knows" where it is, but it can't "find it". Thanks – neuralmer Jan 04 '21 at 22:12
1

Add the custom framework in the Embedded Binaries as following picture. Because it is not a system framework, it needs to be copied into the application bundle.

About embedded binaries:

The image

Community
  • 1
  • 1
AechoLiu
  • 17,522
  • 9
  • 100
  • 118
  • 1
    You mean "copied into the app bundle" not "copied into the project", right? – trojanfoe Feb 02 '16 at 09:21
  • Doing this means, whenever you are making changes in the framework, you need to add it again. This way needs more managing. I was looking to add it as a subproject framework but with external folder. – Shubham Aggarwal Feb 02 '16 at 14:14
  • @ShubhamAggarwal No, you don't need to add it again after any changes. It means the application bundle needs binary of that custom framework. If it is a system framework, the binary of framework can be found in the mobile device, but if it is a custom framework, it is impossible to find the binary of framework. So, the binary of framework needs to be included in the application bundle. – AechoLiu Feb 03 '16 at 03:11
  • @ShubhamAggarwal If you add the custom framework which located in the path '/User/xxx/A', after you change your custom framework, you need to sync the built framework to '/User/xxx/A'. You can write some scripts to do such things automatically. – AechoLiu Feb 03 '16 at 03:28
  • @Toro: That do seems a solution. But it won't work great in case of a team. Because the path of framework generated is dynamic. Take the case, if i delete derived data. But this thing may work if that script finds that dynamic path automatically. I don't know if the "Run Scripts" option in Xcode will help. – Shubham Aggarwal Feb 03 '16 at 06:57
  • @ShubhamAggarwal The `Run Scripts` will work. I had written a run script to do such thing. Copy the built framework to a folder. – AechoLiu Feb 03 '16 at 07:01
  • @Toro: Was working on that only. Great Solution. Thanks. – Shubham Aggarwal Feb 03 '16 at 07:14
  • Anyone have script to add external reference framework to ios project – nitin kachhadiya Feb 20 '19 at 04:29
0

Adding to @AechoLiu's answer, with Xcode 11.1, I had to set the Framework's Embed column to Embed & Sign, otherwise the Framework won't be bundled.

kakyo
  • 10,460
  • 14
  • 76
  • 140
0
  1. Add external framework

  2. Build Settings > Framework Search Paths

  3. Find the related path and update it with "recursive"

Muhammed Tanriverdi
  • 3,230
  • 1
  • 23
  • 24