Xcode 7 Swift Framework Cannot import module being compiled - ios

My framework WebCoreDataStaticLibrary was working fine with ios 8.3 in Xcode 6.3. After I updated to ios 9 and Xcode 7 I am not able to compile my framework. This framework contain both swift and Objective C classes.
I have converted to To Latest Swift Syntax via Xcode
In any swift classes where I have imported WebCoreDataStaticLibrary its coming Cannot import module being compiled.
import WebCoreDataStaticLibrary Cannot import module being compiled
As a result I am not able to build the framework As a result getting this fatal error.
fatal error: lipo: can't open input file: /*/Developer/Xcode/DerivedData/A3WebCoreDataStaticLibrary-ctaegtiwmwhrsdeggeswpkjvucua/Build/Products/Debug-iphonesimulator/A3WebCoreDataStaticLibrary.framework/A3WebCoreDataStaticLibrary (No such file or directory) Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
Project Settings

It's telling you the problem. It can't find A3WebCoreDataStaticLibrary.framework/A3WebCoreDataStaticLibrary.
I even know why. There is no directory on your file system named /*/.
Something in your project settings is set wrong. My guess is your Framework Search Paths is wrong, or the Link Binary With Libraries section is wrong. Without knowing what's in your project settings, it's hard to tell.
UPDATE The screenshot shows a different error than the description.
At this point, you need to start digging. Go to that directory. Make sure that file exists.
If the file doesn't exist, you need to look at the A3WebCoreDataStaticLibrary target and see why it's not building the framework where you expect it to be.
If the file does exist, then you need to check the build order. It may be building the framework after it tries to build your app.

Related

CMFormatDescription.h Unknown type name 'AudioFormatListItem'

I have a very old iOS project that i'm trying to get back on the app store, using XCode 13.0.
When compiling it is giving me errors from within AVFoundation as in CMFormatDescription.h has an error
CMFormatDescription.h Unknown type name 'AudioFormatListItem'
Tracing the error back from AVFoundation it it comes down to the header where I actually import AVFoundation in a header file of one of my classes.
#import <AVFoundation/AVFoundation.h>
The project has AVFoundation and CoreMedia frameworks imported in the build phases so I'm not sure why it would be giving me compiler errors for code within the framework.
I ended up opening a code support case with Apple Support. The issue came down to having a folder in my build folder called CoreAudio.framework . That somehow ended up in a folder with all my classes which was contained in my compile path.
Deleting this folder and its contents allowed the build to complete successfully.

My app does not find sirikit intentdefinition classes in xcode 11.4

My app has had support for a couple of siri shortcuts since it came out, haven't touched it in a long time. My project compiles and builds in 11.3.2 but doesn't in 11.4.
The errors i get is that the classes that are supposed to be generated from my intentdefinition file, and that i am referencing in my intenthandlers are no longer found.
For example, in my intentdefinition file i have a custom intent called "MyStatus".
I then have a MyStatusIntentHandler:
#import "MyStatusIntent.h"
#interface MyStatusIntentHandler<MyStatusIntentHandling> : NSObject
In 11.4, i get an "MyStatusIntent.h" file not found. In 11.3.1 and earlier it builds fine.
I am not super great at project config and structure, so i'm a bit at a loss as to where to start digging. If anyone has any pointers, and what in 11.4 that might be new and giving me problems, I'm all ears.
I've had a similar problem in mixed swift+objc project.
There is a file 'Intents.intentdefinition' in my project for a separate Siri Extentsion target.
Also, this file is included in the compilation of the application target (for using generated classes in adding intents with UI).
Siri Extenstion target builds successfully.
But Application build fails with error: "'AnyIntent.h' not found", though those files were generated (I've checked).
I solved this issue only by changing the build setting of the Siri Extension target
Intent Class Generation Language (INTENTS_CODEGEN_LANGUAGE)
from Automatic to Swift
All imports of the previously generated intents header files I changed to
#import <SiriIntents-Swift.h>
I have this problem too.
After updated XCode get build failed with "error: use of unresolved identifier" for classes from *.intentdefinition file.
with terminal build I had this message:
2020-03-26 17:11:21.874 xcodebuild[28391:166707] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEIntentBuilder/IDEIntentBuilder-16029/IntentsBuildSystem/XCCompilerSpecificationIntents.m:46
Details: Code generator extension identifier unexpectedly nil for <DVTDeclaredPrimitiveFileDataType:0x7f888398b950:49:'com.apple.sirikit.intentdefinition':'Intent Definition':-*-*-------**-----*--*----*----------------------*-------------->
Object: <XCCompilerSpecificationIntents: 0x7f88838a4540>
Method: -createCommandsforInputs:withMacroExpansionScope:
Thread: <NSThread: 0x7f8892390940>{number = 13, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **
now I downgrade Xcode and add feedback to the https://feedbackassistant.apple.com/feedback/7640678
I have dug around, and also talked to Apple Support. Turns out, it has to do with the "legacy build system".
Once i switched to the new build system in xcode project settings, i could build the project again. I would argue that if they still support the legacy system (which they do), it should work, but oh well.
Read how to switch here:
https://help.apple.com/xcode/mac/current/#/dev396bc94c7
Stumbled upon this problem on XCode 12.4 while trying to add a ConfigurationIntent for an iOS 14 widget, and in my case the problem wasn't that the code generator was erroring out. Turned out it actually worked just fine, but the names of the classes it created were prefixed with an "Objective-C Class Prefix", (because of some Obj-C legacy project setting, or whatever) and the boilerplate code generated by XCode which referred to it was oblivious to that step and kept looking for a ConfigurationIntent class that was nowhere to be found. Changing INTENTS_CODEGEN_LANGUAGE didn't help with this either.
Anyway, in the end I had to delve into:
DerivedData/<ProjectName>/Build/Intermediates.noindex/<ProjectName>.build/Debug-iphoneos/<TargetName>/DerivedSources/IntentDefinitionGenerated/Intents
which is where I found my intent class file, and its actual name in the form of <ObjCPrefix>ConfigurationIntent. I replaced the references to ConfigurationIntent with this, and the errors finally disappeared.

Xcode does not find framework after closing

i have a swift XCode project and i want to import Chartboost framework inside it. it works fine when i import the framework but when i close XCode and re-open, it gives error and says that could not find the files although the files are right there. here is the error :
'Chartboost/Chartboost.h' file not found
Failed to import bridging header '/..../project-Bridging-Header.h'
there are other frameworks inside the project but they do not give any error. i have to delete the framework and then copy it every time i close XCode. how do i fix this ?
1.Please check the Framework Search Path in Target .If this frame work exists in folder name with space for example "Silly Things" .Then it will take two lines.So you have to give the name "Silly\ Things" in Framework Search Path.
2.If you are removing and adding again and again.Then it is just appending again and again in framework path.
So if you are closing and then opening it is not finding with suggested path and might be ending with this error.

How to build iOS framework with XCode 6

I know of familiar tutorials on this, but introduction of framework XCode 6 template has changed the game.
I already watched WWDC 2014 video about building modern frameworks but it talks more about building extensions, framework & app all inside single project. It does not specify if the framework I make with it is truly reusable across any project.
I am building framework the XCode 6 way (File->New Project->Framework and Library->Cocoa Touch Framework), but when I import it inside my test app project (separate from framework project) - I keep getting various errors.
Example: Include of non-modular header inside framework, and so on.
I know this is not what it says, and there are quite some missing steps in whatever I am doing. The older tricks may have worked for everyone, but I simply don't find which way to follow after XCode 6.
For example, there is some folder structure that a framework needs, but XCode 6 doesn't comply to it while building it. Is it right? If not, how can I change the way the XCode builds framework folder hierarchy?
Do I go back to old school or am I screwing some tiny thing in XCode 6 that I am unable to create a reusable framework?
I am not sure if you are trying to build a framework with Objective-C or Swift as your question doesn't state it. I've encountered errors you are mentioning with Swift so I'll give you my method to build Swift frameworks.
I found the process for Objective-C to be very straightforward and well documented, so I'll skip this.
As for Swift, there are a few things to consider. First, Swift static libraries are not supported, so you must exclusively use a framework (aka dynamic library) when linking an app to a library.
Here are the steps:
Create the Framework using New > Project under IOS > Framework & Library, select Cocoa Touch Framework
To avoid the "ld: warning: directory not found for option..." goto Library Search Paths in Build Settings for your target and delete the paths.
You can't mix Objective-C with Swift so don't even consider adding the Swift-Header bridge file in your code.
There are some cases in swift where you need to import code from unexposed Frameworks. I've successfully used the module-map inside the framework to deal with these case.
I also select CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES in the Build Settings to solve 'include of non-modular header inside framework module'. That seems to work
I make sure that the header file that gets generated is marked as Public (not Project). Click on the file and you'll see the selection in the inspector under 'Target Membership'
You may run into some bizarre error messages when building. Xcode has a tendency to report linker errors when your code can't compile correctly resulting in missing files the linker needs to output its binaries. Sometimes XCode won't show the errors in the files you are compiling and you need to go manually on the build output and go back to the files. Some other time, you'll get a problem where you need to delete the cache. Those issues I call XCode blues and deal with it constantly. I found this type of problems happens more often when building libraries. The rest should work as expected.

How to import own classes from your own project into a Playground

Assume a setup like this:
You have an Xcode 6 project, where you've implemented your own classes (say MyView and MyViewController) with both Objective-C and Swift
You have added a Playground into your project
In the Playground, it's possible to import modules (frameworks) like UIKit with the import keyword. How do you enable access to the project's other classes from the Playground?
Just trying to access project classes directly results with an error message:
Use of unresolved identifier 'MyView'
As of Xcode 6.0 Beta 5, it is now possible to import your own frameworks into a playground. This provides a way to share code between your applications and playgrounds, which can both import your frameworks. To do this:
Your playground must be in the same workspace as the project that produces your framework. Your workspace must contain a target that produces the framework, instead of using a pre-built framework.
You must have already built your framework. If it is an iOS framework, it must be built for a 64-bit run destination (e.g. iPhone 5s), and must be built for the Simulator.
You must have an active scheme which builds at least one target (that target's build location will be used in the framework search path for the playground).
Your "Build Location" preference (in advanced "Locations" settings of Xcode) should not be set to "Legacy".
If your framework is not a Swift framework the "Defines Module" build setting must be set to "Yes".
You must add an import statement to your playground for the framework.
Once all these conditions are fulfilled, importing your framework will work in a playground.
In Xcode 7 we introduced another mechanism that you can use to import your own classes as source, instead of importing a framework; you can read about this "Auxiliary Sources" support at http://help.apple.com/xcode/mac/8.0/#/devfa5bea3af
I actually managed to refer to other Swift files in the current project by doing this:
Create an empty Playground and place is somewhere under your project.
Open the YourPlayground.playground bundle (yes, it's a bundle = directory) in Terminal.
Edit contents.xcplayground for example with vi and add another section like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='3.0' sdk='iphonesimulator'>
<sections>
<code source-file-name='section-1.swift'/>
<code source-file-name='section-2.swift'/>
</sections>
<timeline fileName='timeline.xctimeline'/>
</playground>
Rename section-1.swift to section-2.swift (if you created the Playground from scratch, there should be an example section-1.swift in your bundle)
Add a hard link (symbolic link doesn't seem to work) named section-1.swift which will point outside the bundle to your Swift class file like:
ln ../../Classes/MyView.swift section-1.swift
Close Xcode and open the Playground again.
Now there should be two sections, one with the contents of your Swift class file and the other one with the example content you got from creating the Playground from scratch.
This way I can actually run code lying outside the Playground, but Xcode seems to crash more often when doing it like this.
Edit:
As of Xcode 6 beta 5 you're now able to refer to project files, as Rick Ballard instructs in his answer.
Since Beta 5 of Xcode 6 it is possible to import your code if it is in a framework. What you need to do is create a framework target, add the Swift files there and in your playground do
import ModuleName
You can look up the module name in the build settings. It's usually the same as the target name.
Remember to make the code you want to see public. You'll need to build the project before changes are available in the playground. (You'll also need to edit the playground to trigger re-execution.)
Important
Do not give the playground file the same name as the target! If you do, importing seems to work but you'll get the following error when the playground tries to execute:
Playground execution failed: error: Couldn't lookup symbols:
I wasted an hour on figuring that out. :)
I wasn't able to get it working using any of the answers here, so I started playing around and found a simple way that worked for me to import a swift class into a playground.
Just create a playground in your project, theres a directory inside it called 'sources', just drag a copy of the swift class into that folder and the playground then will have access to it.
For example:
I just put links to all my swift files in the Sources folder:
cd /path/to/project/MyPlayground.playground/Sources
ln -s ../../*.swift .
This way changes in your source file will take effect in your playground immediately. Worked very nicely.
Xcode 8.2, Swift 3.0.1, macOS Sierra
All you have to do - is write in the beginning:
import ModuleName
(assuming your playground placed in the same workspace as framework/project)
If it's doesn't work:
Rebuild your project
Recreate playground and copy all from old playground there
It solves a lot of strange errors with failed init's and imports of whatever!

Resources