Results 1 to 4 of 4

Thread: Adding Skobbler to a swoft framework (instead of an app)

  1. #1
    Etablierter skobbler
    Join Date
    26.10.2015
    Posts
    36

    Adding Skobbler to a swoft framework (instead of an app)

    We're evaluating skobbler for a large deployment.

    I'm building a framework that will be included in one or more apps.

    I followed the steps to add in the documentation to add the cocoapod to my framework, but the framework doesn't build. It can't import SKMaps. I had to make two changes to make it work:
    1. Add "${PODS_ROOT}/ScoutMaps-iOS-SDK/SKMaps.framework/Headers" to my Header Search Paths
    2. Manually create module.modulemap in "${PODS_ROOT}/ScoutMaps-iOS-SDK/SKMaps.framework/Headers"

    Content of module.modulemap

    Code:
    module SKMaps {
    	header "SKMaps.h"
    	export *
    }
    These two changes got me building successfully, but now I need to create a private cocoapod for my own framework. I'm hitting the same errors again.

    From what I have been able to determine, https://developer.apple.com/library/...xandMatch.html describes what you need to do to package an Objective-C cocoapod so it can be used inside other Swift frameworks. See the section titled "Importing Code from Within the Same Framework Target"

    In the meantime, I suppose I'll have to hack a fix in the podspec for my cocoapod, and find a way to make it work with the ScoutMaps-iOS-SDK cocoapod. I'm not sure yet how I'll do that.

    To reproduce my problem:
    1. Create a new swift iOS framework project.
    a. File | New | Project.
    b. In the left panel under iOS, select Framework & Library.
    c. In the right panel, select CocoaTouch Framework. Next.
    d. Enter project name, SkobblerNestedFramework. Make sure to select Swift for the language. Next.
    e. Choose location for project. Create.

    2. Create Podfile:

    Code:
    platform :ios, '9.0'
    use_frameworks!
    
    target 'SkobblerNestedFramework' do
    	pod 'ScoutMaps-iOS-SDK'
    end
    
    target 'SkobblerNestedFrameworkTests' do
    	pod 'ScoutMaps-iOS-SDK'
    end
    3. Pod Install
    4. Create a class that uses SKMapView


    Code:
    import UIKit
    import SKMaps
    
    public class SkobblerMapView: UIView {
    
    	var mapView: SKMapView
    
    	public override init(frame: CGRect) {
    		mapView = SKMapView(frame: CGRectMake(0,0, frame.size.width, frame.size.width))
    		super.init(frame: frame)
    		self.addSubview(mapView)
    	}
    
    	required public init?(coder aDecoder: NSCoder) {
    		mapView = SKMapView(frame: CGRectZero)
    		super.init(coder: aDecoder)
    	}
    
    	public override func awakeFromNib() {
    		super.awakeFromNib()
    		mapView.frame = self.bounds
    		self.addSubview(mapView)
    	}
    }
    According to the Apple documentation, the "import SKMaps" should not be necessary. Removing it results in errors on every line that references mapView.

    I tried to attach a zip file with a sample project created with the steps above, but I would not upload, probably due to size (94 MB).


    Does anyone have suggestions about how to work around this problem so that my cocoapod, with its dependency on the ScoutMaps-iOS-SDK cocoapod will work? (pod lib lint fails because it can't find SKMaps).

    Thanks!

  2. #2
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    I’ll forward this request to our developers. I'll get back with an update

  3. #3
    Etablierter skobbler
    Join Date
    26.10.2015
    Posts
    36
    For what it is worth, I backed out these two changes in my Xcode project:

    1. Add "${PODS_ROOT}/ScoutMaps-iOS-SDK/SKMaps.framework/Headers" to my Header Search Paths
    2. Manually create module.modulemap in "${PODS_ROOT}/ScoutMaps-iOS-SDK/SKMaps.framework/Headers"

    So, I removed "${PODS_ROOT}/ScoutMaps-iOS-SDK/SKMaps.framework/Headers" from my Header Search Paths, and
    Deleted module.modulemap that I had created in in "${PODS_ROOT}/ScoutMaps-iOS-SDK/SKMaps.framework/Headers"

    I replaced these with a build run script that copies the headers, and adds the module.modulemap file to the new header location. This way I don't have to remember to re create the module.modulemap file whenever I update the ScoutMaps-iOS-SDK cocoapod.

    Code:
    HEADER_DIR="${PODS_ROOT}/Headers/Public/SKMaps"
    FILES_TO_COPY="*"
    mkdir -p "${PODS_ROOT}/Headers/Public/SKMaps"
    cp -f "${PODS_ROOT}"/ScoutMaps-iOS-SDK/SKMaps.framework/Versions/A/Headers/${FILES_TO_COPY} "${HEADER_DIR}"
    echo "module SKMaps {" > "${HEADER_DIR}"/module.modulemap
    echo "    header \"SKMaps.h\"" >> "${HEADER_DIR}"/module.modulemap
    echo "    export *" >> "${HEADER_DIR}"/module.modulemap
    echo "}" >> "${HEADER_DIR}"/module.modulemap
    This keeps my Xcode build working, but still don't have a way to create my own podspec that will validate correctly with pod lib lint.

    Thanks!

  4. #4
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    Thanks for the additional information. I've reported forward.

    Update [17-05-2016]:
    The issue was fixed and would be included in the next release 3.0
    Last edited by Adela_Silvia; 18.05.2016 at 09:22.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •