compilation error when porting AudioKit iOS app to Catalyst macOS app - audiokit

I have an iOS app that has been working fine with AudioKit's iOS build. I wanted to try porting to macOS w Catalyst by dropping in AudioKit.xcframework. Here is what I did
compile AudioKit-4.9.5 from source to generate AudioKit.xcframework (I had previously been using a locally compiled AudioKit iOS framework from the same source release with no issues on the non-Catalyst version)
in the "General" tab,
checked Mac as a deployment target
removed the old AudioKit iOS framework
added AudioKit.xcframework
in "Build Settings" tab,
change "Framework Search Paths" from the parent directory of the AudioKit iOS framework to the parent directory of AudioKit.xcframework
in the "Build Phases" tab,
AudioKit.xcframework appears in "Link Binary with Libraries"
AudioKit.xcframework appears in "Embed Frameworks"
I receive the following errors,
Currently using Xcode 11.4.1.

Answering my own question here since this issue seems to be an artifact of the AudioKit module containing a AudioKit class. Renaming AudioKit class to something else fixes the issue although I'd discourage folks from doing this and instead waiting for a future AudioKit release that does this.

I had the exact same problem. I ended up editing the x86_64-apple-ios-macabi.swiftinterface file and correct the interface by hand.
I only had to prefix AudioKit. in from of the identifier unresolved. It looks more like a bug with the XCFramework build configuration / the swiftinterface generator.
I also run into a crash at runtime when using AKSampler(). For some reason the compiler do not understand that .init() do not exist and that it should use the AKSampler(masterVolume: 1.0, pitchBend: 0.0, ... filterEnvelopeVelocityScaling: 0.0) prototype. Calling by hand with the default values fix it.
Edit: You do not need to explicitly call the long initializer, you simply have to remove the line:
#objc override dynamic public init()
from the #objc open class AKSampler : AKPolyphonicNode, AKComponent { section.
To summarize:
Edit the x86_64-apple-ios-macabi.swiftinterface in the XCFramework/
AudioKit.output and AudioKit.midi.client in place of the unresolved identifier.
If you use AKSampler, remove the line:
#objc override dynamic public init()
from the #objc open class AKSampler : AKPolyphonicNode, AKComponent { section.

Related

Error - "Class is unavailable : Cannot find Swift declaration for this class", while building app on iPhone 4s (iOS 9.3)

My App has been created under iOS 10.2, and when I'm trying to create a build of the app to run on iPhone 4s (iOS 9.3).
I'm using two frameworks :-
ViewModelExtensions.framework (github.com/jozsef-vesza/ExpandingTableView/tree/master/ExpandingTest/Carthage/Checkouts/ViewModelExtensions/ViewModelExtensions)
ExpandingTableView.framework (github.com/jozsef-vesza/ExpandingTableView) in my project.
I'm not able to create a built for my project. Its giving me 3 main errors as follows :-
ExpandingTableViewController is unavailable: cannot find Swift declaration for this class
ExpandingTableViewCell is unavailable: an not find Swift declaration for this class
Use of undeclared type ViewModelType
The thing is its perfectly running on all simulators supporting iOS 10.2. What shall I do ?
Here is the screenshot.Screenshot
My Code - Project
Reason your code not running is because one of the framework you have added Expandable tableView has minimum target requirement specified as 10.2 :) So you can not run it on anything less than iOS 10.2 :)
Now you can't change the frameworks minimum target, so change your projects development target :)
Solutions :
Change Development target to 10.2 in your project
Or get rid of the framework and find something that has minimum target as iOS 9 :)
We'll need more detail (code, did you use pods, etc.)
However, this looks like a problem with the referenced frameworks (I assume you've imported UIKit at least). I suspect (without seeing your code) that you're getting errors next to the frameworks above at build time. If so, there are a few things to check:
Make sure if you used cocoapods, you are using the 'workspace' and not the 'project' file.
Check and see if your "target membership" (you can see this in the inspector to the right of your class code) is set to the proper targets (i.e. your app - and probably nothing else at this point)?
If these checks fail, try re-installing the frameworks (again, depends if you used cocoapods or embedded them via Xcode (point 1 above)).

WatchOS 2 App fails to launch on device with dyld_fatal_error for my Framework Library not loaded: Image not found

I've just followed the apple transition guide to upgrade my ObjectiveC app to WatchOS 2
https://developer.apple.com/library/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/ConfiguretheXcodeProject.html
With the section "Sharing Code Between an iOS App and a watchOS App" describing how to duplicate an existing iOS framework into a WatchOS framework target for use by WatchOS as follows.
"If you already have a watchOS 1 app that shares a framework with your iOS app, duplicate your iOS framework target and modify it to support watchOS 2.
To duplicate and configure your framework target for watchOS 2
Open the project editor pane of Xcode. (The pane is normally closed.)
Control-click the target to display a context menu with a Duplicate command.
Change the name of the target so that you can identify it easily later.
In Build settings, change the following values:
Change the Supported Platforms setting to watchOS.
Change the Base SDK setting to the latest watchOS.
Change the Product Name setting so that it matches the name of your iOS framework. You want both frameworks to be built with the same name.
Add the framework to your WatchKit extension’s list of linked frameworks."
I've followed these steps to clone my framework which with the iOS framework was called MyFramework, and now the new WatchOS framework is called MyFrameworkWatch. But as described above the Product Name is set to MyFramework instead of MyFrameworkWatch. I presume this naming shift is so that I can include from my framework using
#import <MyFramework/SharedUtils.h>
instead of presumably having to change it to
#import <MyFrameworkWatch/SharedUtils.h>
I wouldn't mind the latter but I'll admit its nicer keeping the framework name the same.
After a bit more work beyond the initial automatic transition I managed to get my app working perfectly well on the simulator, but now switching to device i just can't get it to launch.
Launching my app on the device causes it to spin for a few seconds and then just crash. Launching the glance just causes it to spin indefinitely. Trying to run it from Xcode and running the app causes the app to eventually launch and spin, the spinning can last indefinitely sometimes, but eventually it gets through and i get the actual error reported as follows
dyld_fatal_error - dyld: Library not loaded: #rpath/MyFramework.framework/MyFramework referenced from WatchKit Extension Reason: image not found
So this is my Watch App Extension trying to link to the Watch framework, and doing so looking for the MyFramework name, not the MyFrameworkWatch name. I wonder if this name clashing has caused it to get confused?
When I try to find the frameworks referenced under the Products folder in Xcode I can see two frameworks
MyFramework
MyFramework
they're both reference the same path
/Users/jim/Library/Developer/Xcode/DerivedData/MyApp-byegspjumgwlfpahhwjgzpmfkcdx/Build/Products/Debug-iphoneos/MyFramework.framework
though you can see the target membership is separating the two frameworks, the top MyFramework is associated with the main app, today widget and framework tests project. The lower MyFramework is just associated with my Watch extension. It doesn't feel right that these are referencing the exact same path surely?
Finally when googling for this issue I've found reference of CocoaPods having similar problems though according to their site here
https://github.com/CocoaPods/CocoaPods/issues/4180
It's been fixed since September in version 0.39.0, which is the version that pod --version reports. So I presume I have their fix. I'm tempted to remove the cocoa pods from my framework to see if it helps.
Has anyone else followed the transition guide suggestions for creating a duplicate framework and then managed to get the app and framework actually installing on their watch ok?
Is there any way to analyse the build that is done to try and see if i can see problems with the built files so i don't have to wait for the watch to fail to launch the app to debug it.
Any help is really appreciated as always! Cheers!
Edit: I think I've managed to remove cocoa pods from the offending MyFrameworkWatch target by commenting out the target section in my pod file and running pod update/pod install... it didn't seem to clean up the target very well so i had to manually remove the cocoa pod steps in the post build step. Maybe i've not removed it properly, i find it a little confusing to know what is going on under the hood with cocoa pods. Regardless the same error occurred, so either i didn't remove it properly or it has no effect on this particular problem
Ok, this was caused by the apple documentation for transitioning being wrong, or me interpreting it wrong. It says
Add the framework to your WatchKit extension’s list of linked frameworks.
Where as actually the correct fix was to add the framework to the embedded binaries section (which automatically adds an entry to the linked frameworks anyways) and correctly places the framework within the watch extension under a Frameworks directory. Which the app then loads fine! So much frustration, I lost hours to this across a few days!!

Cocoa Touch framework shared between iOS and tvOS

I'm working on an app that can have some shared code that I want to encapsulate in a framework. I created iOS Putter app target, then a framework PutterKit that I link from the app. This works fine.
Then I create a tvOS app target PutterTV and duplicate the PutterKit to PutterKit (TV) and set its sdk to tvOS
When I import PutterKit in the tvOS app and compile it, I get the error
No such module 'PutterKit'
Here is a sample project
https://dl.dropboxusercontent.com/u/1326174/Putter.zip
What is the correct way to setup such a framework?
Looking at your project, you need to:
import PutterTVKit
If you look at your PutterKit(TV) target build settings, you will notice that the ProductName and ProductModuleName are PutterTVKit.
Also make sure that in the Linked Frameworks and Libraries section in PutterTV app target, you link in PutterTVKit.framework (not PutterKit.framework).
With these changes, it appears to compile fine.

after upgrading to xcode 6, OpenGLES/gltypes.h not found

I'm having an issue compiling my iOS code which was building with the earlier version of XCode.
I import UIKit/UIKit.h in my prefix header file, which with iOS 8 SDK cascades down to including CoreVideo/CVOpenGLESTexture.h, and from there OpenGLES/gltypes.h. In the preprocessor stage, XCode complains that the file gltypes.h is not found.
In the Search Paths for the Target, I've ensured that the Framework Search Paths and Header Search Paths are pointing to the location of the SDK installation. Also, "Always Search User Paths" is set to Yes.
Anyone else seen this issue? "Linked Framework and Libraries" has OpenGLES.framework above "CoreVideo.framework" or any other linked frameworks.
Update
XCode 6 was installed as an update from App Store. Also tried uninstalling XCode (by dragging app to trash), and re-installing from App Store. Did not help.
Update
I removed the prefix header file, and set "Precompile Prefix Header" to "No", deleted the cache where xcode would place the precompiled information. Still no give.
Now where ever UIKit/UIKit.h is imported, this error is thrown.
So here's what I did to get over this:
Quit XCode
Removed all reference to OpenGLES.framework from the .xcodeproj file
Restarted XCode, and opened the project
Deleted all derived data (Windows->Organizer->Projects->Derived
Data->Delete)
Let XCode re-index
I know this was asked some time ago, but I just had the same problem and fixed it.
I was working on an iOS app I inherited, and somehow they added the OpenGLES framework to the root of their source folder, and it was that version of OpenGLES framework that they added to the project as a linked framework instead of the one provided by the SDK.
So I removed that from the "Linked Frameworks and Libraries", and added the one supplied by the SDK. Stopped getting that error after doing so.

Could not instantiate class named MKMapView

I may be doing something really stupid here as I've done it before and it worked and now...
Created a new iPad project, in the details view I added a MKMapView, added the MapKit.framework to the project, added the property / etc. to the header. Go to run the project and get a SIGABRT with
****Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate
class named MKMapView'**
I found http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial/ but, like I said, I've already added framework. What am I missing?
I ran into this too, but I was able to get past it by following the instructions of step 2 in your link (thanks, by the way):
Add the MapKit framework to the project. (Control + Click Frameworks
folder -> Add -> Existing Frameworks)
I just searched for MapKit.framework, added it to the project, and the error went away.
I haven't added any map code yet (although I do have a MapViewDelegate connected in IB), but it's working fine so far!
Click on your project to bring the project settings. Under Targets, click your project, select from the upper toolbar "Build Phases". Under "Link binary With Libraries" tab, you will see the list of frameworks included in your project. Click the "+" button and add MapKit library from the shown list to your project.
For Xcode 6.1:
Select your project
In general tab, look for Linked Frameworks and Libraries (last one)
Press + button
Search MapKit.framework
Finally add
Easy way!
Works above Xcode version 7.2
As far as I'm concerned selecting the MAPS from capabilities will automatically link your framework to your project all you have to do is check the Maps button in Capabilities -> Maps.
Heres the attached screenshot. Cheers!!
For xCode 4.2:
Click on your project name ->targets ->building Phase ->link binary with library
-> click on + sign ->select mapKit.framework ->click add
I noticed that I was getting this message (on top of the original one mentioned in this post) when I was building and running on the simulator:
ld: warning: ignoring file
/Users/peter/programming/iPhone/iNspector/MapKit.framework/MapKit,
file was built for unsupported file format which is not the
architecture being linked (i386)
Then I just connected my iPhone, build and ran on the device, and the map worked.
So it seems that the MapKit framework cannot be compiled on the 386 architecture, it needs the device.
In regards to #futureshocked's input, I also came across the
Id: warning: ignoring file /blah.../MapKit, file was built for unsupported file format which is not the architecture being linked (i386)
issue.
**Check to make sure you didn't copy the MapKit framework into your local project directory when you added it to your project. I accidentally did this and XCode was giving me the above error. So I removed it from my project directory (in Finder), recompiled, and everything was normal again.
If you don't have the Framework in your project, go ahead and re-link as stated in the answer above.
Found a good tutorial on getting started with MapKit:
http://www.youtube.com/watch?v=X-3jM24EIGM&feature=related
I also received this error when trying to deploy to my 5.1 phone (with XC 4.5), even after changing my deployment target to be 5.1. Looks like the maps update wouldn't fly since I still had Google Maps on my phone. After updating my phone's OS, the exception disappeared.
Please import the WebKit at your Build Phases.

Resources