Basic SwiftMonkey-Implementation fails with "Bundle couldn't be loaded"

295 views Asked by At

I've been trying to add a SwiftMonkey-Target to my current project for several hours, and nothing seems to work.

The Example-Project from https://github.com/zalando/SwiftMonkey is working. Everything is set up the same way / According to instructions.

  • Running on XCode 10.1
  • Pods installed (to iOS 11.0 base level)
  • SwiftMonkeyPaws imported to AppDelegate, paws assigned on startup
  • New UI-Test Deploy-Target which calls the example testMonkey()-function
  • Scheme set to "test" only (not run), as in example-project
  • Scheme Deploy-Target set to 11.0

This is the test-code (identical to example-code):

import XCTest
import SwiftMonkey

class AdviceAppMonkeyTests: XCTestCase {

override func setUp() {
    super.setUp()
    XCUIApplication().launch()
}

override func tearDown() {
    super.tearDown()
}

func testMonkey() {
    let application = XCUIApplication()
    _ = application.descendants(matching: .any).element(boundBy: 0).frame
    let monkey = Monkey(frame: application.frame)
    monkey.addDefaultXCTestPrivateActions()
    monkey.addDefaultUIAutomationActions()
    monkey.addXCTestTapAlertAction(interval: 100, application: application)
    monkey.monkeyAround(forDuration: 10)
}
}

And this is my podfile:

platform :ios, '11.0'
use_frameworks!

def advice_pods
    pod 'SwiftyJSON'
    pod 'Firebase/Core'
    pod 'Firebase/AdMob'
    pod 'SwiftLint'
end

target 'AdviceApp' do
    advice_pods
    pod 'SwiftMonkeyPaws', '~> 2.1.0'
end

target 'Daily Advice' do
    advice_pods
end

target 'AdviceAppTests' do
    advice_pods
end

target 'AdviceAppMonkeyTests' do
    advice_pods
    pod 'SwiftMonkey', '~> 2.1.0'
end

When I run the test I get a "test failed" warning as well as a

2019-01-07 10:15:54.790962+0100 AdviceAppMonkeyTests-Runner[14731:110840] The bundle “AdviceAppMonkeyTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2019-01-07 10:15:54.791073+0100 AdviceAppMonkeyTests-Runner[14731:110840] (dlopen_preflight(/Users/matthias.zarzecki/Library/Developer/Xcode/DerivedData/AdviceApp-hantxpruajwefgbjvzwhvlvwhmrh/Build/Products/Debug-iphonesimulator/AdviceAppMonkeyTests-Runner.app/PlugIns/AdviceAppMonkeyTests.xctest/AdviceAppMonkeyTests): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib Referenced from: /Users/matthias.zarzecki/Library/Developer/Xcode/DerivedData/AdviceApp-hantxpruajwefgbjvzwhvlvwhmrh/Build/Products/Debug-iphonesimulator/AdviceAppMonkeyTests-Runner.app/PlugIns/AdviceAppMonkeyTests.xctest/Frameworks/SwiftMonkey.framework/SwiftMonkey Reason: image not found)

Do you have any ideas what I could try out?

1

There are 1 answers

0
matthias_code On BEST ANSWER

I worked with the creators over several days to solve this, and we figured it out :)

All details here: https://github.com/zalando/SwiftMonkey/issues/71

TLDR: use_frameworks needs to go inside the target-pods of the main target only

platform :ios, '11.0'

target 'AdviceApp' do
    use_frameworks!
    pod 'SwiftyJSON'
    pod 'Firebase/Core'
    pod 'Firebase/AdMob'
    pod 'SwiftLint'
    pod 'SwiftMonkeyPaws'
end

target 'AdviceAppMonkeyTests' do
    pod 'SwiftMonkey', '~> 2.1.0'
    pod 'SwiftLint'
end

Also alternatively setting the build-system to "legacy" made it work, but that had too much potential to go wrong somewhere else in the future