Audiobus: Use your music apps together.

What is Audiobus?Audiobus is an award-winning music app for iPhone and iPad which lets you use your other music apps together. Chain effects on your favourite synth, run the output of apps or Audio Units into an app like GarageBand or Loopy, or select a different audio interface output for each app. Route MIDI between apps — drive a synth from a MIDI sequencer, or add an arpeggiator to your MIDI keyboard — or sync with your external MIDI gear. And control your entire setup from a MIDI controller.

Download on the App Store

Audiobus is the app that makes the rest of your setup better.

Help for webview integration in AUV3

I've include a webview in a AudioUnitViewController.
adding :

    if let indexURL = Bundle.main.url(forResource: "index",
                                      withExtension: "html"

    ) {
        self.webView.loadFileURL(indexURL,
                                 allowingReadAccessTo: indexURL)
    }

but when opening the plugin the webview remain blank
I have the following error message :
2022-04-06 23:37:19.589269+0200 VieOSX[21892:4718842] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.

Any help or suggestions appreciated.

Comments

  • Hi. That's a pretty technical question for an Audiobus user forum. There's actually a separate developer forum, linked from "Developers" in the top of this page. I don't know what goes on in there, but you might find some more knowlegable help there.

  • Are you doing this in a native macOS AU, Mac Catalyst, or the simulator. I haven't tried to do a webview in an AUv3, but I do use them in my docs for my container app and I vaguely remember there being an issue with getting it to work at least in the simulator. I'll look around and see if I can remember what the issue was.

    One thing you might want to check is that I have com.apple.security.network.client in my entitlements file for the app.

  • edited April 7

    One thing you might want to try if you don't have it in already is this WKNavigationDelegate method,

    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction,
                     decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
    
            if navigationAction.navigationType == .linkActivated  { // A link is clicked forward to browser
    
                if let url = navigationAction.request.url, UIApplication.shared.canOpenURL(url) {
    
                    UIApplication.shared.open(url)
                    decisionHandler(.cancel)
                }
    
            } else { // The action isn't a web link, handle it here.
    
                decisionHandler(.allow)
            }
        }
    

    The delegate docs are here, https://developer.apple.com/documentation/webkit/wknavigationdelegate

    and the specific method is here, https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview

    Edit to make what I was saying more clear:

    You need to make your view controller that you are doing this for conform to the WKNavigationDelegate protocol and then somewhere in the viewDidLoad func you need to set the delegate on the WKWebView to your view controller. In mine I do it like this,

        self.web_view = WKWebView(frame: .zero)
        self.web_view.navigationDelegate = self
        containerView.addSubview(self.web_view)
    

    I don't know if this is going to work for you, but it might and it's the part that allows the WKWebView to load a local file but will send any non-local type URL out to the default web browser and take it out of your sandbox.

  • I think you need to set NSAllowsArbitraryLoads in the Info.plist dictionary NSAppTransportSecurity to YES.

    https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity/nsallowsarbitraryloads

  • Thanks you all for the infos. I will try this and let you know if I have any success

  • @NeonSilicon said:
    Are you doing this in a native macOS AU, Mac Catalyst, or the simulator. I haven't tried to do a webview in an AUv3, but I do use them in my docs for my container app and I vaguely remember there being an issue with getting it to work at least in the simulator. I'll look around and see if I can remember what the issue was.

    One thing you might want to check is that I have com.apple.security.network.client in my entitlements file for the app.

    For now I try on both MAC on a IOS simulator and on my devices. I also try the web view with local html file and url.
    No success for now, I'll try the WKNavigationDelegate solution.

  • @Jeezs said:

    @NeonSilicon said:
    Are you doing this in a native macOS AU, Mac Catalyst, or the simulator. I haven't tried to do a webview in an AUv3, but I do use them in my docs for my container app and I vaguely remember there being an issue with getting it to work at least in the simulator. I'll look around and see if I can remember what the issue was.

    One thing you might want to check is that I have com.apple.security.network.client in my entitlements file for the app.

    For now I try on both MAC on a IOS simulator and on my devices. I also try the web view with local html file and url.
    No success for now, I'll try the WKNavigationDelegate solution.

    If you are wanting to display external web pages and allow following links, then you're probably going to have to change the first section of the if statement. I have that in there because I only load from local files. I did this to make sure that I wouldn't get hit by security checks for displaying external content.

    Do you get the same error when running on device?

  • I did some testing today to see if I could get a WKWebView to work in one of my test AU's. It does work OK for me.

    I did not include the navigation delegate and that has worked fine. Actually the navigation delegate methods aren't being called in the AU extension when I add them anyway, which is weird.

    I added a WKWebView in the storyboard for the AU view controller and then tried loading a local file with .loadFileURL(url, allowingReadAccessTo: url) and this works fine. I then tried doing an external web page with

    let myURL = URL(string:"https://www.apple.com/")
    let myRequest = URLRequest(url: myURL!)
    web_view.load(myRequest)
    

    And this works fine. I haven't added anything at this point in the info.plist or the entitlements for the AU.

    For the local file load that you tried, it could be that the file isn't getting included in the bundle. Make sure that it's included the AU's target membership.

    For the external webpage load, if the page isn't on a secure https server, then you do need to do what @polaron_de suggested. You need to add the following to the Info.plist for the AU.

    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
          <true/>
    </dict>
    
  • If it works for it’ll work for me too.
    I’ll try this

    Thanks a lot for taking time testing this and sharing.

  • BTW, the WKNavigationDelegate is working as it's supposed to in the AU. I was just dumb and forgot to uncomment out the point where I set the delegate. So, it could be used to do normal navigation stuff from within the AU UI. That being said though, using it to forward out external URL's to Safari to avoid possible problems with app store approval doesn't seem to work for AUv3's. The UIApplication.shared call won't work because you are in an extension and the UIViewController.extensionContext.open(url) method looks like it's disabled inside AUv3 app extensions. I can't get it to work anyway and I've found some documentation that indicates that the open(url) method is only possible in a limited number of app extension types on iOS.

  • @NeonSilicon said:
    BTW, the WKNavigationDelegate is working as it's supposed to in the AU. I was just dumb and forgot to uncomment out the point where I set the delegate. So, it could be used to do normal navigation stuff from within the AU UI. That being said though, using it to forward out external URL's to Safari to avoid possible problems with app store approval doesn't seem to work for AUv3's. The UIApplication.shared call won't work because you are in an extension and the UIViewController.extensionContext.open(url) method looks like it's disabled inside AUv3 app extensions. I can't get it to work anyway and I've found some documentation that indicates that the open(url) method is only possible in a limited number of app extension types on iOS.

    Hello, after many tries I've been unable to make it work.
    Is it possible for you to share your Xcode project?

    Thanks for help

  • @Jeezs said:

    @NeonSilicon said:
    BTW, the WKNavigationDelegate is working as it's supposed to in the AU. I was just dumb and forgot to uncomment out the point where I set the delegate. So, it could be used to do normal navigation stuff from within the AU UI. That being said though, using it to forward out external URL's to Safari to avoid possible problems with app store approval doesn't seem to work for AUv3's. The UIApplication.shared call won't work because you are in an extension and the UIViewController.extensionContext.open(url) method looks like it's disabled inside AUv3 app extensions. I can't get it to work anyway and I've found some documentation that indicates that the open(url) method is only possible in a limited number of app extension types on iOS.

    Hello, after many tries I've been unable to make it work.
    Is it possible for you to share your Xcode project?

    Thanks for help

    The project I have it in is a huge jumble of all of my AU's, a host, and my support libraries. It would be more confusing than useful. I'll try to make a little demo project and get it working there. It shouldn't take too long. I need to look at making a minimal AU anyway to see if I can use it to base an Xcode template off of.

    What OS level are you targeting?

  • I target iOS 15 and Mac OS 12.

  • @Jeezs said:
    I target iOS 15 and Mac OS 12.

    OK, I'll set it to those targets. The AU I tested in before was targeting 14.1 and 11.0. I doubt if that will make any difference, but it will be good to test the same targets.

  • Yes if it work for 14.1 and 11.0 it’s ok

  • I will also try on another computer.
    Currently I work on a M1 and target iOS 15 and MacOS 12 it may be one of the cause of the multiple problems I have.

  • To make things quicker I decided to add a webview to the CircuitBreaker project I have on GitHub. The zip file at

    http://www.neonsilicon.com/Downloads/CircuitBreaker.zip

    has the modified project. I've stripped out the project configuration so it won't have my identifiers in the project. The Readme at github for the project describes how to run the setup.sh script to configure the project with your developer credentials.

    https://github.com/NeonSilicon/CircuitBreaker

    In the viewDidLoad method of the view controller there are a couple of sections that you can uncomment or comment to load either a local page from the bundle or a remote page from a website. I used my own website because it doesn't use https and demonstrates the loading of an unsecured site using the NSAppTransportSecurity dictionary in the Info.plist.

    Let me know if you have any issues getting it configured or running.

  • edited April 21

    Just try on two different machines.
    The auv3 compile correctly but didn’t appear in hosts ether iOS and Mac.
    I often have this problem when compiling my own auv3 and it seems to me totally erratic.
    When I create a new auv3 project from scratch sometimes the plugin appear in the host sometimes not.
    I’ll try to figure out why.

  • edited April 21

    @NeonSilicon said:
    To make things quicker I decided to add a webview to the CircuitBreaker project I have on GitHub. The zip file at

    http://www.neonsilicon.com/Downloads/CircuitBreaker.zip

    has the modified project. I've stripped out the project configuration so it won't have my identifiers in the project. The Readme at github for the project describes how to run the setup.sh script to configure the project with your developer credentials.

    https://github.com/NeonSilicon/CircuitBreaker

    In the viewDidLoad method of the view controller there are a couple of sections that you can uncomment or comment to load either a local page from the bundle or a remote page from a website. I used my own website because it doesn't use https and demonstrates the loading of an unsecured site using the NSAppTransportSecurity dictionary in the Info.plist.

    Let me know if you have any issues getting it configured or running.

    I’ve finally succeed to make it work.
    Need to understand why the AUV3 sometime won’t appear in the host.
    Anyway thanks a lots.

  • @Jeezs said:

    @NeonSilicon said:
    To make things quicker I decided to add a webview to the CircuitBreaker project I have on GitHub. The zip file at

    http://www.neonsilicon.com/Downloads/CircuitBreaker.zip

    has the modified project. I've stripped out the project configuration so it won't have my identifiers in the project. The Readme at github for the project describes how to run the setup.sh script to configure the project with your developer credentials.

    https://github.com/NeonSilicon/CircuitBreaker

    In the viewDidLoad method of the view controller there are a couple of sections that you can uncomment or comment to load either a local page from the bundle or a remote page from a website. I used my own website because it doesn't use https and demonstrates the loading of an unsecured site using the NSAppTransportSecurity dictionary in the Info.plist.

    Let me know if you have any issues getting it configured or running.

    I’ve finally succeed to make it work.
    Need to understand why the AUV3 sometime won’t appear in the host.
    Anyway thanks a lots.

    Which host are you testing in? MacOS or iOS. I use Apple's sample code host for quick testing and it has trouble seeing the AU on macOS when launched from Xcode. I usually have to click over to the "Instruments" tab and then back to the "Effects" tab to get it to see the AU that I'm testing. There seems to be a lag in the system registering the AU when Xcode launches the host.

  • @NeonSilicon said:

    @Jeezs said:

    @NeonSilicon said:
    To make things quicker I decided to add a webview to the CircuitBreaker project I have on GitHub. The zip file at

    http://www.neonsilicon.com/Downloads/CircuitBreaker.zip

    has the modified project. I've stripped out the project configuration so it won't have my identifiers in the project. The Readme at github for the project describes how to run the setup.sh script to configure the project with your developer credentials.

    https://github.com/NeonSilicon/CircuitBreaker

    In the viewDidLoad method of the view controller there are a couple of sections that you can uncomment or comment to load either a local page from the bundle or a remote page from a website. I used my own website because it doesn't use https and demonstrates the loading of an unsecured site using the NSAppTransportSecurity dictionary in the Info.plist.

    Let me know if you have any issues getting it configured or running.

    I’ve finally succeed to make it work.
    Need to understand why the AUV3 sometime won’t appear in the host.
    Anyway thanks a lots.

    Which host are you testing in? MacOS or iOS. I use Apple's sample code host for quick testing and it has trouble seeing the AU on macOS when launched from Xcode. I usually have to click over to the "Instruments" tab and then back to the "Effects" tab to get it to see the AU that I'm testing. There seems to be a lag in the system registering the AU when Xcode launches the host.

    Yes I test it on the Mac.
    I thought I try on iOS too but on real device not the emulator.
    Dunno if it can cause the problem too.

Sign In or Register to comment.