How to make XCFramework take into account the extra info.plist fields - info.plist

I need to embed this library https://github.com/securing/IOSSecuritySuite into my own XCFramework module as dependency but there are two problems.
First, since I want to use my framework as binary, all of its dependencies must have the 'Build Libraries for Distribution' property set to 'Yes'. It can be achieved by placing all IOSSecuritySuite sources in separate XCFramework, setting the above property and adding it as dependency. Should work.
Second, the IOSSecuritySuite guide requires updating the main info.plist file of a project that uses this library by adding these lines:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>undecimus</string>
<string>sileo</string>
<string>zbra</string>
<string>filza</string>
<string>activator</string>
</array>
(Actually it's demanded by Apple documentation when you use the canOpenUrl method)
But I want to encapsulate all the functionality in a framework so that no additional project configuration is required. And here's the problem. If you open your XCFramework in Xcode you can see 'Info.plist Values' in Build Settings of each target and project but they don't allow you to add new fields. I didn't find any other info.plist there. One info.plist file is created when you convert your framework in an archive, but its only function is simply to describe the package. So I don't know how to add these info.plist lines to the framework so that it will take this into account. I suspect if I just put my custom info.plist in the framework folder it won't work. Probably I don't know some elementary things. I will glad for any hints :)

I figured out:
"Info.plist Values' in Build Settings of each target and project but they don't allow you to add new fields" - you can add fields to the "info" section of the project. This will automatically create physical info.plist in your project folder and framework will see it.
2.macOS is the only one of our platforms that supports nested frameworks https://developer.apple.com/forums/thread/128117 so you are forced to mix all sources in one framework.

Related

failed to emit precompiled header

Good Afternoon
I am trying to implement googles heatmaps into my map based project.
In this particular project, I get the following errors when trying to build.
failed to emit precompiled header '/Users/zachwilcox/Library/Developer/Xcode/DerivedData/OddJobs-gbnkfettubuccoheinzfovrqefub/Build/Intermediates.noindex/PrecompiledHeaders/OddJobs-Bridging-Header-swift_3WGH9SNI96Z2-clang_16JN3VASQHE4C.pch' for bridging header '/Users/zachwilcox/Desktop/OddJobs/OddJobs-Bridging-Header.h'
and a follow up that says
'Google-Maps-iOS-Utils/GMUHeatmapTileLayer.h' file not found
I'm not sure why this is happening because I created an entirely new project and did the same implementation and it worked perfectly. But when I run it on my existing project I get these two errors.
I have been researching this problem for a while now and I can't figure out what the problem is. I have the Bridging header set to the .h file.
I have tried most steps that individuals have tried to give with their answers but for some reason, it's not working for my project. Thank you in advance. When reading googles installation guide, it said that all I needed to add was one bridging header file which is the code you see in the image below. When researching it, I have seen that I needed to add a .m file as well however I still get the same error when I do. again, in my dummy project, I don't have the .m file just everything you see below and everything compiles.
There are chances you have 'Find Implicit Dependencies" turned off for the selected Scheme. If you have updated/installed pods and try to build the project, it will more likely fail if this option is unchecked for the selected Scheme.
From Apple's Document:
Parallelize Build – This option allows Xcode to speed up total build time by building targets that do not depend on each other at the same time. This is a time-saver on projects with many smaller dependencies that can easily be run in parallel.
Find Implicit Dependencies – This is a very powerful option that allows Xcode to resolve what targets need to be built for the primary target of the scheme to be built successfully. However, this does come with some sharp edges that you have to be aware of.
Situation: You link a library against your application target and create an implicit dependency to that library’s target.
Scenario 1: “Find Implicit Dependencies” is enabled.
Result: The library will get built prior to building the application target. The application target will then link against the library and build successfully.
Scenario 2: “Find Implicit Dependencies” is disabled.
Result: The library will not get built prior to building the application target. The application target fail to build.
Fix: To ensure that the second scenario does not happen, you must add the necessary targets into the targets list and order them correctly.
If your project includes pod then you've to set the pod configuration for the test project too..
Select Root Project in File inspector -> Project Name -> Info -> Configurations
Set configuration for your test project same like your main project

Multiple Metal shaders with different language versions in one project

I'm trying to include multiple Metal shaders in my Xcode project which have different language versions, but I'm unable to figure out how to do it.
I'm trying to do this, so I can support the latest features when available and drop back when not.
In the project's settings I can only find a general specifier for the Metal language revision. I also can't find anything in the MSL reference manual to specify it inside the file.
Is this even possible? If so, how?
Thanks in advance.
In Xcode, go to the Build Phases for the target which builds your app. Disclose the compile sources. Select a .metal file. Double-click in the right-hand Compiler Flags column to edit it. Enter -std=osx-metal1.2 or similar. That specific shader source file will be compiled with that language.
I found this compiler flag by comparing the build transcripts of builds with various settings for the target-wide build setting.

Embedded Framework conflict with version located outside the bundle

One of my Mac applications contains a framework which I embed into the application bundle. Now I have found some evidence that on some customer machines the application links against the same framework located in the /System/Library/Frameworks folder.
I'm obviously missing something when it comes to linking the embedded framework to the application in XCode, so here's how I've done it.. and perhaps you can point me to the missing step:
1) I drag the framework project into my project and set up the dependency between both projects
2) I drag the build product of the framework project to the "Link Binary with Libraries" build phase of my target
3) I drag the build product of the framework project to the "Copy Framework Files" build phase of my target set to "Destination: Frameworks"
This all works great but somewhere I need to specify that I want to link with the embedded version of the framework rather than any framework version that might be found on the system. Is there a search path to be set somewhere? or "static" link?
Any help would be appreciated.
Best regards,
Frank
Sounds like you might be missing a key step. You also need to set the "install name" of your embedded framework.
When you link a framework or dynamic library, your app will look for the framework at the path specified by framework's install name. This should specify a relative path for embedded frameworks. If it is an absolute name it will pick up the system installed version, even if you've embedded the library.
To examine the install name do the following and look at the first location.
otool -L <framework-binary>
These two blog posts explain the issue and also how to set everything up properly:
http://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
http://www.dribin.org/dave/blog/archives/2009/11/15/rpath/
Additionally, if you're compiling a dylib from the command line (say an open source library) just add the following to your CFLAGS to set your install name.
-install_name '#rpath'
If you want to modify an existing binary's install name use 'install_name_tool'.
Also be sure your copy files build phase is copying the right files into the right places in your app bundle.

How do I change an existing Xcode target from dynamic to static?

I'm working with an existing project that produces a dynamic library (Cocoa API).
I'd rather generate a static library, but if I change the
[Linking|Mach-O Type] field from "Dynamic Library" to "Static Library",
both the Clean Project and Build Project complain that the
target has an invalid MACH_O_TYPE value of 'staticlib'.
Is there a straightforward way to get the build to produce
a static .a file?
Thanks,
Eric
Opens up the project.pbxproj file in YourProjectName.xcodeproj folder using TextEdit, search for productType and change it's value from "com.apple.product-dynamic" to "com.apple.product-static"
I ended up creating a new 'static library' project, and then added all
the members. Closing xcode and bringing up the two project files in
a text editor let me quickly complete the new project.
I managed to do this, with the help of this post and a bit of digging around. Additional changes I had to make were changing compiled.mach-o.dylib to archive.ar and changing various references in the project file (including inside comments, call me pedantic) from foo.dylib to libfoo.a.
I also had to create a new 'scheme' before it would build, but that might be because I changed the name of the project, I'm not sure. Also, any frameworks referenced by the library need to be added to the application(s) that link against it when you move from .dylib to .a.
It was well worth persevering though as it preserved all the subtleties of the original project (such as building a 32/64 fat binary for release but not for debugging). Result.
Delete your build target, then create a new one, choose "Library" and make sure you choose type "Static". After this, you only have to add your sources and dependencies again.
You have to change two settings:
Under Library, set Mach-O Type to Static Library
Under Packaging, set Executable Extension to a
This worked for me on Xcode 13.1.

Adding a framework in Xcode

Im trying to add a third party framework in Xcode but I'm getting an error that it can't be found
error: MKAbeFook/MKAbeFook.h: No Such File or Directory
I've added it in the Linked Frameworks group and added it to the Target for this project. I've also added it to a new Copy Files build phase for that target.
Basically I've followed the instructions here: http://pointlesscrap.net/mkabefook/desktop/gettingstarted
Any ideas where I'm going wrong?
Best way to diagnose this is to post the compiler invocation line, not just the error (you can just drag and drop the line from the Build Results window that says "Compiling foo.m"). My expectation is that you don't have a Frameworks Search Path set up for the location of the framework. Xcode usually adds that manually when you add the framework, but if you put it in certain kinds of places, or added it in certain ways, you need to manually point your target's Framework Search Paths at its directory.
Perhaps the author mistook MKFaceBook for MKAbeFook?
EDIT: Never mind, it looks like that is actully the name of the framework.

Resources