Unable to see XCode/SwiftUI Previews within CocoaPods frameworks
#9,275 opened on 2019/10/20
Repository metrics
- Stars
- (14,815 個のスター)
- PR merge metrics
- (30d に merged PR はありません)
説明
- [Y] I've read and understood the CONTRIBUTING guidelines and have done my best effort to follow.
Report
What did you do?
Sample project https://github.com/jayayres/cocoapodsswiftuipreviewbugreport git clone https://github.com/jayayres/cocoapodsswiftuipreviewbugreport.git cd cocoapodsswiftuipreviewbugreport ; bundle install --binstubs ; bundle exec pod install Open in Xcode 11.1, on Mac OS Catalina Try using SwiftUI preview functionality for Pods/Development Pods/MyStaticPod/MyStaticPodSwiftUIView.swift , Pods/Development Pods/MyPod/MyDynamicPodSwiftUIView.swift, and MyPodTest/MyPodTest/MyMainAppSwiftUIView.swift
What did you expect to happen?
XCode previews should work for all 3 files.
What happened instead?
XCode previews always fail for MyStaticPodSwiftUIView.swift (which is set up with static_framework = true in its podspec) with: noPreviewInfos(arch: "x86_64", sdkRoot: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.1.sdk")
XCode previews fail most of the time for MyDynamicPodSwiftUIView.swift (unless a clean build is done, and that is the only dynamic pod in which previews are done, and previews are not done first for MyMainAppSwiftUIView.swift) with:
Xcode Previews rendering agent: Error Domain=com.apple.dt.UITestingAgent Code=-1 "failed to load library at path "/DerivedData/MyPodTest-hcoikzfhpffncqcobtylgtykwvvb/Build/Intermediates.noindex/Previews/MyPodTest/Products/Debug-iphonesimulator/MyStaticPod/MyStaticPod.framework/MyStaticPod": Optional(dlopen(/DerivedData/MyPodTest-hcoikzfhpffncqcobtylgtykwvvb/Build/Intermediates.noindex/Previews/MyPodTest/Products/Debug-iphonesimulator/MyStaticPod/MyStaticPod.framework/MyStaticPod, 0): no suitable image found
or sometimes: MyPodTest.app: Error Domain=com.apple.dt.UITestingAgent Code=-1 "Preview provider "9MyPodTest32MyDynamicPodSwiftUIView_PreviewsV" does not exist" UserInfo={NSLocalizedDescription=Preview provider "9MyPodTest32MyDynamicPodSwiftUIView_PreviewsV" does not exist}
It looks like Xcode internally uses preview-thunk.dylib for previews. It appears that the preview functionality is not working at present within CocoaPods for either static or dynamic frameworks however.
CocoaPods Environment
CocoaPods : 1.8.4
Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
RubyGems : 3.0.6
Host : Mac OS X 10.15 (19A602)
Xcode : 11.1 (11A1027)
Git : git version 2.21.0 (Apple Git-122)
Ruby lib dir : /usr/local/var/rbenv/versions/2.6.3/lib
Repositories : cocoapods- - CDN - https://cdn.cocoapods.org/
master - git - https://github.com/CocoaPods/Specs.git @ 7dd20d6b83719245167a244512860ef8b1ea5e99
Installation Source
Executable Path: ./bin/pod
Plugins
cocoapods-deintegrate : 1.0.4
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.1.0
cocoapods-trunk : 1.4.1
cocoapods-try : 1.1.0
Podfile
source 'https://cdn.cocoapods.org/'
platform :ios, 13.0
target 'MyPodTest' do
use_frameworks!
pod 'MyPod', path: 'lib/MyPod'
pod 'MyStaticPod', path: 'lib/MyStaticPod'
end
Project that demonstrates the issue
https://github.com/jayayres/cocoapodsswiftuipreviewbugreport.git