Closed matthiaszarzecki closed 5 years ago
Hey @matthiaszarzecki and sorry for the late reply. Are you still facing the issues described? If so, one thing that you might check is whether SwiftMonkey is present in "Embedded Binaries" in "Genera" project settings:
At least I recall having to do something with that...
Thanks for getting back to me @wojciechczerski! No, so far The Binaries weren't added.
But if I add them, like so:
A new error appears saying
Showing Recent Messages
:-1: Multiple commands produce '/Users/matthias.zarzecki/Library/Developer/Xcode/DerivedData/AdviceApp-hantxpruajwefgbjvzwhvlvwhmrh/Build/Products/Debug-iphonesimulator/AdviceApp.app/Frameworks/SwiftMonkeyPaws.framework':
1) Target 'AdviceApp' has copy command from '/Users/matthias.zarzecki/Library/Developer/Xcode/DerivedData/AdviceApp-hantxpruajwefgbjvzwhvlvwhmrh/Build/Products/Debug-iphonesimulator/SwiftMonkeyPaws.framework' to '/Users/matthias.zarzecki/Library/Developer/Xcode/DerivedData/AdviceApp-hantxpruajwefgbjvzwhvlvwhmrh/Build/Products/Debug-iphonesimulator/AdviceApp.app/Frameworks/SwiftMonkeyPaws.framework'
2) That command depends on command in Target 'AdviceApp': script phase “[CP] Embed Pods Frameworks”
Which makes me think the binaries are automatically imported when installed via pods (as pods themselves usually do not need to be added manually to the embedded binaries).
What do you think? :)
I was able to reproduce the issue you are encountering and one fix that I knew was to switch to the legacy build system. But since it's not very satisfying I did some searching and I think the solution is here.
The thing that helped me was to change the Podfile
to be flat (no nested targets). However I see that you already have it. Another thing is the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
flag. Do you perhaps get a warning when executing pod install
, something like:
... target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in ...
if so, please try following this. if that doesn't help, maybe it'll be enough to just go with the legacy system? To do this:
Please let me know if this helped.
BTW: You could remove SwiftMonkey
from your app-target. It is only needed in UI tests target. The Podfile
could look like this:
platform :ios, '11.0'
use_frameworks!
def advice_pods
pod 'SwiftyJSON'
pod 'Firebase/Core'
pod 'Firebase/AdMob'
pod 'SwiftLint'
pod 'SwiftMonkeyPaws', '~> 2.1.0'
end
target 'AdviceApp' do
advice_pods
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
In fact I am wondering whether you need the advice_pods
in your AdviceAppMonkeyTests
at all. If things keep on not working, could you try removing it?
target 'AdviceAppMonkeyTests' do
pod 'SwiftMonkey', '~> 2.1.0'
end
Also in my test Podfile
the use_frameworks!
flag is only in the app-target and not in tests. Perhaps you could try removing it from the AdviceAppMonkeyTests
target.
Thanks again for the series of ideas! I tried out several. Just adding SwiftMonkey to AdviceAppMonkeyTests (and all other targets adapted to only use the pods they actually require) did not end up working.
Switching the Workspace-Settings to Legacy did work though! :D
To be sure this was it I just created a fresh empty project and again added SwiftMonkey via Pods. It also failed when I wanted to run it, and then worked when I set the workspace-settings to "legacy". :)
Is this a thing you'd like to add to the instructions, or possibly could update in the future? I'm not sure how having the old system in our production-environment will affect everything else in the future ;) (I'm also working on introducing this to several much larger environments)
Great to hear that at least one solution worked for you @matthiaszarzecki ! Though I must say this one is not very satisfying TBH. As you mentioned, a clean project integrating SwiftMonkey should fail as well therefore I'll try to reproduce it.
@wojciechczerski Haha, it is not satisfying /at all/. Curious to see how it looks on your machine!
Hey @matthiaszarzecki! I have created a sample project (TestSwiftMonkey) in which I integrated both SwiftMonkey
and SwiftMonkeyPaws
pods. It have tested it on a simulator and on a real device and the "monkey tests" ran on both. Could you please have a look whether the project works for you as well?
Cool, thanks @wojciechczerski!
Your project does actually work on my computer, huh. Did we maybe set it up differently?
I recreated mine again too (failing to work, legacy-build-fix not enabled) and uploaded it. Does it maybe work on your side? SwiftMonkeyForZalando
Here are the steps I did:
@matthiaszarzecki Thanks for sharing the project! I did some investigation and assuming it does compile on your machine at all (I'll explain this later), the fix most likely is to move use_frameworks!
from the top of the Podfile
to the SwiftMonkeyInstallForZalando
target, like that:
platform :ios, '11.0'
target 'SwiftMonkeyInstallForZalando' do
use_frameworks!
pod 'SwiftMonkeyPaws'
end
target 'SwiftMonkeyInstallForZalandoMonkeyTesting' do
pod 'SwiftMonkey'
end
In my case your project did not compile at all. After I ran pod install
, opened the workspace and tried to build it, I got an error caused by missing files:
I deleted the Pods
folder and opened the SwiftMonkeyInstallForZalando.xcodeproj
(not the workspace!). The project looked like this:
The project should not contain references to the Pods
directory. I removed this reference, saved the SwiftMonkeyInstallForZalando.xcodeproj
and ran the pod install
again. After opening the workspace, the project did not contain missing files and it could build:
With these changes I was able to build and run the app but the tests were still failing to run. I didn't get exactly the error you had:
SwiftMonkeyInstallForZalandoMonkeyTesting-Runner.app (35153) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying error: The test runner failed to load the test bundle. Executable cannot be loaded for some other reason, such as a problem with a library it depends on or a code signature/entitlements mismatch.))
At this point making a change to the Podfile
that I mentioned solved the issue and the tests could run.
NOTE: I did all testing using CocoaPods version 1.5.3
. Your Podfile.lock
indicates you are using 1.6.0.beta.2
which could generate the workspace differently. Perhaps you could also update your CocoaPods installation to the latest 1.6.0.rc.2
(if you need to use 1.6 version, otherwise stable 1.5 should work fine).
@wojciechczerski good idea looking into the CocoaPods-Version, I didn't think of that!
I think it's the use_frameworks! :D
I just did several tests with the project I provided earlier, and the actual project I've been trying to add MonkeyTests too.
Setting it to the actual build-engine (not legacy) and adding use_frameworks to the main target in the podfile makes it work.
Counter-Test: Putting it at the top of the podfile again (and doing a pod deintegrate, pod install) then triggers an error on run. Putting it back into the main targets and doing a clean pod-install with deintegrate before works again :)
This is a way more satisfying solution than putting it into legacy-build-mode ;P
@matthiaszarzecki Glad to hear that it worked! If it is solved for you, can we close this issue?
Thank you so much @wojciechczerski! Yes, this is done then. Would of course love to see your pod-install-instructions on the main page be updated with this new info :)
Hi Everyone!
I've been trying to add a SwiftMonkey-Target to my current project for several hours, and nothing seems to work.
The Example-Project is working. Everything is set up the same way / According to instructions.
This is the test-code (identical to example-code without comments):
And this is the Podfile:
When I run the test I get a "test failed" warning as well as this:
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?