2015-06-17 13 views
12

Ho un progetto Objective-C esistente e voglio aggiungere un nuovo target di test dell'interfaccia utente Xcode 7 con OHHTTPStubs come dipendenza.Includere una dipendenza da test dell'interfaccia utente Xcode 7 tramite Cocoapods?

ho aggiunto il nuovo (Swift 2.0) bersaglio test UI in Xcode, poi ha aggiunto questo al mio Podfile:

target 'FooUITests' do 
    pod 'OHHTTPStubs', '4.0.1' 
end 

ho corse pod update, puliti, e ricostruito. Ma quando provo e import OHHTTPStubs nella parte superiore del file di test UI di prova del modello .swift creato per me, si lamenta "Nessun modulo" OHHTTPStubs "".

Sto usando la versione 0.37.2 di Cocoapods-sta importando una dipendenza Objective-C in un obiettivo Swift (... UI test) che ha lo scopo di funzionare?

UPDATE: Come osservato nel mio self-answer di seguito, aggiungendo use_frameworks! alla mia Podfile ottiene purificarmi compilation-posso import OHHTTPStubs nella parte superiore del mio file di prova, classi e metodi, completamento del codice di riferimento funziona, ma quando ho effettivamente andare per eseguire i test ottengo il seguente output nella console Xcode:

2015-06-18 10:06:57.134 XCTRunner[51557:609693] The bundle “FooUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 
2015-06-18 10:06:57.135 XCTRunner[51557:609693] (dlopen_preflight(/Users/foo/Library/Developer/CoreSimulator/Devices/38181A1B-67B1-4D7F-B434-85361533F985/data/Containers/Bundle/Application/83C68748-55A3-4A02-8862-C18ADEF895B5/FooUITests-Runner.app/PlugIns/FooUITests.xctest/FooUITests): Library not loaded: @rpath/OHHTTPStubs.framework/OHHTTPStubs 
    Referenced from: /Users/foo/Library/Developer/CoreSimulator/Devices/38181A1B-67B1-4D7F-B434-85361533F985/data/Containers/Bundle/Application/83C68748-55A3-4A02-8862-C18ADEF895B5/FooUITests-Runner.app/PlugIns/FooUITests.xctest/FooUITests 
    Reason: image not found) 

ci sembrano essere Release-iphoneos e Release-iphonesimulator costruisce del OHHTTPStubs.framework sotto la mia directory ~/Library/Developer/DerivedData però.

Qualche suggerimento su cosa sta succedendo?

risposta

2

Risulta tutto quello che dovevo fare era dire Cocoapods a use_frameworks! (per il target Swift solo) nella Podfile:

target 'FooUITests' do 
    use_frameworks! 
    pod 'OHHTTPStubs', '4.0.1' 
end 
+2

Hmm, forse non così veloce. Non funziona più, nonostante (a causa di?) Molte pulizie e ricostruzioni. Ora sto ottenendo "Impossibile caricare il pacchetto" Foo "perché è danneggiato o manca le risorse necessarie. Prova a reinstallare il pacchetto." ogni volta che provo e in realtà eseguo i test, anche se lo fa. –

+0

Lo hai mai capito? Avere gli stessi problemi. – piofusco

1

Aggiunta di una [CP] Embed Pods Frameworks Eseguire la fase di compilazione degli script sul mio obiettivo di prova ha risolto questo problema per me, come descritto in this CocoaPods GitHub issue.

Si noti che nel vostro target regolare, il tratto fasi di creazione contiene sia [CP] Copy Pods Resources (che corre "${SRCROOT}/../../Pods/Target Support Files/Pods-YOURTARGET/Pods-YOURTARGET-resources.sh"), e [CP] Embed Pods Frameworks (che gestisce "${SRCROOT}/../../Pods/Target Support Files/Pods-YOURTARGET/Pods-YOURTARGET-frameworks.sh"). Ma il tuo target di test contiene solo [CP] Copy Pods Resources.

Aggiungere manualmente la fase Script di esecuzione [CP] Embed Pods Frameworks all'obiettivo di test (per eseguire "${SRCROOT}/../../Pods/Target Support Files/Pods-YOURTESTTARGET/Pods-YOURTESTTARGET-resources.sh").

Problemi correlati